Created At

Nov 05, 2020

Last Update

Nov 20, 2020

Platforms

HC 2

Views

235

Download

29

BATTERY MONITOR

Displays the power levels of all battery operated devices.

  • The UI of the VD displays the 9 devices with the lowest power levels, sorted low to high.
  • The debugging window of the VD displays all battery operated devices.
  • Dead devices are clearly marked in the UI.

Optionally, every day at 20:00, push notifications are sent to a defined set of phones. One push notification for each battery that is below a specified (code configurable) level.

Technical details

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 push 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:

  • last time the push notification check took place
  • next time for push notifications check.

If the global variable does not exist, it is created automatically. Let the VD create the variable, do not do it manually.

Virtual Device configurable parameters

(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
VD_phoneIDs {6} IDs of  phones for 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 so see when all goes well.

 Credits

  • debug window logging mostly from "Battery Check Scene" by mysmarthome-cba-pl, available from Fibaro marketplace
  • some code fragments from "Advanced Battery Check (ABC) VD standalone 1.0" by   Sankotronic, available from Fibaro.com forum, virtual devices. Very extensive VD. Too much for what I need, but check it out if you need extensive battery management.

Copyright

None. Use, adapt, distribute to your liking.
Please provide feedback on how to improve this VD. Or let me know if you like it :-)

0 Comments,  Want to add comment please login
Load more comments