Tasmota/tasmota/berry/examples/denky.be

22 lines
528 B
Plaintext
Raw Normal View History

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-03-20 17:44:35 +00:00
tasmota.set_light({"channels":channels, "bri":64, "power":true})
tasmota.set_timer(2000, runcolor)
2021-03-13 21:42:24 +00:00
end
#- run animation -#
runcolor()