About This File
[SCENE] Battery Check scene v1.2.4
Hello all,
Here it is, scene that will check battery level on all your battery operated devices and inform you on time when replacement is needed. I wish to thank very much to @petergebruers and @szmyk for code that searches and sorts all battery devices included to HC! THANK YOU!
VERSION HISTORY:
- 28/09/2017 - v1.1 - first release
- 29/09/2017 - v1.1.1 - added translations for Dutch and Slovak
- 29/09/2017 - v1.2 - added possibility to define excluded and rechargeable devices. Added 3 new messages and added translations for German, Czech, Swedish, Danish and French, but need translation for new 3 messages. Also added emoji symbols to e-mail notification.
- 30/09/2017 - v1.2.1 - Corrected level for devices that report level 255 since Sensative strips can report battery level higher than 100%. Corrected translations for Polish, German, Dutch, Slovak, Croatian, Serbian, Bosnian, Slovenian, Chinese, Italian languages. Removed testing code that was accidentally left for checking devices with rechargeable batteries in v1.2
- 01/10/2017 - v1.2.1 - added Romanian translation
- 01/10/2017 - v1.2.2 - If HC reported battery level is 255 then it is shown as 0 % just to avoid any misunderstandings.
- 02/10/2017 - v1.2.2 - added missing Danish translation
- 10/10/2017 - v1.2.3 - added translations for Norwegian, French, Romanian, Russian and Ukrainian languages.
- 17/03/2018 - v1.2.4 - Corrected translation for Czech language.
SCENE DESCRIPTION:
This scene is searching for all battery powered devices included in your HC2 and then checks their battery levels. It will send one e-mail to users with list of all devices which battery level is as follows:
- battery level 15% or lower will send WARNING to replace battery immediately
- battery level between 15% and 25% will send REMINDER that battery should be replaced soon
- battery level between 25% and 35% will send INFO to prepare or buy new battery for replacement
- rechargeable devices if battery level is 20% or less then will remind you to RECHARGE
- if all device batteries found with level above 35% then no e-mail will be sent
Above levels are set according to those used in most devices. Usually, battery is shown in red when device battery level drops to 35%, but there is still no e-mails sent by HC. Reminder 25% level is set according to my experience when it is last moment to order batteries if there are none in the drawer left. Replacement level of 15% is set because some devices can just stop working if level drops bellow. Since all battery operated devices most of the time sleep, it can happen that they might not be able to report back to the gateway due to rapid depletion of the battery at its end of life. Also, thanks to @I.Srodka to confirm that this levels are used by HC.
This scene supports multiple languages as in the list bellow:
HC included languages and for this you do not need to do setup English = "en" OK Polski = "pl" OK Deutsch = "de" OK Svenska = "sv" Portugues = "pt" Italiano = "it" OK Francais = "fr" OK Nederlands = "nl" OK Roman = "ro" OK Brazilian Portuguese = "br" Estonian = "et" Latvian = "lv" Chinese = "cn" OK Russian = "ru" OK Denmark = "dk" OK Finland = "fi" Czech Republic = "cz" US English = "us" OK Spanish = "es" Additional languages supported by this version: Set it up for local lng two letterrs between quotes Slovak = "sk" OK Croatian = "hr" OK Bosnian = "ba" OK Serbian = "rs" OK Slovenian = "si" OK Norwegian = "no" OK Ukrainian (NEW) = "ua" OK
It is difficult for me to properly translate to all above languages so for now languages with OK are translated and the rest are still to be translated. I will really appreciate your help with translation for the rest of the languages. Please if you do translation of bellow messages you can post it here so that other know that it is already translated. I will also add OK for every language I receive translation and of course update scene code! THANK YOU!
Thanks to @gucio1234 for Polish translation!
Thanks to @Bodyart for Slovak German and Dutch translations!
Thanks to @MaTi for Dutch translation!
Thanks to @jakub.jezek for Czech translation!
Thanks to @sonnyboy for Swedish translation!
Thanks to @TurboWannaBe for Danish translation!
Thanks to @speedoxx007 for French translation!
Thanks to @Momos for Romanian translation!
Thanks to @olekenneth for Norwegian translation!
Thanks to @Momos for Romanian translation!
Thanks to @jack.daniels for Russian and Ukrainian translations!
NEW v1.2 (added 3 new messages marked with arrows) This are messages for translation in English. %s are insertion points for device names and battery levels:
["en"] = { title = "Battery check", subTitle = "Following devices need your attention:", info = "INFO! id: %s - %s %s battery is on %s %%", remind = "REMINDER! id: %s - %s %s battery is on %s %%", warning = "WARNING! id: %s - %s %s battery is on %s %%", ---> excluded = "EXCLUDED! id: %s - %s %s battery is on %s %%", ---> recharge = "RECHARGE! id: %s - %s %s battery is on %s %%", found = "Found %s battery operated devices", tobuy = "INFO! Please order replacement battery", soon = "REMINDER! Need to be replaced soon!", replace = "WARNING! Please replace battery as soon as possible", ---> charge = "RECHARGE! Please recharge battery!", lang = "English" },
SCENE SETUP:
This scene is very simple to setup. First select Scenes on main menu in HC web GUI and then add new scene. Select LUA scene. Download BC scene and open with PLAIN TEXT EDITOR (please do not use MS Word or similar programs because they will add formatting that will make scene inoperable). After you paste it to upper code window then you can check and set it up as follows:
LANGUAGE:
If your language is on the bellow list:
Slovak "sk" Croatian "hr" Bosnian "ba" Serbian "rs" Slovenian "si" Norwegian "no" Ukrainian "ua"
You need to setup local lng with two letter abbreviation for your language:
local lng = "hr"
but leave it empty of your language is set on HC.
USERS TO RECEIVE E-MAIL:
Scene by default is set to send e-mail to superuser ID=2, but you can add or replace it with other users. Users ID you can find with this link to your HC docs:
http://YOUR_HC_IP/docs/#!/users
Just add users ID inside curled brackets separated by comma as in bellow example:
local userID = {2, 55, 128}
EXCLUDED DEVICES NEW v1.2
Now you can define devices to be ignored or excluded from report. Just add their ID numbers between curled brackets separated by coma:
local ignoreDevicesId = {100, 345}
or leave brackets empty to check all devices.
DEVICES WITH RECHARGEABLE BATTERIES NEW v1.2
You can also define devices with rechargeable batteries by their type, like for example new Fibaro Thermostat which is by default already added in the scene:
local rechargeDevicesType = {"com.fibaro.FGT001"}
You don't need to remove it even if you still don't have that thermostat. Scene is Fibaro thermostat ready!
RUNNING SCENE:
Scene is not set to automatically run so you need to setup whatever scheduling scene you use to start this scene once per day. If you use
then you can make following settings in Main scene FTBE:
-- SCHEDULED SCENES SETUP ------------------------------------------------ local runSceneSchedName = {"Battery check"} local runSceneSchedID = {Batt_check_sceneID}; local runSceneSchedHour = {{"10:00"}}; local runSceneSchedWeek = {{1, 1, 1, 1, 1, 1, 1}}; local runSceneSchedPushFlag = {0}; local runSceneSchedPushMessage = {""};
Of course, replace Batt_check_sceneID with ID number of this scene that will show up on General tab once scene is saved. And that's it! Enjoy!
HOW TO UPGRADE
From 1.1.1 or previous to 1.2 or higher: Just paste new code over previous one and setup as needed.
From 1.2.2 to 1.2.3: Upgrade only if you need one of the added translations. You can copy only part of the language you need or from line 120 to the end of code to preserve your settings.
From 1.2.2 to 1.2.Battery Check scene v1.2.4.lua4: Upgrade only if you need corrected Czech translation.
NOTE
LUA format of scene code is saved by ZeroBrane Studio v1.50. You can download it at this link: https://studio.zerobrane.com
TXT version please open with TextEdit on Mac or Notepad on Windows.
ICONS DOWNLOAD:
For battery icons please go here to download:
NOTE:
After installing this scene and make it running once per day you can remove battery low e-mail notification from all battery operated devices. Just remove tick for "Notify when battery low via e-mail" on Advanced tab and press save:
What's New in Version 1.2.4 See changelog
Released
Corrected translation for Czech language.
Recommended Comments
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.