Logic Machine Forum
Auto OFF function - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Auto OFF function (/showthread.php?tid=5690)



Auto OFF function - eurosting - 21.10.2024

Hello All,
I'm searching for a small script, which switches off a power plug if device in stanby mode for a long time.
For example I'm using MDT AMS16.12 with power measuring function. The TV is connected to the power plug, which is controlled by AMS1216 device.
So after watching TV I forget sometimes to disable the plug. 
I looking for a script like: 
if TV power plug status =1, but power consumption < 10W for 1 hour, 
then disable the plug.

Tried to use FBD editor of WISER, but without succes. Please 
advise.


RE: Auto OFF function - RomansP - 21.10.2024

Hello.

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



RE: Auto OFF function - eurosting - 21.10.2024

Thanks a lot, your script is working perfect!