Dead Device Monitor
Domoticz

Dead Device Monitor

This script identifies devices in Domoticz that have stopped updating within a defined threshold (default: 7200 minutes). It notifies the user of any "dead" devices, excluding those in a predefined whitelist, by sending real-time alerts to AWTRIX3.
A flow by Galadril

Download flow

Flow Details

πŸš€ Flow:

  1. Trigger:

    • Runs every 1 minute to check device statuses.
  2. Condition:

    • Filters devices that:
      • Have not updated within the threshold (7200 minutes by default).
      • Are not in the whitelist of excluded devices.
  3. Actions:
    βœ… For each dead device:

    • Logs the device name and time since the last update.
    • Creates a JSON payload with a notification message and a specified icon (ID: 1059).
    • Sends the notification to AWTRIX3 using the "AWTRIX3 - Send Notification" device.
  4. Whitelist:

    • A predefined list of devices (e.g., "AWTRIX3 - Send Custom App", "Voordeur - Beweging") that are excluded from monitoring to avoid unnecessary alerts.
  5. Logging:

    • Provides detailed logs for each dead device, the notification payload, and the AWTRIX3 sending process.

More information:

Domoticz: www.domoticz.com

Domoticz AWTRIX3 Plugin: https://github.com/galadril/Domoticz-AWTRIX3-Plugin

-- Flow first published on January 2, 2025.

local THRESHOLD_MINUTES = 7200 -- Default threshold for dead devices in minutes local NOTIFICATION_ICON = 1059 -- Notification icon ID -- Whitelist of device names to exclude from notifications local WHITELISTED_DEVICES = { "Mode 1", "System Status", "Living Room Sensor", } return { active = true, on = { timer = { 'every 1 hours' } }, logging = { level = domoticz.LOG_INFO, marker = "DEVICE_MONITOR" }, execute = function(domoticz) local powerDevice = domoticz.devices("Power Monitor") if not powerDevice or powerDevice.state ~= "On" then return end -- Check if a device is in the whitelist local function isWhitelisted(deviceName) for _, name in ipairs(WHITELISTED_DEVICES) do if deviceName == name then return true end end return false end -- Filter devices that haven't updated within the threshold and are not whitelisted local deadDevices = domoticz.devices().filter(function(device) return device.lastUpdate and device.lastUpdate.minutesAgo > THRESHOLD_MINUTES and not isWhitelisted(device.name) end) -- Process each dead device deadDevices.forEach(function(deadDevice) local notificationText = "Inactive device detected: " notificationText = notificationText .. deadDevice.name .. " (Last update: " .. deadDevice.lastUpdate.minutesAgo .. " mins ago)" -- Log message domoticz.log(notificationText, domoticz.LOG_INFO) -- Format the JSON payload for notifications local payload = { text = notificationText, icon = NOTIFICATION_ICON } local payloadJSON = domoticz.utils.toJSON(payload) domoticz.log("Sending notification: " .. payloadJSON, domoticz.LOG_INFO) -- Send the JSON to the Notification Sender device local notificationDevice = domoticz.devices('Notification Sender') if notificationDevice then notificationDevice.setDescription(payloadJSON) notificationDevice.switchOn().afterSec(2) else domoticz.log("Notification Sender device not found", domoticz.LOG_ERROR) end end) end }
-- Flow first published on January 14, 2025, last updated on January 14, 2025 at 08:01.