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.
--[[
--[[
%% 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
Note: If you miss any devices contact us on info@smarterhome.sk and we will update the LUA script.
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...
Implementations and setting the device for the triggering of the Fibaro Swipe scenes using the LUA script.
1 Comment
Jan 07/16/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.."%");