Stop a device if power too low
Posted: Wednesday 09 November 2022 10:03
Hello,
I'm trying to set-up a script that would stop a device if the power consumption is below a minimum level for a few minutes (practically, I want to switch off the smart plug if the devices that are connected to it are in standby mode).
I'm trying to implement this using dzVents but no success as I do have issues extracting the actual power from the device (Zwave plug NAS-WR01Z Power plug 12A+).
Any clue?
Thanks!
I'm trying to set-up a script that would stop a device if the power consumption is below a minimum level for a few minutes (practically, I want to switch off the smart plug if the devices that are connected to it are in standby mode).
I'm trying to implement this using dzVents but no success as I do have issues extracting the actual power from the device (Zwave plug NAS-WR01Z Power plug 12A+).
Any clue?
Thanks!
Code: Select all
return
{
on =
{
devices =
{
'Bureau-kWh Meter',
},
timer = {'Every 10 seconds'},
},
--data =
--{
-- lastupdated-- =
--{
-- initial = 0,
--},
--},
logging =
{
level = domoticz.LOG_DEBUG, --LOG_DEBUG, -- change to domoticz.LOG_ERROR when script is tested and OK
marker = 'Bureau-kWh Meter',
},
execute = function(dz, item)
local Time = require('Time')
local pwr = dz.devices('Bureau-kWh Meter').actualWatt
local lowp
local seuil = 8
local lastupdated = Time
if pwr > seuil then
dz.log('=========================consommation utilisation')
lowp = 0
lastupdated = Time(dz.time)
dz.log('=========================consommation utilisation' .. lastupdated)
-- on s'arrĂȘte lĂ
--return
end
if pwr < seuil then
dz.log('=========================basse consommation')
if lowp == 1 then
lastupdated = Time(dz.time)
lowp = l
dz.log('=========================basse consommation' .. lastupdated)
return
end
end
end
}