Hallo zusammen, habe ein LUA Script für “The Button” gefunden.
Button Script
–[[
%% autostart
%% properties
%% weather
%% events
164 CentralSceneEvent
%% globals
–]]
– This scene can detect if a Fibaro button is pressed one to five times and
– if the button is held down. Then the Lua script conduct different things
– from turning on or off light or playing music.
– To use it, please edit the number 164 CentralSceneEvent above to the
– ID on your button i.e. 23 CentralSceneEvent.
– Made in Denmark by Thomas G. Nielsen, 2017.
if (fibaro:countScenes()>1) then fibaro:abort(); end
----------- Is the button pressed -------------------------
20 local button_source = (fibaro:getSourceTrigger()[“event”][“data”]);
--------------------pressed once---------------------------------------------------------
if (tostring(button_source[“keyAttribute”]) == “Pressed”) then
if (( tonumber(fibaro:getValue(136, “value”)) > 0 )) then
fibaro:call(136, “turnOff”);
else
fibaro:call(136, “turnOn”);
end
-------------------pressed twice----------------------------------------------------------
elseif (tostring(button_source[“keyAttribute”]) == “Pressed2”) then
local musik = (fibaro:getGlobalValue(“Wc_musik”));
if (musik == “1”) then
fibaro:setGlobal(“Wc_musik”, “0”);
fibaro:startScene(127);
else
fibaro:setGlobal(“Wc_musik”, “1”);
fibaro:startScene(125);
end
-------------------pressed three----------------------------------------------------------
elseif (tostring(button_source[“keyAttribute”]) == “Pressed3”) then
if (( tonumber(fibaro:getValue(19, “value”)) < 1 )) or
(( tonumber(fibaro:getValue(137, “value”)) <1 )) then
fibaro:call(19, “turnOn”);
fibaro:call(137, “turnOn”);
else
fibaro:call(19, “turnOff”);
fibaro:call(137, “turnOff”);
end
-----------------Pressed four------------------------------------------------------------
elseif (tostring(button_source[“keyAttribute”]) == “Pressed4”) then
fibaro:call(19, “turnOn”);
-----------------Pressed five------------------------------------------------------------
elseif (tostring(button_source[“keyAttribute”]) == “Pressed5”) then
fibaro:call(19, “turnOff”);
------------------Held down-----------------------------------------------------------
elseif (tostring(button_source[“keyAttribute”]) == “HeldDown”) then
if (( tonumber(fibaro:getValue(19, “value”)) < 1 )) then
fibaro:call(19, “setValue”, “30”);
else
fibaro:call(19, “turnOff”);
end
end
Ich bekomme im Debug Fenster die Meldung
[DEBUG] 13:35:14: line 20: attempt to index field ‘event’ (a nil value)
Was kann ich tun, kenne mich mit LUA leider nicht aus
Grüße
DickerDad