{"id":13801803,"url":"https://github.com/AnthonyKNorman/ESP8266-Home-Assistant-Smart-Socket","last_synced_at":"2025-05-13T12:30:30.054Z","repository":{"id":215173551,"uuid":"161210877","full_name":"AnthonyKNorman/ESP8266-Home-Assistant-Smart-Socket","owner":"AnthonyKNorman","description":"This Micropython project is to Hack a Hyleton313 cheap WiFi smart socket","archived":false,"fork":false,"pushed_at":"2019-01-23T14:31:02.000Z","size":9274,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-18T16:57:52.605Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AnthonyKNorman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-12-10T17:21:26.000Z","updated_at":"2023-08-11T08:20:43.000Z","dependencies_parsed_at":"2024-01-03T01:08:02.994Z","dependency_job_id":null,"html_url":"https://github.com/AnthonyKNorman/ESP8266-Home-Assistant-Smart-Socket","commit_stats":null,"previous_names":["anthonyknorman/esp8266-home-assistant-smart-socket"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnthonyKNorman%2FESP8266-Home-Assistant-Smart-Socket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnthonyKNorman%2FESP8266-Home-Assistant-Smart-Socket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnthonyKNorman%2FESP8266-Home-Assistant-Smart-Socket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnthonyKNorman%2FESP8266-Home-Assistant-Smart-Socket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AnthonyKNorman","download_url":"https://codeload.github.com/AnthonyKNorman/ESP8266-Home-Assistant-Smart-Socket/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253942108,"owners_count":21987985,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T00:01:27.639Z","updated_at":"2025-05-13T12:30:27.617Z","avatar_url":"https://github.com/AnthonyKNorman.png","language":"Python","funding_links":[],"categories":["Libraries"],"sub_categories":["Communications"],"readme":"# ESP8266-Home-Assistant-Smart-Socket\nThis Micropython project is to Hack a Hyleton313 cheap WiFi smart socket\n\nThe first thing to read is this write up https://github.com/arendst/Sonoff-Tasmota/wiki/Hyleton-313-Smart-Plug\n\nI have also cracked open the common circular version.\nThe wiring connection are as below\n\u003cimg src=\"/resources/Base_view.png\" width=\"500\"\u003e\n\n\n\u003cimg src=\"/resources/IMG_0265.JPG\" width=\"300\"\u003e\n\u003cimg src=\"/resources/IMG_0264.JPG\" width=\"300\"\u003e\n\nOnce you get it open you can see the blue processor board next to the relay. This is an ESP8266 variant, so I decided we could re-flash this plug with micropython\n\n\nThere is a blue led and a red led that shine through the little pin hole on the front. Both of these are directly controlled from GPIO pins. There is also a neat little push button switch that also goes to a GPIO pin. The relay is controlled by yet another GPIO, but when you are testing and powering the board from the usb serial this doesn't work. Probably because there is some sort of transistor driver on the board.\nSo, dismantle the case as per the instructions in the link above.\nThanks to the work of Theo Arends, you don't need to unsolder the ESP8266 board.\n\nConnect your USB seral board as per Theo's instructions, but don't flash the Sonoff software. Instead, download the Micropyton image from http://micropython.org/download#esp8266 and flash it to the board using:\n`esptool.py --port COM3 write_flash -fs 1MB -fm dout 0x0 esp8266-20180511-v1.9.4.bin`\n\nChange COM3 to suit your serial port\n\nChange esp8266-20180511-v1.9.4.bin to the name of the image you downloaded\n\nIf you haven't used esptool before, Adafruit has a great article here https://learn.adafruit.com/building-and-running-micropython-on-the-esp8266/flash-firmware\n\nYou should now be able to see the micropython prompt when you use a terminal tool such as putty.\n\n\u003cimg src=\"/resources/putty.png\" width=\"400\"\u003e\n\nTh enext step is to enble WebREPL. Once again, Adafruit has a great tutorial on how to do this. https://learn.adafruit.com/micropython-basics-esp8266-webrepl/access-webrepl\n\nOnce you have enabled WebREPL you can run scripts and upload files from your browser.\n\n\u003cimg src=\"/resources/webrepl.png\" width=\"400\"\u003e\n\nNow you can de-solder the wires for your USB Serial connector and re-assemble the Socket.\n\n##The Files##\ntimer.py - a class to implement a flashing led. You simple pass the timer an LED and it flashes until you run deinit\n\nwificonf.py - I wanted this to be as easy as possible to change and move, so, at first boot you connect to the SSID presented by the ESP8266 and point a browser to the ESP8266 default IP address http://192.168.4.1. The ESSID will be the default of the ESP8266. You change this in the web page presented below.\n\n\u003cimg src=\"/resources/webpage.png\" width=\"400\"\u003e\n\nCarefully enter your MQTT address, unique name, wifi SSID and password then click submit. Up to this point the blue LED will be flashing. Once you enter your credentials, and the socket connects to your wifi, the led will go out.\n\nThe socket will now be available for use by Home Assistant,or any other system that uses MQTT,\n\nHere is a snippet from my config.yaml file\n```\n  - platform: mqtt_json\n    name: \"SOCKET1\"\n    state_topic: \"home/socket1/status\"\n    command_topic: \"home/socket1/set\"\n    \n```\nwhere socket1 is the unique name entered via the web page.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAnthonyKNorman%2FESP8266-Home-Assistant-Smart-Socket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAnthonyKNorman%2FESP8266-Home-Assistant-Smart-Socket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAnthonyKNorman%2FESP8266-Home-Assistant-Smart-Socket/lists"}