Sorry za dluga nieobecnosc... problem rozwiazany, dzieki marecki_0luk1 za naprowadzenie. Udalo mi sie rozwiazac problem bez uzycia zmiennej globalnej, tylko local. Od teraz uzywam tasmyLED na scianie i za TV do sygnalizowania zdarzen (np: 1x zielony gdy ktos jest w korytarzu, lub 3x zielony gdy skonczy sie pranie, lub 10x czerwony gdy alarm lub zalanie). Po zasygnalizowaniu zdarzenia tasmaLED wraca do poprzednio ustawionego koloru.
Czesc kodu odpowiedzialna za powrot do poprzedniego koloru:
--pobierz ostatnie ustawienie koloru
local colorSet = fibaro:getValue(90, "lastColorSet")
fibaro:debug(colorSet)
--miejsce na akcje
fibaro:call(90, "setColor", "0", "255", "0", "0")
fibaro:sleep(500)
--ustaw poprzedni kolor
local RGBWTable= {};
local i = 1;
for value in string.gmatch(colorSet,"(%d+)") do
RGBWTable[i] = value;
i = i + 1;
end
fibaro:debug('R:'..RGBWTable[1]);
fibaro:debug('G:'..RGBWTable[2]);
fibaro:debug('B:'..RGBWTable[3]);
fibaro:debug('W:'..RGBWTable[4]);
fibaro:call(90, "setColor", RGBWTable[1], RGBWTable[2], RGBWTable[3], RGBWTable[4]);
Przykladowy kod, ktory daje znac gdy ktos otworzy drzwi wejsciowe i wejdzie do korytarza:
--[[
%% properties
23 value
--]]
if (fibaro:countScenes() > 1) or
fibaro:getValue(23, "value") == 0
then
fibaro:debug("Scena wywolana kilkukrotnie lub czujka zmienila stan z 1 na 0")
fibaro:abort()
end
if
( tonumber(fibaro:getValue(23, "value")) > 0 )
and
( tonumber(fibaro:getValue(90, "value")) == 0 )
then
fibaro:setGlobal("text", "FIBARO: %0A%0AMotion Detected in Hall - Light ON")
fibaro:call(76, "pressButton", "1")
fibaro:setGlobal("koditext", "Motion Detected in Hall - Light ON");
fibaro:call(150, "pressButton", "2");
fibaro:call(90, "setG", "255")
fibaro:sleep(300)
fibaro:call(90, "turnOff")
elseif
( tonumber(fibaro:getValue(23, "value")) > 0 )
and
( tonumber(fibaro:getValue(90, "value")) > 0 )
then
--get last color
local colorSet = fibaro:getValue(90, "lastColorSet")
fibaro:debug(colorSet)
fibaro:setGlobal("text", "FIBARO: %0A%0A[Eng] Motion Detected in Hall - Light ON")
fibaro:call(76, "pressButton", "1")
fibaro:setGlobal("koditext", "Motion Detected in Hall - Light ON");
fibaro:call(150, "pressButton", "2");
--start Info Sequence
fibaro:call(90, "setG", "255");
fibaro:sleep(300)
--set old color
local RGBWTable= {};
local i = 1;
for value in string.gmatch(colorSet,"(%d+)") do
RGBWTable[i] = value;
i = i + 1;
end
fibaro:debug('R:'..RGBWTable[1]);
fibaro:debug('G:'..RGBWTable[2]);
fibaro:debug('B:'..RGBWTable[3]);
fibaro:debug('W:'..RGBWTable[4]);
fibaro:call(90, "setColor", RGBWTable[1], RGBWTable[2], RGBWTable[3], RGBWTable[4]);
end