New Driver API v5 in EVA ICS 3.2.2 brings important improvement: now Physical Interface modules can support extended unit state (status + value). To test and demonstrate this feature, we’ve made PHIs for 2 popular LED controllers: Philips HUE and Nanoleaf. Everyone likes playing with LEDs, even industrial guys )
Both PHIs can be found at EVA ICS website and downloaded to Universal Controller instance.
# for Nanoleaf eva uc phi download https://get.eva-ics.com/phi/lights/nanoleaf.py # for Philips HUE eva uc phi download https://get.eva-ics.com/phi/lights/philips_hue_leds.py
Before loading PHIs, we need to know IPs of Philips HUE bridge and Nanoleaf and create authentication tokens on the equipment (“user” on HUE bridge).
IPs can be found on your DHCP server, tokens can be created by modules automatically: for HUE you must press “connect” button and load PHI module within 30 seconds, for Nanoleaf: press power button for about 7 seconds. So, press and continue:
eva uc phi load nano1 nanoleaf -c host=IP_OF_YOUR_NANOLEAF -y eva uc phi load hue1 philips_hue_leds -c host=IP_OF_YOUR_HUE_BRIDGE -y
Both PHIs have very similar features:
- they translate EVA ICS commands to the installed hardware
- unit status = unit on (1) or off (0)
- unit value = RGB hex color (e.g. #FFFFFF or just FFFFFF), which’s automatically converted to XYZ or HSV
- when PHI is unloaded, it tries to delete its authentication token from the equipment.
We’ve used XYZ color scheme in Philips HUE PHI to be compatible with their smartphone app. Unfortunately backward conversion to RGB has some limitations, so the module supports only “status” updates.
As Philips HUE bridge can control each LED independently, “-c port=X” option must be specified for “driver assign” command (default LPI: basic). Nanoleaf doesn’t support ports, so no assign configuration options are required (default LPI: usp).
Nanoleaf PHI uses HSV which has better backward conversion however as Nanoleaf works only with integer values for hue, saturation and brightness, unit updates may shift value a little bit.
If Nanoleaf module can not convert specified value from hex to RGB, it will try to start an effect, so unit values “Color Burst”, “Forest”, “Flames” (and all other available) are possible.
Additionally, Philips HUE module supports “exec scan” and “exec delete” commands to ask HUE bridge find new LEDs or delete removed.
Let’s continue with Nanoleaf, create new unit and assign driver to it:
eva uc create unit:lights/amb1 -y eva uc action enable unit:lights/amb1 eva uc driver assign unit:lights/amb1 nano1.default -y # let unit update its state from the hardware every 10 seconds eva uc config set unit:lights/amb1 update_interval 10 -y # recommended - sometimes SOHO units forget their state # and the same status/value need to be reapplied again eva uc config set unit:lights/amb1 action_always_exec 1 -y
The unit is configured. Let’s test it with a couple of actions:
# toggle on/off eva uc action toggle unit:lights/amb1 -w 5 # red light eva uc action exec unit:lights/amb1 1 -v '#ff0000' -w 5 # dark blue eva uc action exec unit:lights/amb1 1 -v '#000044' -w 5 # color burst eva uc action exec unit:light/amb1 1 -v 'Color Burst' -w 5
It works! Now let’s make a simple “SCADA” interface ). To make it cool, we will need some color picker, e.g. iro.js. Put “iro.min.js” to ui/ folder and continue.
Here’s interface demo. Actually I’ve played with Philips HUE on this video:
So as you see, controlling LED colors is not a rocket science. With EVA ICS you can easily integrate fabulous Philips HUE and Nanoleaf to your home or enterprise unified setup and let them change colors on any events or just to your mood.