LUA Script: Battery check - Fibaro Home Center 2

LUA Script: Battery check - Fibaro Home Center 2

In this short but useful manual we will show you how to check the battery status in the interface of the Fibaro Home Center 2 control unit using a simple LUA script. You can create the script in a simple way in the Fibaro interface after clicking the section Scenes -> Add scene -> Add scene in LUA. Then insert the below-mentioned script into the advanced section and name the scene for example Battery status. Start the scene and then you can see the response to the running scene in the debug window, it means the status of the batteries.

Example of a script:

 
--[[ 
--[[ 
%% properties 
%% globals 
--]] 
 
local minBatteryLevel = 25
local maxID = 1000
 
Debug = function ( color, message )
  fibaro:debug(string.format('<%s style="color:%s;">%s', "span", color, message, "span"))
end
 
for id = 1, maxID do 
   local batteryLevel = fibaro:get(id, 'batteryLevel') 
 if batteryLevel ~= nil 
    then 
      local name = fibaro:getName(id) 
      local room = fibaro:getRoomNameByDeviceID(id) 
      if not(room == "unassigned") then
       local deviceType = fibaro:getType(id)
       if(deviceType == 'com.fibaro.FGMS001v2' or deviceType == 'com.fibaro.humiditySensor' 
or deviceType == 'com.fibaro.FGFS101' or deviceType == 'com.fibaro.remoteSwitch'
or deviceType == 'com.fibaro.doorLock' or deviceType == 'com.fibaro.FGMS001'
or deviceType == 'com.fibaro.windowSensor' or deviceType == 'com.fibaro.doorSensor'
or deviceType == 'com.fibaro.FGSS001' or deviceType == 'com.fibaro.binarySwitch') then if tonumber(batteryLevel) <= minBatteryLevel then Debug( 'red', "POZOR! " ..name.." ("..room..")/Batéria: "..batteryLevel.." %") else Debug( 'green', name.." ("..room..")/Batéria: "..batteryLevel.." %") end end end end end

fibaro home center 2 kontrola baterii

The following types of devices are supported: 

  • fibaro.humiditySensor (humidity sensors)
  • fibaro.remoteSwitch (z.B. Wall-C)
  • fibaro.doorLock (z.B. RFID-Sensor, danalock)
  • fibaro.FGMS001 (movement sensor v1 and v2)
  • fibaro.windowSensor (window sensors)
  • fibaro.doorSensor (door sensors)
  • fibaro.binarySwitch (e.g. battery siren)
  • fibaro.FGSS001 (smoke sensor v1 and v2)
  • fibaro.FGFS101 (flood sensor)

 

Note: If you miss any devices contact us on info@smarterhome.sk and we will update the LUA script.

Posted on 13.06.2016 Tutorials and Tips, FIBARO, FIBARO HC2, LUA scripts for HC2 1 15256

Related articles

Fibaro HC2: LUA script to check the status of windows and doors

Short LUA script for Z-Wave controller Fibaro Home Center 2 for checking the door and window sensors when leaving the...

Using Aeon Labs Minimote in Fibaro HC2

Using Aeon Labs Minimote in Fibaro HC2

LUA: Fibaro Swipe

Implementations and setting the device for the triggering of the Fibaro Swipe scenes using the LUA script.

1 Comment

  • Jan

    Jan 16.07.2018 Reply

    If your devices are named logically, you could just get the name instead of checking the device type using:

    modulename = fibaro:getName(id) ;
    fibaro:debug("deviceid "..id.." named "..modulename.." - battery level is at "..batteryLevel.."%");


Leave a CommentLeave a Reply

Blog search

Latest Comments

Recently Viewed

No products

Menu

Compare 0