Suppose you have a P1 interface connected to your Smart Power Meter in your home and you have written a simple Python script to read it and send messages to the Engine when the average consumption changed in the last minute. You also have a HUE bulb and light strip you use as signal for various event in your home like motion at the front door, time to take your medicine and power consumption of your home.   

This script stored in your system folder of your myhome.homylon package could set the tresholds you want to be noticed about. 

 

// Homylon Scene HomePower


define agent homepower ...
... address 10.10.10.11 port 55196 protocol udp ...
... sensor grid type power

define agent HUE ...                  # the HUE agent announces itself so this is for clarity
... light ball, "bar strip" 

exportHigh = -400                   # production 
importNormal = 400               # consumtion
importHigh = 800 
 
when power grid < exportHigh { 
    light bol, "bar strip" blue brightness 70 
} 
 
// note: we need to register passing the treshold upwards and downwards and then check if it is exactly within that range 


when [power grid < 0] or [power grid > exportHigh] and power grid > exportHigh and power grid < 0 { 
    light bol, "bar strip" green brightness 70 
} 
 
when [power grid > 0] or [power grid < importNormal] and power grid < importNormal and power grid > 0 { 
    light bol, "bar strip" yellow brightness 50 
} 
 
when [power grid > importNormal] or [power grid < importHigh] and power grid < importHigh and power grid > importNormal { 
    light bol, "bar strip" orange brightness 20 
} 
 
when power grid > importHigh { 
    light bol, "bar strip" red brightness 20 
}