Easy LUA scripts part 1: battery check

by boomx10. February 2016

From time to time we will present you some short, but useful LUA scripts within these new series.
Here you get to know more.

In the first episode of our new series, we want to present a short script to you, with it you will be able to check all battery driven devices in regard of their status. The script will show you the battery status and if it is necessary to change the batteries or not. The variety of status will be shown in different colors. These colors are green (battery is in best order) and red (battery runs lower than 25%). In the following picture you can see this in detail.

lua battery check

lua battery check

The LUA script

The LUA script checks all devices, which are implemented in your FIBARO HomeCenter2 and is assigned to a room, in a loop and recognizes, if a device is battery driven or stationary. To prevent for example the LUX and temperature values of a MotionSensor will be displayed also, the script inquires which kind of device is present.
Following kinds of devices are supported at the moment:

  • fibaro.remoteSwitch (z.B. Wall-C)
  • fibaro.doorLock (z.B. RFID-Sensor, danalock)
  • fibaro.FGMS001 (Motion Sensor)
  • fibaro.windowSensor (door sensor)
  • fibaro.doorSensor (door sensor)
  • fibaro.binarySwitch (e.g. battery driven sirene)
  • fibaro.FGSS001 (smoke sensor v1 & v2)
  • fibaro.FGFS101 (flood sensor)


While testing you may recognize some more kinds of devices, which are not covered by the list above, if this happens, please take a look in the API for the device type. This apparent via the URL  http://IP-HC2/api/devices?=ID_des_devices . There you search for the ID, which does not appear in the script. Please copy the tab „type“ in the following display.

 lua battery check new typ

lua battery check new typ

We would be pleased, if you can provide us with the „traced“ types of devices in the comment section, so we will be able to update this script now and then.

Thank you for your participation and have fun with this script.



About The Author

Leave a Response