{"id":19396563,"url":"https://github.com/costastf/philips_hue_switch","last_synced_at":"2026-05-06T09:43:11.697Z","repository":{"id":70676635,"uuid":"90738355","full_name":"costastf/philips_hue_switch","owner":"costastf","description":"micropython code that toggles a philips hue lamp to be used with a hardware switch making that existing wall switch not cutting the current off but using the api to toggle the lamps state. ","archived":false,"fork":false,"pushed_at":"2017-05-26T18:55:31.000Z","size":18714,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-03T22:55:49.014Z","etag":null,"topics":["esp01s","esp8266","micropython","philips-hue","philips-hue-lamp","philips-hue-lights","philips-hue-switch"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/costastf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2017-05-09T11:31:52.000Z","updated_at":"2020-03-06T09:43:50.000Z","dependencies_parsed_at":"2023-03-31T05:14:01.297Z","dependency_job_id":null,"html_url":"https://github.com/costastf/philips_hue_switch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/costastf/philips_hue_switch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/costastf%2Fphilips_hue_switch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/costastf%2Fphilips_hue_switch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/costastf%2Fphilips_hue_switch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/costastf%2Fphilips_hue_switch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/costastf","download_url":"https://codeload.github.com/costastf/philips_hue_switch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/costastf%2Fphilips_hue_switch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285035892,"owners_count":27103933,"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-11-18T02:00:05.759Z","response_time":61,"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":["esp01s","esp8266","micropython","philips-hue","philips-hue-lamp","philips-hue-lights","philips-hue-switch"],"created_at":"2024-11-10T10:36:04.775Z","updated_at":"2025-11-18T09:03:10.703Z","avatar_url":"https://github.com/costastf.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Philips hue switch\nMicropython code that toggles a philips hue lamp using wemos d1 mini or esp8266-01s\n\nThis project is to be used with a hardware switch making that existing wall\nswitch not cutting the power off but using the api to toggle the lamp's\nstate.\n\nSome electrical assembly required :)\n\n# WARNING\nOnly mess with high current if you really really know what you are doing. If\nnot certified to do so please refrain from it. It can definitely kill you,\nwhich is not a desired outcome for any hobby project.\n\n\n# Problem statement\nPhilips hue lamps are amazing, providing a wonderful solution for home\nlighting. The only problem is that the way they are operated leaves some\nthings to be desired.\n\nWhen the traditional switch is off the lamps of course\ncan not be operated through the app, but only using the app is not realistic\nfor all lights and all conditions. Also people coming over do not have access\nto the app and many people in a house create confusion.\n\nThe current solution is to purchase a separate wireless switch from\nPhilips to use with the lamps but that can get really expensive really quick\nif you want one for each lamp and of course that does not solve the\nproblem of the traditional switches that either will disrupt the usage of\nthe lights or have to be taken out. Not fun.\n\n# Solution\nAll lights can be operated through the api provided by the hue bridge.\nInstead of using the switch to cut the power to the lamp leaving it useless,\nwe rewire the lamp to be constantly powered and the switch to an esp8266-01s\nboard to toggle the lamp through the api. That way our switch works as before\nfor all, toggling the state of the lamp and the lamp continues to be\naccessible through the app all the time. Sweet right?\n\nso we want to go from this initial state:\n\n![alt text](schematics/initial_state.png \"Initial state schematic\")\n\nto this state (schematic depicting an esp01s):\n\n![alt text](schematics/esp8266_01s_schem.png \"esp01s\nschematic\")\n\n# Requirements\n[Enable hue api access to your bridge](https://www.developers.meethue.com/documentation/getting-started)\n\nIf project is based on a wemos D1 mini\n\n* [wemos d1 mini](https://www.aliexpress.com/item/D1-mini-Mini-NodeMcu-4M-bytes-Lua-WIFI-Internet-of-Things-development-board-based-ESP8266-by/32644199530.html)\n\n* [220v to 5v power converter](https://www.aliexpress.com/item/5V-700mA-3-5W-AC-DC-Precision-Buck-Converter-AC-220v-to-5v-DC-step-down/32649591757.html)\n\nIf project is based on an esp8266 01s (Current documentation mentions this case.)\n\n* [esp8266-01s](https://www.aliexpress.com/item/New-Version-ESP8266-ESP-01-ESP01-Serial-Wireless-WIFI-Module-Transceiver-Receiver-Board-for-Internet-of/32799606069.html)\n\n* [220v to 3.3v power converter](https://www.aliexpress.com/item/AC-220-V-to-3-3-V-DC-power-supply-module-transformer-module-is-completely-isolated/32768604824.html)\n\n* 2x 10KΩ Resistance\n\n# Physical Connection\n\nYou can see pictures of the connectivity under the [images](images) directory.\n\n\n# Schematics\n\nImages in png format and a fritzing project for each case can be found under \n[schematics](schematics).\n\n\n# Configuration\n\n Rename configuration_sample.json to configuration.json and edit accordingly.\n If the board used is a wemos D1 mini the pin should be set to gpio3 (D0) \n whereas if the board used is the esp8266-01s the pin should be set to 3 (RX)\n  Everything else should just work out of the box.\n\n# Flashing micropython\n\nTo load this project the microcontroler needs to be running micropython and you\nneed [ampy](https://github.com/adafruit/ampy)\n\nRequired tools:\n\n# esp8266-01s specific\n\nTo flash the esp8266-01s a component to connect it to usb is required.\nRemember that it is 3.3v power and *will* fry with 5v.\n\n* [esp8266-01s programmer](https://www.aliexpress.com/item/ESP01-Programmer-Adapter-UART-GPIO0-ESP-01-Adaptaterr-ESP8266-USB-to-ESP8266-Serial-Wireless-Wifi/32704996344.html)\n\nIn order for the board to be flashed it has to be booted up with d0 pulled\nlow. That means that when the board is booted d0 should be connected to\nground.\n\nThe easiest way to do that is to stick a thin cable in the\nappropriate holes as can be seen [here](images/IMG_20170519_095341.jpg). This\n of course can get pretty old pretty quick if you have a few boards to flash.\n\n\n  A better solution is to add a jumper between ground and d0 as can be seen\n  [here](images/IMG_20170518_141529.jpg) and [here](images/IMG_20170518_165919.jpg)\nand choose the appropriate mode of booting by using the jumper cap or not.\n\nOf course in order for the project to work properly when used the esp8266-01s\n has to be booted with d0 and d1 high, so it does not enter in flash mode.\n\n In order to fix this a 10K pull up resistor has to be connected between d0\n and VCC (3.3v) and between d1 and VCC so the pins are kept high and the \n board boots into running mode even if rebooted.In order to not make the \n board unflashable by permanent pull ups I have installed jumpers on the pull\n  ups so the board can boot into flash but also be able to be programmed. Images\n   of this connection can be found under [images](images) and the final end \n   result with the two pull ups installed is [this](images/IMG_20170522_210237.jpg)\n\n In order for the switch to not interfere with the booting process we are \n using RX (gpio03) as input pulled high through software. That of course will\n  interfere with the serial console so depending on the state of the switch \n  when the board boots you might not have access to the serial console.\n\n\n# common for both wemos d1 mini and esp8266-01s\n   [esptool](https://github.com/espressif/esptool) (Follow installation instructions)\n\n  With the board connected to a usb port of your linux box assuming that the\n  port is ttyUSB0 (check with dmesg after connecting to see what is assigned)\n\n  After the first command you might have to reboot the board, or just\n  disconnect and connect again.\n\n    esptool.py --port /dev/ttyUSB0 erase_flash\n    esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash --flash_size=detect 0 MICROPYTHON_FIRMWARE_FOR_ESP8266.bin\n\n\n  I have had some wemos d1 mini boards having trouble flashing with the above\n  with garbage on the serial and the led staying on. On those boards this\n  command works.\n\n    esptool.py --port /dev/ttyUSB0 write_flash -fm dio -fs 32m 0 MICROPYTHON_FIRMWARE_FOR_ESP8266.bin\n\n\n# Loading the project\n\nRequired tools:\n\n   [ampy](https://github.com/adafruit/ampy) (Follow installation instructions)\n\n    export AMPY_PORT=/dev/ttyUSB0\n    ampy put library\n    ampy put configuration.json\n    ampy put main.py\n    ampy put boot.py\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcostastf%2Fphilips_hue_switch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcostastf%2Fphilips_hue_switch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcostastf%2Fphilips_hue_switch/lists"}