Created At
Nov 05, 2020
Created At
Nov 05, 2020
Last Update
Jan 04, 2021
Platforms
HC 2
Views
2048
Download
221
Displays the power levels of all battery operated devices.
Optionally, every day at 20:00, notifications are sent. Both push notifications and email notifications are supported. Notifications can be sent to the phones and email addresses of users defined in the Fibaro system. Individual notifications are sent for each battery that is below a specified (configurable) level.
The VD main loop runs frequently (specified by VD_ui_refresh_interval) to ensure the ui is kept up to date. Default is 5 minutes.
A check for notifications is done once a day, at 20:00. The accuracy of that moment is determined by VD_ui_refresh_interval. The VD only checks if it is 20:00 every 5 minutes.
The VD uses global variable BATMON_CONFIG to store its configuration. It contains:
If the global variable does not exist, it is created automatically. Let the VD create the variable, do not do it manually.
(in the code of the main loop)
Variable | default value | description |
VD_ui_refresh_interval | 5*60*1000 | interval between runs of the main loop [msec] |
VD_ui_num_battery_lines | 9 | Number of lines in the VD UI that can display a battery status. Only change this when you have added or removed a 'Batteryxx' line in the UI. |
VD_user_ids_for_email | {2} | IDs of users that should receive email notifications. Leave empty to disable email notifications. |
VD_phone_ids_for_push_messages | {6} | IDs of phones for push notifications. Leave empty to disable push notifications. |
VD_push_notification_threshold | 15 | battery level under which a push notification is generated [%] |
VD_notification_override_interval | 0 | if ~=0, this interval [sec] will override the usual interval of 1 day |
VD_extended_debugging | false | extended debugging for testing purposes. The stuff you do not need to see when all goes well. |
V1, Dec-2020 : Added email notifications. Minor code cleanup.
V0, Oct-2020 : Initial version
None. Use, adapt, distribute to your liking.
I appreciate a comment to indicate what you like and dislike about the VD.
For anyone facing the same problem as me that certain devices has battery level 255% when depleted I made the following change in the code: if (device_is_dead) then battery_level = 0; else battery_level = tonumber(fibaro:getValue(device_id, "batteryLevel")); -- For devices returning battery level 255 at critical low, replace with 1 if (battery_level == 255) then battery_level = 1; end end