21.10.2024, 10:22
Hello.
Here is the resident script, which will be executed every minute
Here is the resident script, which will be executed every minute
Code:
if not minute_counter then
minute_counter = 0
end
plug_status = grp.getvalue('plug_status') -- the object of plug status
power_consumption = grp.getvalue('power_consumption') -- the object of power in watts
log(minute_counter)
--log(plug_status)
--log(power_consumption)
if plug_status and power_consumption < 10 then
minute_counter = minute_counter + 1
else
minute_counter = 0
end
if minute_counter > 59 then -- one hour passed
grp.write('plug_control', false) -- turn off plug (plug control object)
minute_counter = 0
end