Thanks @waaren
So in fact it's a System_Alive_Check where only
is omitted
Code: Select all
-- this script can be used in conjunction with the System-alive checker plug-in.
-- the plugin pings a list of devices and creates switches for these devices
-- the reason for this script is to not treat devices as dead immediately after they
-- do not respond. More often than not, the second ping atempt does work. So only
-- if the device has been not responding for a while AFTER it is been presumed dead
-- then this script will notify you
-- put the names of these switches in the devicesToCheck list
-- you may have to tweak the THRESHOLD depending on the check interval
local THRESHOLD = 120 -- minutes
local devicesToCheck =
{
'TFA1',
'TFA2',
'Oregon',
}
return
{
on =
{
devices = devicesToCheck,
timer =
{
'every other hour',
},
},
data =
{
notified = { initial = {} },
},
logging =
{
level = domoticz.LOG_ERROR, -- change from LOG_DEBUG to LOG_ERROR when script executes without problems
marker = 'notify',
},
execute = function(dz, item)
if item.isTimer then
for index, deviceName in ipairs(devicesToCheck) do
local device = dz.devices(deviceName)
--dz.notify('notifyer achter de eerste if.',dz.PRIORITY_HIGH)
dz.log('device name ' .. device.name, dz.LOG_DEBUG)
dz.log('device state ' .. device.state, dz.LOG_DEBUG)
dz.log('device lastUpdate ' .. device.lastUpdate.minutesAgo, dz.LOG_DEBUG)
dz.log('device notified ' .. tostring(dz.data.notified[deviceName]), dz.LOG_DEBUG)
if device.lastUpdate.minutesAgo >= THRESHOLD and dz.data.notified[deviceName] ~= true then
--dz.notify('notifyer achter de tweede if.',dz.PRIORITY_HIGH)
dz.log('Idle device ' .. deviceName, dz.LOG_DEBUG)
dz.notify('notifyer', deviceName .. ' is not responding anymore.',dz.PRIORITY_HIGH)
dz.data.notified[deviceName] = true
end
end
else
dz.data.notified[item.name] = false
end
end
}
Can you explain me how come it displays temp-sensors every 30 seconds while it does not in the original System_Alive_Checker.
Code: Select all
2020-04-26 12:52:41.579 Status: dzVents: Info: Handling events for: "TFA1", value: "20.4;49;1"
2020-04-26 12:52:42.031 (Slimme meter) P1 Smart Meter (Stroom)
2020-04-26 12:52:46.306 (RFXCOM) Temp + Humidity (TFA2)
2020-04-26 12:52:46.451 Status: dzVents: Info: Handling events for: "TFA2", value: "20.4;47;1"
2020-04-26 12:52:52.023 (Slimme meter) P1 Smart Meter (Stroom)
2020-04-26 12:53:02.029 (Slimme meter) P1 Smart Meter (Stroom)
2020-04-26 12:53:12.036 (Slimme meter) P1 Smart Meter (Stroom)
2020-04-26 12:53:22.026 (Slimme meter) P1 Smart Meter (Stroom)
2020-04-26 12:53:24.437 (RFXCOM) Temp + Humidity (TFA1)
2020-04-26 12:53:24.586 Status: dzVents: Info: Handling events for: "TFA1", value: "20.4;49;1"
2020-04-26 12:53:31.310 (RFXCOM) Temp + Humidity (TFA2)
2020-04-26 12:53:31.433 Status: dzVents: Info: Handling events for: "TFA2", value: "20.4;47;1"
2020-04-26 12:53:32.028 (Slimme meter) P1 Smart Meter (Stroom)
2020-04-26 12:53:40.991 (Ranninkstraat 52) Temp + Humidity + Baro (Ranninkstraat)
2020-04-26 12:53:40.994 (Ranninkstraat 52) Wind (Unknown)
2020-04-26 12:53:40.998 (Ranninkstraat 52) Rain (Unknown)
2020-04-26 12:53:42.038 (Slimme meter) P1 Smart Meter (Stroom)
2020-04-26 12:53:52.044 (Slimme meter) P1 Smart Meter (Stroom)
2020-04-26 12:53:56.687 (RFXCOM) Temp (Oregon)
2020-04-26 12:53:56.839 Status: dzVents: Info: Handling events for: "Oregon", value: "20.2"
2020-04-26 12:54:02.035 (Slimme meter) P1 Smart Meter (Stroom)
2020-04-26 12:54:07.443 (RFXCOM) Temp + Humidity (TFA1)
2020-04-26 12:54:07.562 Status: dzVents: Info: Handling events for: "TFA1", value: "20.4;49;1"
2020-04-26 12:54:12.041 (Slimme meter) P1 Smart Meter (Stroom)
2020-04-26 12:54:16.313 (RFXCOM) Temp + Humidity (TFA2)
2020-04-26 12:54:16.467 Status: dzVents: Info: Handling events for: "TFA2", value: "20.4;47;1"
2020-04-26 12:54:22.050 (Slimme meter) P1 Smart Meter (Stroom)
2020-04-26 12:54:27.930 (RFXCOM) Temp (Oregon)
2020-04-26 12:54:28.066 Status: dzVents: Info: Handling events for: "Oregon", value: "20.2"
2020-04-26 12:54:32.039 (Slimme meter) P1 Smart Meter (Stroom)
2020-04-26 12:54:42.045 (Slimme meter) P1 Smart Meter (Stroom)
2020-04-26 12:54:50.435 (RFXCOM) Temp + Humidity (TFA1)
2020-04-26 12:54:50.586 Status: dzVents: Info: Handling events for: "TFA1", value: "20.4;49;1"
2020-04-26 12:54:52.052 (Slimme meter) P1 Smart Meter (Stroom)
Is that because this
is omitted?
I have found this one as well:
Code: Select all
local devicesToCheck = {
['TFA1'] = 80, -- threshold in seconds
['TFA2'] = 90,
['Oregon'] = 90
}
return {
active = true,
on = { timer = { 'every 3 minutes' } },
data = { notified = { initial = {} } },
execute = function(dz)
local notified = dz.data.notified -- short reference
local toCheck = devicesToCheck
for deviceName, threshold in pairs(toCheck) do
local lastUpdate = dz.devices(deviceName).lastUpdate.secondsAgo
if (lastUpdate > threshold and notified[deviceName] == nil) then
dz.log(deviceName .. 'is inactive for ' .. lastUpdate .. 's. Threshold=' .. threshold, dz.LOG_ERROR)
notified[deviceName] = lastUpdate -- mark as notified
else
notified[deviceName] = nil -- remove from notified list
end
end
end
}
Which one is more elegant in the way that it asks less resources from domoticz/rasperrypi.
Extra question: Can the system_alive_check be adapted in a way that it checks all domoticz connected devices (WiFi and 433/866 MHz) in one loop for being up and running?
Bugs bug me.