Pomoże ktoś rozwiązać problem?
Czciałem otrzymać listę wszsytkich ID urządzeń, W tym celu wykonałem scenę z kodem:
--[[
%% properties
%% globals
--]]
local maxNodeID = 550
local nazwa
local spis = ''
local licznik = 0
local lista_ID = ''
local lista_pusta = ''
local lista_full = ''
for i = 0, maxNodeID do
nazwa = fibaro:getName(i)
if nazwa ~= '' and tonumber(fibaro:getValue(i, "parentID")) == 1
then
--inkrementacje
fibaro:debug("urzadzenie = "..i..", czyli "..nazwa) -- debug testowy
spis = spis .. tostring(i) .. ' ' .. 'dead\n'
licznik = licznik + 1
lista_ID = lista_ID .. tostring(i) .. ','
lista_pusta = lista_pusta .. '0,'
end
end
-- uciecie ostatniego przecinka
lista_ID = string.sub(lista_ID, 1, -2)
lista_pusta = string.sub(lista_pusta, 1, -2)
-- montaz ostatniej listy
lista_full = "local ID = {" .. lista_ID .. "}"
lista_full = lista_full .. "\n" .. "local Dead = {" .. lista_pusta .. "}"
lista_full = lista_full .. "\n" .. "local Dead = {" .. lista_pusta .. "}"
lista_full = lista_full .. "\n" .. "local DeadTime = {" .. lista_pusta .. "}"
-- wysylka listy na maila
fibaro:call(2, "sendEmail", "Lista properties", spis)
fibaro:call(2, "sendEmail", "Lista ID", lista_ID)
fibaro:call(2, "sendEmail", "Lista pusta", lista_pusta)
Niczego w scenie nie zmieniałem, dokładnie przekopiowałem taką jaka jest i nie otrzymałem żadnej informacji. W czym jest problem?
Kolejna sprawa to scena z budzeniem umarlaków. Scenę także przekopiowałem i zmieniłem tylko ID urządzenia. Sprawdzam to tylko na jednym urządzeniu ID 110. Gdzie jeszcze muszę wprowadzić zmiany?
Czy ktoś może sprawdzić co jest problemem?
--[[
%% properties
110 dead
%% globals
--]]
-- powyzej wylistowane wszystkie ID urzadzen
-- ponizej powtorzone numery ID urzadzen do sprawdzania czy sa martwe
local ID = {110}
local Dead = {0}
local StartDead = {0}
local DeadTime = {0}
local trigger = fibaro:getSourceTrigger()
local TriggerID = tonumber(trigger['deviceID'])
--local Value, ModificationTime, Petla, PetlaCzasStart, nrdead = 0,0,0,0,0
local Value = 0
local ModificationTime = 0
local Petla = 0
local PetlaCzasStart = 0
local SprawdzanieStatusuNotOK = true
local Awaria = false
local Raport = ""
local DeadList = ""
local nrdead = 0
fibaro:setGlobal("nrdead", "0")
fibaro:call(223, "pressButton", "1") --HC2 send nr dead thinkspeak
--fibaro:debug(StartDead[1]..DeadTime[1])
--fibaro:debug(Value..ModificationTime..Petla..PetlaCzasStart..nrdead)
--fibaro:debug('start'..#ID..#Dead..#StartDead..#DeadTime)
--if TriggerID ~= nil then fibaro:debug('trigger ID='..TriggerID) else fibaro:debug('trigger type='..trigger.type) end
-- jesli scena jezeli juz dziala skoncz scene
if tonumber(fibaro:countScenes()) > 1
then fibaro:abort() end
PetlaCzasStart = os.time()
-- program glowny zapetlony w petli while
while SprawdzanieStatusuNotOK and (os.time() - PetlaCzasStart) < 3000 do
-- ustaw zeby zakonczyc petle while w nastepnym kroku
SprawdzanieStatusuNotOK = false
-- sprawdzanie stanu wszystkich ID
fibaro:sleep(5000)
for Petla = 1 , #ID do
-- jezeli czujnik martwy a w tabeli oznaczony jako zywy obudz 1 raz
Value , ModificationTime = fibaro:get(ID[Petla],'dead')
if fibaro:get(ID[Petla],'dead') == '1' and Dead[Petla] == 0
then
local name = fibaro:getName(ID[Petla]).. ' ' .. fibaro:getRoomNameByDeviceID(ID[Petla])
--fibaro:debug('Dead: '..ID[Petla].." "..name);
fibaro:setGlobal("deadlist", ID[Petla])
fibaro:setGlobal("deadname", name)
--fibaro:call(302, "pressButton", "6") --update log mysql
nrdead = nrdead + 1
DeadList = DeadList..ID[Petla].."\n"
Dead[Petla] = 1
DeadTime[Petla] = os.time()
StartDead[Petla] = ModificationTime
fibaro:wakeUpDeadDevice(ID[Petla])
end
-- jezeli po minucie po pierwszej probie ciagle jest martwy sprobuj 2 raz
if fibaro:get(ID[Petla],'dead') == '1' and Dead[Petla] == 1 and
(os.time() - DeadTime[Petla]) > 60
then
Dead[Petla] = 2
DeadTime[Petla] = os.time()
fibaro:wakeUpDeadDevice(ID[Petla])
end
-- jezeli po minucie po drugiej probie ciagle jest martwy sprobuj 3 raz
if fibaro:get(ID[Petla],'dead') == '1' and Dead[Petla] == 2 and
(os.time() - DeadTime[Petla]) > 60
then
Dead[Petla] = 3
DeadTime[Petla] = os.time()
fibaro:wakeUpDeadDevice(ID[Petla])
end
-- jezelipo minucie po trzeciej probie ciagle martwy raportuj status 4
if fibaro:get(ID[Petla],'dead') == '1' and Dead[Petla] == 3 and
(os.time() - DeadTime[Petla]) > 60
then
Dead[Petla] = 4
end
-- jezeli byl martwy a wrocil do zywych czekaj dwie minuty i raportuj jako ozywiony
if fibaro:get(ID[Petla],'dead') == '0' and Dead[Petla] > 0 and
(os.time() - ModificationTime) > 120 and Dead[Petla] < 10
then
Dead[Petla] = Dead[Petla] + 10
DeadTime[Petla] = ModificationTime - StartDead[Petla]
end
if fibaro:get(ID[Petla],'dead') == '1' and Dead[Petla] > 10
then
Dead[Petla] = 0
end
-- jezeli jakikolwiek czujnik jest w trakcie ozywiania ustaw flage do petli while
if Dead[Petla] > 0 and Dead[Petla] < 4
then
SprawdzanieStatusuNotOK = true
end
end
end
-- Raport z czynnosci
if (os.time() - PetlaCzasStart) > 2990
then
Raport = Raport .. ' TRAGEDIA JAKAS!!!! 15 minut budzenia umarlakow!!! \n\n'
end
for Petla = 1 , #ID do
Value , ModificationTime = fibaro:get(ID[Petla],'dead')
local name = fibaro:getName(ID[Petla]).. ' ' .. fibaro:getRoomNameByDeviceID(ID[Petla])
if Dead[Petla] == 4
then
Awaria = true
Raport = Raport..' AWARIA!!! Prawdziwa padlina ID : '..ID[Petla]..name..'\n'
end
if Dead[Petla] > 10
then
Raport = Raport ..' Obudzony : '..ID[Petla]..' '..name
.. ' po ' .. tostring(Dead[Petla] - 10) ..' probie, czas smierci: '..tostring(DeadTime[Petla])..' s\n'
Dead[Petla] = 0
end
if (os.time() - ModificationTime) < 6000 and Dead[Petla] < 10
then
--Raport = Raport..' Obudzenie : '..tostring(ID[Petla])..' '..name ..' nastapilo '..tostring(os.time() - ModificationTime)..' s temu \n'
end
end
if Awaria
then
--fibaro:call(idr,'sendPush','UMARLAKI - PRZECZYTAJ MEJLA')
end
if string.len(Raport) > 0 and nrdead > 2 then
fibaro:call(2,"sendEmail","Raport budzenia umarlakow", Raport)
end
fibaro:setGlobal("nrdead", tostring(nrdead))
--fibaro:setGlobal("deadlist", DeadList)
fibaro:call(223, "pressButton", "1") --HC2 send nr dead thinkspeak
fibaro:debug('END '..TriggerID..':'..Raport)