This flow was submitted before accounts existed, so nobody owns it yet. If you submitted it, open the edit link you were given — it still works — and you can attach the flow to an account from there. There is no deadline, and attaching it retires the link for good.
Low Battery Notifications
This script checks all devices for low battery levels every hour and sends notifications to the AWTRIX3 device for devices below 20%.
| System | Domoticz |
|---|---|
| Firmware | AWTRIX 3 |
| Topic | Smarthome |
| Built by | Galadril |
| File | gkVBAnn7An4x.json · 2.4 KB |
| Icons | — |
| Published | 9 Jan 2025 |
| Downloads | 18 |
⚙️ Script Activation:
The script is active by default, as indicated by active = true.
⏰ Trigger:
The script runs every hour, as specified by the timer:
timer = { 'every 1 hours' }.
📝 Logging:
Uses the logging level domoticz.LOG_INFO, with entries marked by "AWTRIX3_BATTERY" for easy identification.
🚀 Execution:
When triggered, the script performs the following actions:
🔍 Condition Check:
- Filters devices with a battery level below 20%.
- Ignores devices without a battery attribute or those with invalid battery readings.
🔄 Action:
- Sends notifications for devices with low battery levels:
- Battery < 20%: Uses a specific icon (ICON_BATTERY_20) and sends a warning.
- Battery < 10%: Uses a critical icon (ICON_BATTERY_10) and sends a critical warning.
- Formats the notification as a JSON payload containing the device name and icon.
- Sends the payload to the "AWTRIX3 - Send Notification" device:
- ✅ If the AWTRIX3 device is found: Sends the notification.
- 🛑 If the AWTRIX3 device is not found: Logs an error.
More information:
Domoticz: www.domoticz.com
Domoticz AWTRIX3 Plugin: https://github.com/galadril/Domoticz-AWTRIX3-Plugin
gkVBAnn7An4x.json
local BATTERY_THRESHOLD_1 = 20 -- First threshold for notification
local BATTERY_THRESHOLD_2 = 10 -- Second threshold for critical notification
local ICON_BATTERY_20 = 6355 -- Icon for battery level < 20%
local ICON_BATTERY_10 = 6354 -- Icon for battery level < 10%
return {
active = true,
on = {
timer = {
'every 1 hours'
}
},
logging = {
level = domoticz.LOG_INFO,
marker = "AWTRIX3_BATTERY"
},
execute = function(domoticz)
-- Filter devices with low battery level
local lowOnBattery = domoticz.devices().filter(function(device)
local level = device.batteryLevel
return (
level ~= nil and -- Ensure the device has a battery level attribute
level ~= 255 and -- Ignore if no battery measurement is applicable
level < BATTERY_THRESHOLD_1 -- Notify if below 20%
)
end)
-- Send individual notifications for each device with low battery
lowOnBattery.forEach(
function(lowDevice)
local batteryLevel = lowDevice.batteryLevel
local notificationIcon = nil
-- Determine the appropriate icon based on battery level
if batteryLevel < BATTERY_THRESHOLD_2 then
notificationIcon = ICON_BATTERY_10
else
notificationIcon = ICON_BATTERY_20
end
local message = lowDevice.name .. " low"
local payload = {
text = message,
icon = notificationIcon
}
local payloadJSON = domoticz.utils.toJSON(payload)
domoticz.log('Low battery warning for: ' .. message, domoticz.LOG_INFO)
domoticz.log("Sending to AWTRIX3: " .. payloadJSON, domoticz.LOG_INFO)
-- Send the notification to AWTRIX3
local awtrixDevice = domoticz.devices('AWTRIX3 - Send Notification')
if awtrixDevice then
awtrixDevice.setDescription(payloadJSON)
awtrixDevice.switchOn().afterSec(2)
else
domoticz.log("AWTRIX3 - Send Notification device not found", domoticz.LOG_ERROR)
end
end
)
end
}