Click for more products.
No products were found.
Blog search
Latest Comments

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.

Related products
Related articles
1 Comment
  • Ja*

    Ja* 16.07.2018

    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 Comment
Leave a Reply
Please login to post a comment.

Menu

Settings

Create a free account to save loved items.

Sign in

Create a free account to use wishlists.

Sign in
News
Packeta - Pickup/Collection points and Z-BOXes
16. 10. 2024

From now on, you can pick up your order in person at pick-up points and Z-BOXes, in different countries, also with Cash On Delivery payment !


15. 10. 2024

After a long time, we have in stock a great 3-phase electricity consumption meter for smart homes based on Z-Wave technology.


Automatic VAT adjustment or removal
10. 10. 2024

The amount of VAT is automatically set according to the country of delivery, or VAT is removed for companies with a valid VAT number.


08. 10. 2024

File a complaint or return request online. How to do it? More info by clicking on More news in the bottom corner.


More news