You may have noticed that after you switch your Hue lights outside Domoticz the status of your Hue lights can be incorrect. This may cause scripts or Blockly events to malfunction. Or more accurately said: you scripts work just fine, but they are not getting the correct inputs from Domoticz. The purpose of this script is to eliminate these problems. The concept of the script is that it will loop through your Hue lights (1, 2, 3, etc) until no more lights are found. It gets both the name and status of each light and corrects Domoticz when needed. All the script does is correct the on/off status. It does nothing with (for instance) dim-level or colors. If you need more advanced functions look here[1].
If you scroll down to the bottom, a version without dependencies is available. To use the older versions of the script you'll need to install socket library [2] and dkjson [3]. Both need to end up in /usr/local/lib/lua/5.2 (path is for Synology NAS, it may be different on RPI). You need to be able to access your bridge using the HUE api. More information on Philips HUE api and how to get/change your username can be found here [4].
Another thing is that the name of each light must be the same in your bridge and Domoticz. The script is very simple: it gets the name of each light from your bridge and then sends the status to Domoticz using the exact same name. So if the names differ between the two then the script will not work. You can check the names of your lights using the Hue app. I saved it in my scripts folder as "script_time_checkLights.lua". Time based scripts are executed every minute. More information on the event system can be found here [5]. To configure the script all you have to do is enter the IP of your HUE bridge and your HUE username.
Update Script Fix if you remove a broken bulb this script will stop there... not updating the lamps after the broken bulb. Change until(stop) into until(i > 25) where 25 is the highest number of lamps found in your Philips HUE app, this will quick fix it...
Update: dzVents version based on the version of m. hagenaars this version uses dzvents and also takes unreachable lights into account (assuming those are off). The script will wait until the light has a unreachable state for 5 minutes before switching them off since I would ran into issues doing this directly.
Update: dzVents version Updated version based on the above scripts without the need for adding the libraries (part of dzVents; forum link: [[6]]) to update on/off status. Script for lights as well as groups available below:
Lights:
Groups:
En example of an expanded script can be found Here It add's virtual power and energy meters for HUE and expand/fix the update script.