2021-03-13 21:42:24 +00:00
|
|
|
#-
|
|
|
|
# example of using Berry script to change the led color
|
|
|
|
# accordingly to power consumption
|
|
|
|
# using Denky (French Teleinfo reader)
|
|
|
|
-#
|
|
|
|
|
|
|
|
#- define the global symbol for reference -#
|
|
|
|
runcolor = nil
|
|
|
|
|
|
|
|
def runcolor()
|
|
|
|
var pwr = energy.read().find('activepower',0)
|
|
|
|
print(pwr)
|
2021-03-20 17:44:35 +00:00
|
|
|
var red = tasmota.scale_uint(int(pwr), 0, 2500, 0, 255)
|
2021-03-13 21:42:24 +00:00
|
|
|
var green = 255 - red
|
|
|
|
var channels = [red, green, 0]
|
2021-06-12 11:48:00 +01:00
|
|
|
light.set({"channels":channels, "bri":64, "power":true})
|
2021-03-20 17:44:35 +00:00
|
|
|
tasmota.set_timer(2000, runcolor)
|
2021-03-13 21:42:24 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
#- run animation -#
|
|
|
|
runcolor()
|