{"id":21991517,"url":"https://github.com/terrabits/oittm-smart-plug","last_synced_at":"2026-05-05T14:07:24.031Z","repository":{"id":98389569,"uuid":"229835753","full_name":"Terrabits/oittm-smart-plug","owner":"Terrabits","description":"Hacking an ESP8266-based OITTM Smart Plug with Micropython.","archived":false,"fork":false,"pushed_at":"2020-01-13T19:08:11.000Z","size":1154,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-08T19:58:58.143Z","etag":null,"topics":["esp8266","hacking","micropython"],"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/Terrabits.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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-12-23T23:13:10.000Z","updated_at":"2020-01-13T19:08:13.000Z","dependencies_parsed_at":"2023-03-25T23:18:13.823Z","dependency_job_id":null,"html_url":"https://github.com/Terrabits/oittm-smart-plug","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Terrabits/oittm-smart-plug","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Terrabits%2Foittm-smart-plug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Terrabits%2Foittm-smart-plug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Terrabits%2Foittm-smart-plug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Terrabits%2Foittm-smart-plug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Terrabits","download_url":"https://codeload.github.com/Terrabits/oittm-smart-plug/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Terrabits%2Foittm-smart-plug/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000658,"owners_count":26082805,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["esp8266","hacking","micropython"],"created_at":"2024-11-29T20:09:36.146Z","updated_at":"2025-10-08T19:58:58.543Z","avatar_url":"https://github.com/Terrabits.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Oittm Smart Plug Hack\n\nYet another ESP8266-based smart plug hack. This one is on the Oittm Smart Plug I purchased some time ago on Amazon.\n\n![Amazon - Oittm WiFi Smart Plug listing](doc/amazon-oittm-smart-plug-listing.png)\n\nI referenced [this Not Enough Tech article](https://notenoughtech.com/featured/esp8266-smart-plug/) which walks you through exactly how to get access to the ESP8266. From there, I began to code.\n\n## User Interface\n\n### Configuration Page\n\nThis is an MQTT-based hack.\n\nTo that end, the smart plug starts in access point mode and serves the following pages via HTTP\u0026#x3A;\n\n![Configure form](doc/screenshots/post-config.png)\n\nAfter entering the config information and clicking `Submit`, the smart plug displays the following message:\n\n![Configure confirmation page](doc/screenshots/display-config.png)\n\nThe smart plug will then restart and attempt to connect to WiFi and the MQTT broker. If successful, it will continue to function. If unsuccessful, it will restart in access point mode and you can try again.\n\n### Hard Reset\n\nPushing the button 10 times quickly (in \u0026lt; 3 s) will cause any saved settings to be deleted and the smart plug to perform a hard reboot.\n\n### MQTT\n\nWhen connected to WiFi and the MQTT broker, it can then be fully controlled via MQTT publishes to the following:\n\n| Verb      | Topic               | Message       | Result                                        |\n| --------- | ------------------- | ------------- | --------------------------------------------- |\n| Publish   | `main_topic/set`    | `on` or `off` | Outlet is turned `on` or `off`, respectively  |\n| Publish   | `main_topic/toggle` | don't care    | Outlet state is toggled                       |\n| Subscribe | `main_topic`        | `on` or `off` | observed on state changes, with updated state |\n\n## Hardware Requirements\n\n-   ESP8266-based smart plug\n-   micropython v1.12 or newer\n\nIf using a different smart plug, edit `src/smart_plug.py` to control the specifics of your device.\n\n## Installation\n\nFrom a fresh flash of micropython, copy all files from `src/` onto the microcontroller.\n\nI use [rshell](https://github.com/dhylands/rshell).\n\n```shell\n# from rshell,\n# with file system mounted to /pyboard:\n\ncd path/to/project\ncd src\ncp -r http   /pyboard\ncp -r states /pyboard\ncp    *.py   /pyboard\n```\n\n## Code\n\n### State Diagram\n\nThe operation is summarized by the state diagram, below.\n\n![state machine](doc/screenshots/main-state-machine.png)\n\n### Configuration\n\nThe configuration (handled by states with the `config/` prefix) is saved and recalled via the `Config` class in `src/config.py`.\n\nAll saved settings can be reset from the repl with the following snippet:\n\n```python\nfrom   config import Config\nimport machine\n\n# delete all saved state\nconfig = Config()\nconfig.delete()\n\n# hard reboot\nmachine.reset()\n```\n\nThis will force the smart plug to go into access point mode for reconfiguration.\n\n### HTTP Server\n\nI micro-HTTP server is included in `src/http`. This server is just \"big\" enough to handle this application.\n\nIt is not considered a complete or secure HTTP implementation.\n\n### MQTT Server\n\nAs this hack uses MQTT, it requires access to a broker (server) on your network. MQTT is configured along with WiFi via the configuration page.\n\nAll MQTT settings are ultimately editable in `src/mqtt.py`.\n\n### Wifi\n\nWifi control is implemented in `src/wifi.py`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterrabits%2Foittm-smart-plug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fterrabits%2Foittm-smart-plug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterrabits%2Foittm-smart-plug/lists"}