var threshold = 5 var duration = 300 var below_threshold_time = 0 var data = nil var power = 0 while (true) { data := tasmota.cmd('Status 8') :power := data['StatusSNS']['ENERGY']['Power'] } if (power < threshold) { below_threshold_time + 10 if (below_threshold_time >= duration) { tasmota.cmd('Power off') } } else { below_threshold_time = 0 } tasmota.sleep(10) } var threshold = 5 var duration = 300 var below_threshold_time = 0 var data = nil var power = 0 while (true) data := tasmota.cmd('Status 8') power := data['StatusSNS']['ENERGY']['Power'] if (power < threshold) below_threshold_time := below_threshold_time + 10 end if (below_threshold_time >= duration) print('Power off') } else { below_threshold_time = 0 end tasmota.sleep(10) end var threshold = 5 var duration = 300 var below_threshold_time = 0 var data = nil var power = 0 while true data := tasmota.cmd('Status 8') power := data['StatusSNS']['ENERGY']['Power'] if (power < threshold) below_threshold_time := below_threshold_time + 10 if (below_threshold_time >= duration) print('Power off') if (power > threshold) below_threshold_time = 0 tasmota.sleep(10) end