Re: Is the washing machine done?
Posted: Friday 27 September 2019 8:24
I will look into it and let you know after a while.
Code: Select all
local StatusWasmachine
domoticz.StatusWasmachine.updateText('wasmachine is klaar')
Change the lines tojaaap wrote: ↑Sunday 29 September 2019 14:57 I have been struggling to get a text sensor to be updated with the information on the status of the washmachine. I know many of you have a notification set up, but I would like to have a switch or text sensor to be updated. That way, anyone looking at the dashboard can see the wash is done (and hopefully, people will put it in the dryer voluntarily![]()
Code: Select all
local StatusWasmachine = domoticz.devices('name of your text sensor')
StatusWasmachine.updateText('wasmachine is klaar')
Code: Select all
2019-09-30 00:04:26.606 Status: dzVents: Error (2.4.19): .../scripts/dzVents/generated_scripts/is de was klaar 2.lua:25: attempt to call field 'devices' (a nil value)
Code: Select all
-- create a lookup table that matches a usage
-- device to the accompanying switch
local USAGE_DEVICES = {
-- ['SC-Wasdroger verbruik'] = 'Wasdroger', -- You need to have a inline wall plug that measures energy,
['SC-Wasmachine verbruik'] = 'Wasmachine', -- here you make the link between the energy device and the wall plug.
}
local USAGE_SwitchTimeOutMinutes = {
-- ['Wasdroger'] = 6, -- Here you define how long no power is used per device.
['Wasmachine'] = 6, -- The period is in minutes. Adjust to your needs. Between every add a ",".
}
local USAGE_MaxWatt = {
-- ['Wasdroger'] = 3, -- Here you define the maximum amount of power a device uses when it is in standby.
['Wasmachine'] = 1, -- Some devices uses a little amount of power. Test it and a slightly higher usage.
}
local USAGE_Notify = {
-- ['Wasdroger'] = 'Yes', -- In some cases you want to be notified when a device is turned on and off.
['Wasmachine'] = 'Yes', -- Adjust to your needs. Between every line you need to add a ",".
}
local StatusWasmachine = domoticz.devices('Status wasmachine')
return {
logging = {
level = domoticz.LOG_INFO, -- Uncomment to override the dzVents global logging setting
marker = 'POW'
},
on = {
timer = { 'every 5 minutes' },
devices = { -- Make sure that the devices are the same as above
-- 'SC-Wasdroger verbruik',
'SC-Wasmachine verbruik',
},
},
data = { -- use exact device names to match USAGE_DEVICES
-- ['SC-Wasdroger verbruik'] = { history = true, maxMinutes = 10 },
['SC-Wasmachine verbruik'] = { history = true, maxMinutes = 10 } --deze weer op 10 zetten straks
},
execute = function(domoticz, device)
if (device.isTimer) then
-- we need to check for expiration of grace period
domoticz.log("timer trigger")
for i, machine in pairs(USAGE_DEVICES) do
local usage = "SC-" .. machine.. " verbruik"
domoticz.log("device = " .. machine)
local actual = domoticz.devices(usage).WhActual
local average = domoticz.data[usage].avg()
domoticz.data[usage].add(actual)
domoticz.log("actual = " .. actual)
domoticz.log("average = " .. tostring(average))
if actual == 0 then
domoticz.log(machine .. " gebruikt geen energie, dus is uit")
domoticz.devices(machine).switchOff().checkFirst()
StatusWasmachine.updateText('wasmachine is uit')
elseif actual < USAGE_MaxWatt[machine] then
domoticz.log(machine .. " gebruikt weinig energie, is de machine klaar?")
StatusWasmachine.updateText('Wasmachine is klaar')
local timeout = USAGE_SwitchTimeOutMinutes[machine]
domoticz.log(machine .. " gebruikte gemiddeld: " .. tostring(domoticz.data[usage].avg))
if (average <= USAGE_MaxWatt[machine]) then
domoticz.log(machine .. " lijkt standby te staan, we nemen aan klaar.")
domoticz.devices(machine).switchOff().checkFirst()
domoticz.data[usage].reset()
else
domoticz.log(machine .. " maar nog te kort om klaar te zijn.")
domoticz.devices(machine).switchOn().checkFirst()
end
else
domoticz.log(machine .. " gebruikt energie, dus is (nog) bezig.")
domoticz.devices(machine).switchOn().checkFirst()
end
end
elseif (USAGE_DEVICES[device.name] ~= nil) then
-- we have a usage sensor here
domoticz.log("usage trigger")
local switch = domoticz.devices(USAGE_DEVICES[device.name])
local timeout = USAGE_SwitchTimeOutMinutes[USAGE_DEVICES[device.name]]
local watt = USAGE_MaxWatt[USAGE_DEVICES[device.name]]
domoticz.data[device.name].add(device.WhActual)
local history = domoticz.data[device.name]
domoticz.log("device = " .. device.name)
if (switch.active) then
domoticz.log("Switch is active, check average use and last update")
domoticz.log("usage last update: " .. tostring(switch.lastUpdate.minutesAgo))
domoticz.log("usage = " .. tostring(device.WhActual))
domoticz.log("average = " .. tostring(history.avg()))
if (history.avg() <= watt and device.WhActual <= watt and switch.lastUpdate.minutesAgo >= timeout) then
switch.switchOff().checkFirst()
domoticz.log("Turn switch off")
domoticz.data[device.name].reset()
end
else
domoticz.log("Switch not on")
if (device.WhActual > watt) then
domoticz.log("but power use is over treshold, turn switch on")
switch.switchOn().checkFirst()
end
end
end
end
}
I understand that it is bit confusing in this script. That's why I am not a big fan of declaring a lot of variables before the "execute =" blockjaaap wrote: ↑Monday 30 September 2019 0:06 Thank you for your suggestion. However, I keep getting the same respons in the log:Code: Select all
2019-09-30 00:04:26.606 Status: dzVents: Error (2.4.19): .../scripts/dzVents/generated_scripts/is de was klaar 2.lua:25: attempt to call field 'devices' (a nil value)
Code: Select all
2020-05-14 10:21:58.229 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler is de was klaar
2020-05-14 10:21:58.229 Error: dzVents: Error: (3.0.2) ...cz/scripts/dzVents/generated_scripts/is de was klaar.lua:103: attempt to compare number with nil
Code: Select all
-- create a lookup table that matches a usage
-- device to the accompanying switch
local USAGE_DEVICES = {
-- ['SC-Wasdroger verbruik'] = 'Wasdroger', -- You need to have a inline wall plug that measures energy,
['SC-Wasmachine verbruik'] = 'Wasmachine', -- here you make the link between the energy device and the wall plug.
}
local USAGE_SwitchTimeOutMinutes = {
-- ['Wasdroger'] = 6, -- Here you define how long no power is used per device.
['Wasmachine'] = 6, -- The period is in minutes. Adjust to your needs. Between every add a ",".
}
local USAGE_MaxWatt = {
-- ['Wasdroger'] = 3, -- Here you define the maximum amount of power a device uses when it is in standby.
['Wasmachine'] = 3, -- Some devices uses a little amount of power. Test it and a slightly higher usage.
}
local USAGE_Notify = {
-- ['Wasdroger'] = 'Yes', -- In some cases you want to be notified when a device is turned on and off.
['Wasmachine'] = 'Yes', -- Adjust to your needs. Between every line you need to add a ",".
}
return {
-- logging = {
-- level = domoticz.LOG_INFO, -- Uncomment to override the dzVents global logging setting
-- marker = 'POW'
-- },
on = {
timer = { 'every 5 minutes' },
devices = { -- Make sure that the devices are the same as above
-- 'SC-Wasdroger verbruik',
'SC-Wasmachine verbruik',
},
},
data = { -- use exact device names to match USAGE_DEVICES
-- ['SC-Wasdroger verbruik'] = { history = true, maxMinutes = 10 },
['SC-Wasmachine verbruik'] = { history = true, maxMinutes = 10 } --deze weer op 10 zetten straks
},
execute = function(domoticz, device)
if (device.isTimer) then
-- we need to check for expiration of grace period
domoticz.log("timer trigger")
for i, machine in pairs(USAGE_DEVICES) do
local usage = "SC-" .. machine.. " verbruik"
domoticz.log("device = " .. machine)
local actual = domoticz.devices(usage).WhActual
local average = domoticz.data[usage].avg()
domoticz.data[usage].add(actual)
domoticz.log("actual = " .. actual)
domoticz.log("average = " .. tostring(average))
local StatusWasmachine = domoticz.devices('Status wasmachine')
if actual == 0 then
domoticz.log(machine .. " gebruikt geen energie, dus is uit")
StatusWasmachine.updateText('wasmachine is uit')
domoticz.devices(machine).switchOff().checkFirst()
elseif actual < USAGE_MaxWatt[machine] then
domoticz.log(machine .. " gebruikt weinig energie, is de machine klaar?")
local timeout = USAGE_SwitchTimeOutMinutes[machine]
domoticz.log(machine .. " gebruikte gemiddeld: " .. tostring(domoticz.data[usage].avg))
if (average <= USAGE_MaxWatt[machine]) then
domoticz.log(machine .. " lijkt standby te staan, we nemen aan klaar.")
StatusWasmachine.updateText('Wasmachine is klaar')
domoticz.devices(machine).switchOff().checkFirst()
domoticz.devices('was ophangen').switchOn()
domoticz.data[usage].reset()
else
domoticz.log(machine .. " maar nog te kort om klaar te zijn.")
StatusWasmachine.updateText('Wasmachine is bijna klaar')
domoticz.devices(machine).switchOn().checkFirst()
end
else
domoticz.log(machine .. " gebruikt energie, dus is (nog) bezig.")
StatusWasmachine.updateText('Wasmachine draait')
domoticz.devices(machine).switchOn().checkFirst()
end
end
elseif (USAGE_DEVICES[device.name] ~= nil) then
-- we have a usage sensor here
domoticz.log("usage trigger")
local switch = domoticz.devices(USAGE_DEVICES[device.name])
local timeout = USAGE_SwitchTimeOutMinutes[USAGE_DEVICES[device.name]]
local watt = USAGE_MaxWatt[USAGE_DEVICES[device.name]]
domoticz.data[device.name].add(device.WhActual)
local history = domoticz.data[device.name]
domoticz.log("device = " .. device.name)
if (switch.active) then
domoticz.log("Switch is active, check average use and last update")
domoticz.log("usage last update: " .. tostring(switch.lastUpdate.minutesAgo))
domoticz.log("usage = " .. tostring(device.WhActual))
domoticz.log("average = " .. tostring(history.avg()))
if (history.avg() <= watt and device.WhActual <= watt and switch.lastUpdate.minutesAgo >= timeout) then
switch.switchOff().checkFirst()
domoticz.log("Turn switch off")
domoticz.data[device.name].reset()
end
else
domoticz.log("Switch not on")
if (device.WhActual > watt) then
domoticz.log("but power use is over treshold, turn switch on")
switch.switchOn().checkFirst()
end
end
end
end
}
I don't see an obvious error so best to add some loglines.jaaap wrote: ↑Thursday 14 May 2020 10:23 Hi all,
I've reinstalled domoticz on a raspberry pi (first install was on synology nas). I've imported the database from the NAS to the raspberry pi. All went well, except for a simpel script that is now giving the error:
Code: Select all
2020-05-14 10:21:58.229 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler is de was klaar 2020-05-14 10:21:58.229 Error: dzVents: Error: (3.0.2) ...cz/scripts/dzVents/generated_scripts/is de was klaar.lua:103: attempt to compare number with nil
Code: Select all
domoticz.log(device.name .. ', actual Watt = ' .. tostring(device.WhActual),domoticz.LOG_FORCE )
domoticz.log('Defined max watt ' .. tostring(watt),domoticz.LOG_FORCE )
Code: Select all
2020-05-14 14:08:02.629 Status: dzVents: Info: Handling events for: "SC-Wasmachine verbruik", value: "0.345"
2020-05-14 14:08:02.629 Status: dzVents: Info: ------ Start internal script: is de was klaar: Device: "SC-Wasmachine verbruik (hs110)", Index: 113
2020-05-14 14:08:02.630 Status: dzVents: Info: usage trigger
2020-05-14 14:08:02.632 Status: dzVents: Info: device = SC-Wasmachine verbruik
2020-05-14 14:08:02.632 Status: dzVents: Info: Switch not on
2020-05-14 14:08:02.632 Status: dzVents: !Info: SC-Wasmachine verbruik, actual Watt = nil
2020-05-14 14:08:02.632 Status: dzVents: !Info: Defined max watt 3
2020-05-14 14:08:02.632 Status: dzVents: Info: ------ Finished is de was klaar
2020-05-14 14:08:02.632 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler is de was klaar
2020-05-14 14:08:02.632 Error: dzVents: Error: (3.0.2) ...cz/scripts/dzVents/generated_scripts/is de was klaar.lua:105: attempt to compare number with nil
Code: Select all
cd /home/pi/domoticz/plugins/domoticz-tplink-smartplug
vi plugin.py
Code: Select all
Domoticz.Device(Name="emeter power (W)", Unit=4, Type=243, Subtype=29).Create() # Subtype 29 is kWh
Code: Select all
:wq
Before you got that path you could also try after changing
Code: Select all
device.WhActual
Code: Select all
tonumber(device.sValue)
In the first block you also declare the 'timeout' but you are not using it and do log2020-08-20 08:00:00.843 Status: dzVents: Info: timer trigger
2020-08-20 08:00:00.843 Status: dzVents: Info: device = Wasdroger
2020-08-20 08:00:00.857 Status: dzVents: Info: actual = 0.0
2020-08-20 08:00:00.857 Status: dzVents: Info: average = 0.0
2020-08-20 08:00:00.857 Status: dzVents: Info: Wasdroger gebruikt geen energie, dus is uit
2020-08-20 08:00:00.859 Status: dzVents: Info: device = Wasmachine
2020-08-20 08:00:00.860 Status: dzVents: Info: actual = 0.3
2020-08-20 08:00:00.860 Status: dzVents: Info: average = 0.34705882352941
2020-08-20 08:00:00.860 Status: dzVents: Info: Wasmachine gebruikt weinig energie, is de machine klaar?
2020-08-20 08:00:00.860 Status: dzVents: Info: Wasmachine gebruikte gemiddeld: function: 0xffff50064990
2020-08-20 08:00:00.860 Status: dzVents: Info: Wasmachine lijkt standby te staan, we nemen aan klaar.
Code: Select all
-- Is the washing macgine done? Version 2.0
-- create a lookup table that matches a usage
-- device to the accompanying switch
local USAGE_DEVICES = {
['SC-Wasdroger gebruik'] = 'Wasdroger', -- You need to have a inline wall plug that measures energy,
['SC-Wasmachine gebruik'] = 'Wasmachine', -- here you make the link between the energy device and the wall plug.
}
local USAGE_TimeOut = {
['Wasdroger'] = 6, -- Here you define how long no power is used per device.
['Wasmachine'] = 6, -- The period is in minutes. Adjust to your needs. Between every add a ",".
}
local USAGE_MaxWatt = {
['Wasdroger'] = 3, -- Here you define the maximum amount of power a device uses when it is in standby.
['Wasmachine'] = 3, -- Some devices uses a little amount of power. Test it and a slightly higher usage.
}
return {
logging = {
level = domoticz.LOG_INFO, -- Uncomment to override the dzVents global logging setting
marker = 'POW'
},
on = {
timer = { 'every 5 minutes' },
devices = { -- Make sure that the devices are the same as above
'SC-Wasdroger gebruik',
'SC-Wasmachine gebruik',
},
},
data = { -- use exact device names to match USAGE_DEVICES
['CountDevices'] = {initial=0},
['SC-Wasdroger gebruik'] = { history = true, maxMinutes = 10 },
['SC-Wasmachine gebruik'] = { history = true, maxMinutes = 10 },
},
execute = function(domoticz, device)
function status(machine)
local usage = "SC-" .. machine.. " gebruik" -- name of physical power measuring device
local standby = USAGE_MaxWatt[machine] -- threshold for standby
local timeout = USAGE_TimeOut[machine] -- amount of time the power consumption needs to be constant
local switch = domoticz.devices(machine) -- the actual virtual switch that shows the status of the device
local power_actual = domoticz.devices(usage).WhActual -- the actual power consumption of the device
local power_average = domoticz.data[usage].avg() -- the average power consumption in the last 10 minutes
local minutes = domoticz.devices(usage).lastUpdate.minutesAgo -- the # minutes the power consumption is unchanjged
domoticz.log("device : " .. machine .. ', power: ' .. usage)
domoticz.log('gebruik : ' .. power_actual .. ', treshold: ' .. standby)
domoticz.log('gemiddeld: ' .. power_average)
domoticz.log('sinds : ' .. minutes .. ', standby: ' .. timeout)
domoticz.data[usage].add(power_actual)
if (switch.active) then
if power_actual > standby then -- Device is already on
return('Already on')
end
if (power_actual == 0) or (power_actual <= standby and
(power_average <= standby) or minutes > standby) then
switch.switchOff() -- Device is off or on standby
domoticz.data[usage].reset() -- Reset history
return('Off')
end
return('Idle')
end
if power_actual > standby then -- Device is active
switch.switchOn() -- Turn the virtual switch on
if domoticz.data['CountDevices'] == 0 then
domoticz.data['CountDevices'] = 1 -- Keep track off active devices
end
return('Switching On')
end
if power_average > 0 then -- Switch is off but average needs to be reset
domoticz.data[usage].reset() -- Reset history
end
return('Off') -- Device is off
end
if (device.isTimer) then -- Then its a regular check
domoticz.log("Monitoring " .. tostring(domoticz.data['CountDevices']) .. " apparaten.")
if (domoticz.data['CountDevices'] > 0) then -- When one or more devices are on
domoticz.log("Monitoring " .. tostring(domoticz.data['CountDevices']) .. " apparaten.")
domoticz.data['CountDevices'] = 0 -- Reset count
for i, machine in pairs(USAGE_DEVICES) do -- Loop thru all the devices
checked = status(machine) -- Check the status of each device
domoticz.log('status: '..checked) -- Check the status of each device
if checked ~= 'Off' then
domoticz.data['CountDevices'] = domoticz.data['CountDevices'] + 1 -- Keep track off active devices
end
end
end
elseif (USAGE_DEVICES[device.name] ~= nil) then -- Then one device has a changed power consumption
domoticz.log('status: '..status(USAGE_DEVICES[device.name])) -- Check the status of this one device
end
end
}
Code: Select all
1154 Ribes 0009301 2 SC-Wasmachine gebruik Usage Electric 0 Watt - - 2020-12-05 16:40:05
Code: Select all
164 ZWave USB 0011401 2 SC-Wasmachine verbruik Usage Electric 17.8 Watt - - 2020-12-06 10:05:39
Code: Select all
2021-01-13 09:25:18.989 Status: dzVents: Info: POW: ------ Start internal script: Wasmachine Droger status: Device: "Garage Wasmachine Verbruik (Zigbee )", Index: 2582
2021-01-13 09:25:18.992 Status: dzVents: Info: POW: device : Garage Wasmachine, power: Garage Wasmachine Verbruik
2021-01-13 09:25:18.993 Status: dzVents: Info: POW: gebruik : 66.0, treshold: 3
2021-01-13 09:25:18.993 Status: dzVents: Info: POW: gemiddeld: 33.0
2021-01-13 09:25:18.993 Status: dzVents: Info: POW: sinds : 0, standby: 6
2021-01-13 09:25:18.993 Status: dzVents: Info: POW: status: Already on
2021-01-13 09:25:18.994 Status: dzVents: Info: POW: ------ Finished Wasmachine Droger status
2021-01-13 09:25:19.176 Status: dzVents: Info: POW: ------ Start internal script: Wasmachine Droger status: Device: "Garage Wasmachine Verbruik (Zigbee )", Index: 2582
2021-01-13 09:25:19.179 Status: dzVents: Info: POW: device : Garage Wasmachine, power: Garage Wasmachine Verbruik
2021-01-13 09:25:19.180 Status: dzVents: Info: POW: gebruik : 66.0, treshold: 3
2021-01-13 09:25:19.180 Status: dzVents: Info: POW: gemiddeld: 37.714285714286
2021-01-13 09:25:19.180 Status: dzVents: Info: POW: sinds : 0, standby: 6
2021-01-13 09:25:19.180 Status: dzVents: Info: POW: status: Already on
2021-01-13 09:25:19.181 Status: dzVents: Info: POW: ------ Finished Wasmachine Droger status
2021-01-13 09:25:34.006 Status: dzVents: Info: POW: ------ Start internal script: Wasmachine Droger status: Device: "Garage Wasmachine Verbruik (Zigbee )", Index: 2582
2021-01-13 09:25:34.013 Status: dzVents: Info: POW: device : Garage Wasmachine, power: Garage Wasmachine Verbruik
2021-01-13 09:25:34.013 Status: dzVents: Info: POW: gebruik : 0.0, treshold: 3
2021-01-13 09:25:34.013 Status: dzVents: Info: POW: gemiddeld: 41.25
2021-01-13 09:25:34.013 Status: dzVents: Info: POW: sinds : 0, standby: 6
2021-01-13 09:25:34.014 Status: dzVents: Info: POW: status: Off
2021-01-13 09:25:34.015 Status: dzVents: Info: POW: ------ Finished Wasmachine Droger status
Code: Select all
-- Is the washing macgine done? Version 2.0
-- create a lookup table that matches a usage
-- device to the accompanying switch
local USAGE_DEVICES = {
['Garage Droger Verbruik'] = 'Garage Droger', -- You need to have a inline wall plug that measures energy,
['Garage Wasmachine Verbruik'] = 'Garage Wasmachine', -- here you make the link between the energy device and the wall plug.
}
local USAGE_TimeOut = {
['Garage Droger'] = 6, -- Here you define how long no power is used per device.
['Garage Wasmachine'] = 6, -- The period is in minutes. Adjust to your needs. Between every add a ",".
}
local USAGE_MaxWatt = {
['Garage Droger'] = 3, -- Here you define the maximum amount of power a device uses when it is in standby.
['Garage Wasmachine'] = 3, -- Some devices uses a little amount of power. Test it and a slightly higher usage.
}
return {
logging = {
level = domoticz.LOG_INFO, -- Uncomment to override the dzVents global logging setting
marker = 'POW'
},
on = {
timer = { 'every 5 minutes' },
devices = { -- Make sure that the devices are the same as above
'Garage Droger Verbruik',
'Garage Wasmachine Verbruik',
},
},
data = { -- use exact device names to match USAGE_DEVICES
['CountDevices'] = {initial=0},
['Garage Droger Verbruik'] = { history = true, maxMinutes = 10 },
['Garage Wasmachine Verbruik'] = { history = true, maxMinutes = 10 },
},
execute = function(domoticz, device)
function status(machine)
local usage = machine.. " Verbruik" -- name of physical power measuring device
local standby = USAGE_MaxWatt[machine] -- threshold for standby
local timeout = USAGE_TimeOut[machine] -- amount of time the power consumption needs to be constant
local switch = domoticz.devices(machine) -- the actual virtual switch that shows the status of the device
local power_actual = domoticz.devices(usage).WhActual -- the actual power consumption of the device
local power_average = domoticz.data[usage].avg() -- the average power consumption in the last 10 minutes
local minutes = domoticz.devices(usage).lastUpdate.minutesAgo -- the # minutes the power consumption is unchanjged
domoticz.log("device : " .. machine .. ', power: ' .. usage)
domoticz.log('gebruik : ' .. power_actual .. ', treshold: ' .. standby)
domoticz.log('gemiddeld: ' .. power_average)
domoticz.log('sinds : ' .. minutes .. ', standby: ' .. timeout)
domoticz.data[usage].add(power_actual)
if (switch.active) then
if power_actual > standby then -- Device is already on
return('Already on')
end
if (power_actual == 0) or (power_actual <= standby and
(power_average <= standby) or minutes > standby) then
switch.switchOff() -- Device is off or on standby
domoticz.data[usage].reset() -- Reset history
return('Off')
end
return('Idle')
end
if power_actual > standby then -- Device is active
switch.switchOn() -- Turn the virtual switch on
if domoticz.data['CountDevices'] == 0 then
domoticz.data['CountDevices'] = 1 -- Keep track off active devices
end
return('Switching On')
end
if power_average > 0 then -- Switch is off but average needs to be reset
domoticz.data[usage].reset() -- Reset history
end
return('Off') -- Device is off
end
if (device.isTimer) then -- Then its a regular check
domoticz.log("Monitoring " .. tostring(domoticz.data['CountDevices']) .. " apparaten.")
if (domoticz.data['CountDevices'] > 0) then -- When one or more devices are on
domoticz.log("Monitoring " .. tostring(domoticz.data['CountDevices']) .. " apparaten.")
domoticz.data['CountDevices'] = 0 -- Reset count
for i, machine in pairs(USAGE_DEVICES) do -- Loop thru all the devices
checked = status(machine) -- Check the status of each device
domoticz.log('status: '..checked) -- Check the status of each device
if checked ~= 'Off' then
domoticz.data['CountDevices'] = domoticz.data['CountDevices'] + 1 -- Keep track off active devices
end
end
end
elseif (USAGE_DEVICES[device.name] ~= nil) then -- Then one device has a changed power consumption
domoticz.log('status: '..status(USAGE_DEVICES[device.name])) -- Check the status of this one device
end
end
}