Dieses Script ist ein Abfallprodukt des Batterie check scripts von hier: (https://www.siio.de/board/thema/und-noch-ein-batterie-check-scipt/page/7/#post-79063)
Da es eher gedacht ist um sporadisch ausgeführt zu werden, hat es kein Autostart und muss manuell angestoßen werden. Der Output sieht dann ungefähr so aus:
[DEBUG] 10:45:45: Sun Aug 27 10:45:45 2017, Version: 0.1.0
[DEBUG] 10:45:46: Here is your HC2 device list:
[DEBUG] 10:45:46: --------------------------------------------------
[DEBUG] 10:45:46: 24 Batterie devices
[DEBUG] 10:45:46: 45 Non batterie devices
[DEBUG] 10:45:46: 9 Virtual devices
[DEBUG] 10:45:46: 3 HC2 Users
[DEBUG] 10:45:46: 6 iOS/Android devices
[DEBUG] 10:45:46: 6 Plugins in use.
[DEBUG] 10:45:46: -------------------------------------------------
Wer also schon immer wissen wollte, wieviel von welchen Geräten in seinem HC2 vorhanden sind, braucht in Zukunft nicht mehr zu zählen.
--[[
%% properties
--]]
-- file: Device-inventory.lua
-- version: 0.1.0
-- purpose:This script shows the device inventory and prints the output to
-- the debug window.
-- Click the Start button to run the script.
-- Copyleft 08-2017 {jeep}
local sourceTrigger = fibaro:getSourceTrigger();
local version = "0.1.0"
local oldnodeId = nil ;
Debug = function ( color, message )
fibaro:debug(string.format('<%s style="color:%s;">%s', "span", color, message, "span"))
end
devices = fibaro:getDevicesId({visible = true, enabled = true, isPlugin =false })
function checkDevices()
local vdev = 0;
local bdev = 0;
local users = 0;
local iosdev = 0;
local nbdev = 0;
local plugins = 0;
local x = 0;
Debug('withe', os.date('%c')..', Version: '.. version );
for id = 1, #devices do
local batteryLevel = fibaro:get(devices[id], 'batteryLevel')
local nodeId = fibaro:get(devices[id], 'nodeId')
if batteryLevel ~= nil and batteryLevel ~= '' then
if oldnodeId ~= nodeId then
bdev = bdev+1;
end
oldnodeId = nodeId
else
local dtype = fibaro:getType(devices[id])
if (dtype == 'virtual_device') or (dtype == 'HC_user') or (dtype == 'iOS_device') then
x=x+1
else
nbdev = nbdev+1
end
if (dtype == 'virtual_device') then
vdev = vdev +1
elseif (dtype == 'HC_user') then
users = users+1;
elseif (dtype == 'iOS_device') then
iosdev = iosdev+1;
end
end
end
devices = fibaro:getDevicesId({ enabled = true, visible = true, isPlugin =true })
for id = 1, #devices do
plugins = plugins+1
end
separator = '--------------------------------------------------'
Debug('withe','Here is your HC2 device list:')
Debug('withe', separator)
Debug('withe', bdev ..' Batterie devices')
Debug('withe', nbdev ..' Non batterie devices')
Debug('withe', vdev ..' Virtual devices')
Debug('withe', users ..' HC2 Users')
Debug('withe', iosdev ..' iOS/Android devices')
Debug('withe', plugins .. ' Plugins in use.')
Debug('withe', separator)
end
local startSource = fibaro:getSourceTrigger();
if (startSource["type"] == "other") then
checkDevices()
end