- Create a "Device State Changed" type trigger. Select your energy meter device. Select the "Current Load" state. Select "Has Any Change" as the change type.
- Use any conditions you like, but none are necessary for this to work.
- For the Action, select "Execute Script" from the Server Actions. Choose Embedded Python as the script type and enter the following code.
- Code: Select all
# Set the color of the light to represent household energy demand.
# - Deep blue = 0.0 kW
# - Solid green = 5.0 kW
# - Deep red = 10.0 kW
# Change the highUsage value from 10 to whatever you like if 10 kW is too high or too low for you needs.
highUsage = 10.0
hueDev = indigo.devices[<device ID of hue light>] # Enter the device ID from Indigo
energyDev = indigo.devices[<device ID of energy monitor>] # Enter the device ID from Indigo
power = energyDev.states['energyInput1']
saturation = 100 # (percent) Change if you like.
rampRate = 10 # (seconds) Change if you like.
plug = indigo.server.getPlugin('com.nathansheldon.indigoplugin.HueLights')
# Convert the power demand into a hue degree and brightness.
# hue is based on maximum 10 kW load. 260 degrees = no load.
# brightness is based on maximum 10 kW load. 1 = no load.
hue = int(round((highUsage - power) / highUsage * 260.0))
# Make sure the hue doesn't go below 0 or above 260.
if hue < 0:
hue = 0
if hue > 260:
hue = 260
brightness = int(round(power / highUsage * 100.0))
# Prevent the lights from going completely off if power usage is nearly zero.
if brightness == 0:
brightness = 1
# Prevent the brightness value from going over 100%.
if brightness > 100:
brightness = 100
# Only proceed if the Hue Lights plugin is enabled.
if plug.isEnabled():
plug.executeAction("setHSB", hueDev.id, props={'hue':hue, 'saturation':saturation, 'brightness':brightness, 'rate':rampRate})
- Modify the devices and values above to fit your situation. Click the "Compile" button to ensure everything is okay. If so, click OK to save the trigger.
Note that this will change the color settings for your Hue Lights device every time the Current Load value changes, even slightly. You can prevent this by adding a condition in the above code so that the code only executes if the "energyInput1Delta" state of the Energy EAGLE device is greater than, say, 0.1. Alternatively, you can add a condition in the Conditions tab that requires the "Change in Current Load" device state (for the same energy meter device in the code above) is greater than, say, 0.1. This had one disadvantage, though. Because the "Change in Current Load" state is updated just slightly after the "Current Load" state, the trigger checks the "Change in Current Load" state before it can be updated, making this condition unreliable. Including a condition in the Python code above works better because, by the time the Actions are executed, the Change in Current Load state has been updated.