Shelly script to turn off device on standby

I wrote a small script for a Shelly Plug S Gen 3 to turn off a device 1 when its power consumption is lower then a threshold for a specific amount of time. let threshold = 18 ; /* watts */ let duration = 1 * 60 * 60 ; /* seconds */ let belowThresholdSince = null ; print ( JSON . stringify ( Shelly . getDeviceInfo ())); Shelly . call ( 'Switch.GetStatus' , { id : 0 }, function ( res ) { print (…