mariusmotea / diyhue Goto Github PK
View Code? Open in Web Editor NEWPhilips Hue emulator that is able to control multiple types of lights
License: Other
Philips Hue emulator that is able to control multiple types of lights
License: Other
Hello,
My project is to control devices normally controlled by a 433 MHz remote with my Logitech Harmony Hub.
I already have a Raspberry Pi with a 433 MHz module and I can successfully control devices via the a Python script. Now, it seems according to my researches that the easiest way to make the Harmony Hub control something via a network API (i.e. not via infrared) would be to emulate a Philips Hue bridge. This is how I arrived here, wanted to build something like this:
Harmony Hub ---(LAN)---> diyHue ---(exec script? API?)---> my 433 MHz Python script
Is this something that could be done with diyHue? Could my Python script be easily controlled by diyHue?
Thank you,
I currently use the pi-blaster library and that seems to work great so far manually. It's basically a file where you write to.
But now I'm trying to merge with my existing Philips Hue lights and my Google Home. So I've setup the bridge and it gets recognised by the app but I'm stuck with how I would need to add the led strip I've connected to my Raspberry Pi GPIO pins. Is there any way to do interface with a simple led strip? The Pi-Blaster library handles most of the conversion (I'm using a modified ikea dioder kit) and basically needs all a pin and a value between 0.0-1.0. How would I go about adding the leds to the project (add it to the bridge)? And could you give me a lead for a template I could build it on and what arguments are passed? Thanks a lot, it's working great so far! I would gladly make a pull request from a new fork where I've added compatibility for pi-blaster.
So i bought the 2meter light strip and an extension of 1 meter.
Installed the software on the PI and downloaded the app to my phone.
I was able to connect to the bridge but after that the app just crashes on my phone.
Am i missing something? Could you possible give a step by step for my setup?
I came across some problems with the Service file.
My Raspberry takes a bit to get a dhcp ip from my router. Meanwhile the service starts and fails at "getIpAddress()". I modified the Service File to try to restart the Service after a fail.
Here my modified version:
Description=Hue Emulator Service
After=multi-user.target
[Service]
Type=idle
Restart=always
RestartSec=30
StartLimitInterval=200
StartLimitBurst=5
WorkingDirectory=/home/pi
ExecStart=/home/pi/HueEmulator.py
[Install]
WantedBy=multi-user.target
It retrys to start the service after a fail 5 times with a delay of 30 seconds each time. Maybe add this to the Wiki?
Hi, there again.
I have made the ESP Mi-light hub for my older milight rgbw bulbs (fut014) and rgbcct led strip controller (fut039).
with the rgbcct led controller the color temperature works in the opposite waywith the hue app as with the rf remote and with the ESP Mi-light web ui.
Hey,
So, I noticed, when sending an "off" signal to the lamp, the dimmed parts of it went completely dark (or sometimes they go on full brighness) for lets say 50ms to 100ms, then go back to normal brightness and fade out like expected.
I use A ESP8266-01 for an RGBW light and mapped the pins like this:
//define pins
uint32 io_info[PWM_CHANNELS][3] = {
// MUX, FUNC, PIN
{PERIPHS_IO_MUX_MTDI_U, FUNC_GPIO12, 1}, //R
{PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13, 0}, //G
{PERIPHS_IO_MUX_MTMS_U, FUNC_GPIO14, 3}, //B
{PERIPHS_IO_MUX_GPIO5_U, FUNC_GPIO5 , 2},//W
};
I guess it may be the soft-PWM? but im not really sure.
Maybe you have an idea what I can do about this (beside waiting for my ESP8266-12 to arrive)
Ah yeah and all other things are working as expected :)
cad435
Maybe not so much an issue, but for what it's worth, the bridge emulator doesn't seem to play well with other networked automation services I have running on my network.
My network includes Home Assistant (home-assistant.io), Hyperion.ng (github.com/hyperion-project/hyperion.ng), and a Philips Hue Bridge 2G.
Home Assistant gets a little finicky and has to be restarted multiple times (at times) to find the real Philips Bridge and the Emulated Bridge. (Also, using automations in Home Assistant, the lights controlled through the Emulated Bridge have a few different reactions than the Hue lights controlled through the Hue Bridge.)
Hyperion.ng often has issues with the Proto server/client communication. (I run 2 Hyperion.ng servers for extra effects across the room. Shortly after starting Hyperion.ng, it usually freezes and throws errors about not being able to communicate via Proto. Once I stopped the Emulated Bridge, I had no issues.
I'm not really expecting you to troubleshoot these or correct them, just sharing my experience.
With all of that said, when it comes to just wanting to use your Emulated Bridge with a couple of strip lights on some D1 mini's and controlling them from the Hue app, it works great! So essentially, it works as is intended in that sense. Nice work!
EDIT: Redacted appears to be a different issue now, unrelated to the emulated bridge, just coincidental timing.
This is not an issue !!
In the Tradfri Wiki part is says: http://{bridgeIP}/tradfri
Which "tradfri" is going to be installed for the intergration with the bridge?
There are many tradfri applications here on github
BR Steen
Today there seems to be an update to the Hue Bridge. When I try to update, it fails. This is the output on the bridge:
192.168.0.33 - - [10/Jun/2017 01:14:00] "POST /updater HTTP/1.1" 200 -
in post method
_----------------------------------------------------------------------------
Exception happened during processing of request from ('192.168.0.33', 39512)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 655, in init
self.handle()
File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
method()
File "HueEmulator.py", line 596, in do_POST
post_dictionary = json.loads(self.data_string)
File "/usr/lib/python2.7/json/init.py", line 338, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
_----------------------------------------------------------------------------
I assume that the script is designed to be updated like a bridge, but how can the update be circumvented? I was not able to find any changelogs online that would indicate the version that I could then use in the json.config...
Edit: I added underscores in front of the rows with dashes as otherwise all of the text is displayed as a Header...
I am very exited about this project, and got it working to some extent (succesfully connected a ESP8266 RGB PWM ledstrip), but I have an issue with linking my existing Hue bridge. When I go to http://[BridgeEmulatorIP]/hue Firefox gives me an error:
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
And Chrome just displays the html code with no functionality. I am running the emulator on a Raspberry pi 1 model B with Raspbian stretch lite.
This is not an issue, i create this topic so the users can write what devices they where able to use with this Hue emulator to specify them in README file. For devices that are not working will be better to have separate issue opened.
Today there was a new release of the official phillips hue app. Sadly it requires to update the bridge otherwise it wont work. If you just updated the app you are just able to control your current setup but not to edit it. If you reinstall the app you are premittet to enter the app because you cannot update the bridge. Can you please make the changes necessary to support the official hue app again?
Thank you in advance
~Tim
P.S. Has someone not updated the app and is able to provide me with the old version off the app? (You could use something like the App ApkExtractor.The version of the old Phillips Hue app should should be 2.15.0)
This is how it looks when i updated the app: (everything exept the controlpage of the rooms is blocked)
And this us how it looks when i do a fresh install of the app: (App is unusable due to unskippable update notification)
Hope you can understand the screenshot even if they are in german.
Does this project support a esp8266 milight hub with the code here
Hi,
When in the HUE app I scan for lights, I get this problem:
192.168.1.114 is a hue bulb
is a new device
192.168.1.114 is unknow device 'modelid'
192.168.1.184 is unknow device HTTP Error 404: Not Found
Do I need to set a model id in the sketch ? If so, where an what ?
Thanks
But it won't do it...
Tried the old app, but cannot connect with esp lights.
Also having trouble with that, The appear directly in my personal Wifi. Can see the settings for on/of and so on, but No SSID is broadcasted.
Hey,
is it possible to speed up the PWM from 5kHz to over 17kHz?
Its absolut fine in visual aspects, but actually i can hear a slight 5kHz tone and thats really annoying...
Every increase in speed is really appreciated even if the resolution will decrease...
Or maybe a define were you can select a speed mode...
Will be very cool!
cad435
Is it possible to make this work with smart things , would like to port my phillips switches over to smart things and this seems like it could be a good option
basically what i want to do is force hue to push an update on button change events
Is there any way to be discoverable by Amazon Echo?
Hello,
I setup a diyHue and a Lightstrip, wich is simply one WS2812B connected to a ESP8266-01.
Works flawless, except the LED is way to bright and if I chose for example 'green' on the color-palette its more like a greenish white type of thing.
I made a picture really close to the lit LED, so as you can see the setting "green" actually lights up the green subpixel, but also the red subpixel is really bright, wich gives a type of yellow/green/white light.
--> Pic: http://fs5.directupload.net/images/170921/zqa5e9bm.jpg
In general most of the colors are very white and washed out.
Any help would be appreciated and since the discussion on Hackaday.io was moved to github i guess this is the right place to adress it.
cad435
Hi i tried to follow your guide and could get the bridge and a WS2812b LED-Stripe working. Works all perfect, great work.
Now i want to head over to build some Bulbs. Im interested in the MiLight bulb but i cant rly follow the instructions u gave. Could you maybe make a step by step guide with some more Pictures? Would be rly helpfull.
THX
Would you be able to help a newbie to set this up? I have a rpi3, Tradfri Gateway and Google Home. If I understand correctly, with this my Google Home should be able to control my Tradfri lights. Correct?
I have python on the pi, but what steps do I need to make to get this code installed?
Sorry for asking the obvious.
I finally got everything set-up, with a neopixel ledstrip and a couple of RGB+CCT Milights. I added the milights as RGB+CCT lamps (which they are, and they function normally outside of the HueEmulator). But when I try to set them to a color, they don't respond. (they seem to be stuck in CCT mode, because that functionallity works well). It's the same in both manual control as when trying scenes.
New Hue application update introduce the function "Timers". Before to add a timer the application check bridge capabilities to be sure it has available resources. After solving this problem the Hue application start to post the data in order to create the timer and at finish it crash. Some sample output from somebody with a real Hue Bridge will help to understand the reason why it crash. I expect a field added by hue bridge is missing on my bridge emulator
is it possible to control the lights using HomAssisntant.io?
if so.. how?
thank you
Hello, finally some long awaited parts have arrived and i made a quick test build of a RGBW strip controller. However the colors dont seem correct at first glance. I found the GPIOs to use in the sketch, but as far as i could see there wasn't any guidance on which color corresponds to which GPIO?
On a related question, are the sketches pre tuned/calibrated? I have another build with a ws2812b strip and it behaves correctly, just that the colors are kinda "dull". I've used the same strip in other builds so i know it can be more intense. If so, any simple way to make the sketch neutral again for testing purposes?
Hi, can someone please help me with the configuration of the Emulator?
At the Moment, the ESP8266 and Emulator is running.
I can connect with the Hue App to the Emulator, but how can i connect the ESP8266+ WS2812 LED with the Emulator(how to configure), that i can see the Light in the Hue App.
Thanks
Christian
Can you change that neopixels are displayed as as an led strip in the lights overview in the app instead of being diplaxed as a generic rgb ligt or add the ability to change the type of light in the script?
I uploaded your "HueSensorStandardLightSwitch" to my ESP8266. Buttons and connection is working. But how to pair the "Hue Tap" to my Philips Hue Bridge? Via iOS App it cannot find my ESP. If I type manually into my browser: "http://192.168.178.19/switch?mac=A0:20:A6:1A:FA:D3&devicetype=ZLLSwitch" -> It shows: "Bad URL in request response"
to link with Google Home it needs to be able to be linked with account.meethue.com/link-bridge which asks me to Push the big button on the middle of your bridge. The one you've always wanted to push. Go on.
Is this possible in any way shape or form or not?
Thanks
(partial continuation of #20)
Hi, First of all, great project! Love it!
I would like to use a ESP module as a diyHue but with just singel output for a mosfet, like a generic SingelColor output but with the option as multiple lights on the same module on different pins.
Specific I would like to connect ESP module to 6 channels output as 6 different emulated lights, as in the neopixel version "light count". Could you guide me or make a version of this?
self)
The last bracket in Line 373 of HueEmulator.py is superfluous and the program throws en error when run so it should be removed.
P.S.: I'm fairly new to github, should I open a Pull request next time I find such a case where there is literally one bracket more than it should be?
can the ESPurna (https://bitbucket.org/xoseperez/espurna) Software be used to control ESP8266 Lights (eg. https://www.itead.cc/sonoff-b1.html) based on this software or using the Sonoff Switches (http://www.exp-tech.de/itead-studio-sonoff-touch-luxury-glass-panel-touch-led-light-switch) with it?
The switches would be really neat to use...
Hi.
Got everything working with the HueEmulator, but experiencing an issue while testing the WS2812B LED-strip. After writing the ino-file to NodeMCU, it does not present "New Hue Light" SSID. I get the typical ESP_xxxxxx SSID which I can connect to, but no http-reply from 192.168.4.1. I get IP in the same subnet and I can also ping 192.168.4.1.
Have tried multiple NodeMCU (different manufacturers), but always the same issue. Also tried different versions of WifiManager (v12, 11 and 10) as I suspected this might be the issue. Using latest version of Arduino IDE.
Any advice is welcome :-)
Or does someone know how to hack it so I can manually input wifi-credentials instead of using WifiManager?
Thanks.
I stumbled across this AiLight Bulb (infos here; http://tinkerman.cat/ailight-hackable-rgbw-light-bulb/)
Its a esp8266 Based Bulb which can be easily flashed. Maybe we can add some sketch for this particular bulb? I wasnt able to find the pins for RGBW yet...
Right now, you aren't in any way documenting what kind of device you're compiling with.
Since ESP8266s are fragile and prone to frying when you give them the wrong compile type, this is actually important information.
If you switch from using the Arduino UI to using PlatformIO, that information will all be included in your repository.
Then other people will be able to build your code too and ALSO, create builds for other kinds of chipsets.
New Hue application update introduce random times for schedules that are not working. These will be fixed in next update
i was following your video and i got stuch with cp huebridge/www/. i dunno how i can install this
Can you provide some basic instructions for installing?
If I reboot my Pi and rerun the python script I get following error:
Exception happened during processing of request from ('192.168.0.33', 44660) Traceback (most recent call last): File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_nobloc k self.process_request(request, client_address) File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request self.finish_request(request, client_address) File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/lib/python2.7/SocketServer.py", line 655, in __init__ self.handle() File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle self.handle_one_request() File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request method() File "/root/diyHue/BridgeEmulator/HueEmulator.py", line 643, in do_POST bridge_config["config"]["whitelist"][username] = {"last use date": datetime. utcnow().strftime("%Y-%m-%dT%H:%M:%S"),"create date": datetime.utcnow().strftime ("%Y-%m-%dT%H:%M:%S"),"name": post_dictionary["devicetype"]} TypeError: 'str' object does not support item assignment
The Hue app then wants me to press the Push-link button on the Hue bridge to authenticate. Would it be possible to have the button press added to the python script or can the issue be resolved otherwise?
I firstly followed the steps of the 'Getting started' page on the GitHub wiki, started the emulator, but then the status says following:
`● hue-emulator.service
Loaded: loaded (/lib/systemd/system/hue-emulator.service; enabled; vendor pre
Active: failed (Result: exit-code) since Sun 2017-10-29 14:27:14 CET; 3min 28
Process: 15617 ExecStart=/home/pi/HueEmulator.py (code=exited, status=203/EXEC
Main PID: 15617 (code=exited, status=203/EXEC)
Oct 29 14:27:14 raspberrypi systemd[1]: Started hue-emulator.service.
Oct 29 14:27:14 raspberrypi systemd[1]: hue-emulator.service: Main process exite
Oct 29 14:27:14 raspberrypi systemd[1]: hue-emulator.service: Unit entered faile
Oct 29 14:27:14 raspberrypi systemd[1]: hue-emulator.service: Failed with result
lines 1-10/10 (END)...skipping...
● hue-emulator.service
Loaded: loaded (/lib/systemd/system/hue-emulator.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2017-10-29 14:27:14 CET; 3min 28s ago
Process: 15617 ExecStart=/home/pi/HueEmulator.py (code=exited, status=203/EXEC)
Main PID: 15617 (code=exited, status=203/EXEC)
Oct 29 14:27:14 raspberrypi systemd[1]: Started hue-emulator.service.
Oct 29 14:27:14 raspberrypi systemd[1]: hue-emulator.service: Main process exited, code=exited, status=203/EXEC
Oct 29 14:27:14 raspberrypi systemd[1]: hue-emulator.service: Unit entered failed state.
Oct 29 14:27:14 raspberrypi systemd[1]: hue-emulator.service: Failed with result 'exit-code'.`
Thanks for your help!
This an ESP8266 four channel relay board.
Here's someone already using it:
https://eryk.io/2015/10/esp8266-based-wifi-rgb-controller-h801/
Would be a good one to add in.
Hello diyHue runs perfect.
But after some minutes i couldn'd get a connection to emulated bridge and the HueEmulator.py stoped with the following error:
.....
192.168.178.63 - - [14/Sep/2017 22:18:03] "GET /api/a7161538be80d40b3de98dece6e91f904dc96170/groups HTTP/1.1" 200 -
192.168.178.63 - - [14/Sep/2017 22:18:05] "GET /api/a7161538be80d40b3de98dece6e91f904dc96170/lights HTTP/1.1" 200 -
192.168.178.63 - - [14/Sep/2017 22:18:06] "GET /api/a7161538be80d40b3de98dece6e91f904dc96170/groups HTTP/1.1" 200 -
packet_write_wait: Connection to 192.168.178.82 port 22: Broken pipe
The start looks like this:
pi@raspy-82:~/diyHue/BridgeEmulator $ sudo ./HueEmulator.py
Config loaded
LightRequest: http://192.168.178.50/api/2ypxD3CNUB4CZUmQ1oJ5Jslj7ChKhmxMbixxn4LH/lights/1/state
update status for light 1
LightRequest: http://192.168.178.33/set?light=1&on=False&bri=144&ct=447
update status for light 2
starting ssdp...
start ssdp broadcast
Starting httpd...
192.168.178.51 - - [15/Sep/2017 08:35:36] "GET /description.xml HTTP/1.1" 200 -
192.168.178.51 - - [15/Sep/2017 08:36:36] "GET /description.xml HTTP/1.1" 200 -
Hi there, does it also support discover of different types of bulbs other than the ESP8266 ones e.g. real HUE bulbs.?
Will it be possible to make a wrapper for interfacing with other kinds - e.g. milight bulbs, IKEA trådfri...?
Hi,
I've been around your project for 3 days now. I've been looking at your youtube videos and this repo and i think i've read all the code produced here. It's a very interesting project, the strategy to proxy the hue bridge is clever and it works pretty straightforward. If I interpret everything about this project right, the idea is that you force the hue app on your phone to connect to your raspberry pi... so... you are reverse engineering the philips hue bridge, and at the same time you are maintaining a rewrite of it.
Based on that assumption :
Aren't you afraid of the consequences whenever Philips brings changing ?
For multi compatilibity, you basically flatten all the other bridges api to the hue api so you can control everything with the hue app. But then, you will also need to maintain all the apis to all the devices to which your code is compatible with. Again, I think there are some concerns about maintaining this codebase, don't you think ?
As you add more and more lines of code, the readability of the code becomes very difficult. I believe it's easy for you because you iterate (very very impressively) fast... But even with my skillset, I'm not capable or even willing to contribute to that project (no offense). I've been spending a night reading at this 1200 lines of python and can't figure out half of it... Are you gonna rewrite/clean the code so others can help you maintain it ?
Last, but not least. The amazon devices (and other voice assistants) relay on uPnP to discover all the bridges of your home, and that's how, when you create groups on your hue app, you can turn them on/off with Alexa. Do you plan on maintaining the uPnP side of the hue bridge as well ?
Thanks for the good work, it looks amazing in my living room.
I just wished i could help.
Sincerely,
Julian
hey,
Fiecan Led Bulb are the cheapest light i found. and i bought few of them.
these lights using the ColorDream app as you mentioned in the readme file.
i have electronic skills i gathered over the past three years. and i would really like you to help me flash these bulbs.
i attached link to the pictures i took of the bulb, i cant find the RX or the TX .
need your help here.
thank you.
Hello, during my setup and attempting to move from an actual Hue Bridge to your emulated bridge, I noticed that the Hue Scenes and Hue Groups are not being reported to Alexa/Echo during Discover Devices.
Expected behavior: Alexa discovers Rooms as a device and Scenes as scenes in the Alexa app after Disabling/Re-enabling the Hue Skill. This is how the Hue Bridge behaves.
Current behavior: Only individual lights are reported to Alexa as devices.
Will be nice if somebody can create 3D projects to have these devices that will look like original ones.
Hue Dimmer switch need to be like original dimmer switch (i guess ESP-12S + 1x coil battery will fit the case)
Hue Motions Sensor size need to accept one HC-SR501 sensor, two AAA batteries and one ESP-12S device. Soon i will push a new update to Hue Motion project that will fix rf interferences with PIR.
Hi,
I have got your diyHue emulator working fine with the official phillips hue apps together with a wemos d1 mini and a neopixel ring. Thanks a lot!
I also have a Quby (dutch Toon Eneco) which serves as a thermostat, zwave and Hue controller but it simply could'nt find the Hue bridge emulator. It seems that the Toon listens to others broadcasts then your simulator does.
It would be great to have your simulator working with the Toon. I have found some info over here: https://github.com/ewjmulder/hue-bridge-simulator/issues and especially here: https://raw.githubusercontent.com/ewjmulder/program-your-home/master/eneco-toon/IDEAS.txt which explains the broadcast of this emulator.
I am not a dev but i certainly would love to help with testing if you would have a dive in this.
regards kurniawan77
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.