Aller au contenu

Lua


Smart

Messages recommandés

Good morning, I have this scene that works all day, but actually I would like it to work from 7 to 23, how should I add that part to this code?
Thank you!

--[[
%% autostart
%% properties
110 value --- Relay switch 2x1.5
35 value ---- Motion Sensor
%% weather
%% events
%% globals
--]]

if fibaro:countScenes() > 1  then
  fibaro:abort()
end

local startSource = fibaro:getSourceTrigger();
if (
 (tonumber(fibaro:getValue(110, "value")) == 0  and  tonumber(fibaro:getValue(35, "value")) > 0 ))
then
	fibaro:call(110, "turnOn");
end

 

Lien vers le commentaire
Partager sur d’autres sites

Hi,

 

Like this, as say @jojo

 

I think you don't need in the header 110 value ;-). Your scene is triggered on detection.


 

--[[
%% autostart
%% properties
35 value
%% weather
%% events
%% globals
--]]

if fibaro:countScenes() > 1  then
  fibaro:abort()
end

local now = os.date("%H:%M")

if (now >= "07:00" and now <= "23:00") then

  if (
      (tonumber(fibaro:getValue(110, "value")) == 0  and  tonumber(fibaro:getValue(35, "value")) > 0 ))
  then
    fibaro:call(110, "turnOn");
  end

end

 

Lien vers le commentaire
Partager sur d’autres sites

il y a 9 minutes, pepite a dit :

Hi,

 

Like this, as say @jojo

 

I think you don't need in the header 110 value ;-). Your scene is triggered on detection.


 


--[[
%% autostart
%% properties
35 value
%% weather
%% events
%% globals
--]]

if fibaro:countScenes() > 1  then
  fibaro:abort()
end

local now = os.date("%H:%M")

if (now >= "07:00" and now <= "23:00") then

  if (
      (tonumber(fibaro:getValue(110, "value")) == 0  and  tonumber(fibaro:getValue(35, "value")) > 0 ))
  then
    fibaro:call(110, "turnOn");
  end

end

 

  •  

Thank you.
The last query. I would like that when I double click the variable is changed to "On" so that the light does not turn off, and then when I click to pass the variable to "Off". I have a fgs223, is this scene okay?

This is my scene: 

--[[
%% autostart
%% properties
126 value
11 value
%% weather
%% events
%% globals
--]]

local startSource = fibaro:getSourceTrigger();
if (
 ( fibaro:getGlobalValue("TeclaBanochicos") == "Desactivada"  and  tonumber(fibaro:getValue(126, "value")) == 0  and  tonumber(fibaro:getValue(11, "value")) > 0 )
or
startSource["type"] == "other"
)
then
	fibaro:call(126, "turnOn");
end

And "Desactivada" 

--[[
%% autostart
%% properties
%% weather
%% events
124 CentralSceneEvent 2 Pressed
%% globals
--]]

local startSource = fibaro:getSourceTrigger();
if (
 ( (startSource["type"] == "event" and startSource["event"]["type"] == "CentralSceneEvent") )
or
startSource["type"] == "other"
)
then
	fibaro:setGlobal("TeclaBanochicos", "Desactivada");
end

And "Activada":

--[[
%% autostart
%% properties
%% weather
%% events
124 CentralSceneEvent 2 Pressed2
%% globals
--]]

local startSource = fibaro:getSourceTrigger();
if(startSource["type"] == "other") then
	fibaro:setGlobal("TeclaBanochicos", "Activada");
else
if (( (startSource["type"] == "event" and startSource["event"]["type"] == "CentralSceneEvent") )) then
setTimeout(function()
local delayedCheck0 = false;
local tempDeviceState0, deviceLastModification0 = fibaro:get(124, "value");
if (( (startSource["type"] == "event" and startSource["event"]["type"] == "CentralSceneEvent") ) and (os.time() - deviceLastModification0) >= 3) then
	delayedCheck0 = true;
end

local startSource = fibaro:getSourceTrigger();
if (
 ( delayedCheck0 == true )
or
startSource["type"] == "other"
)
then
	fibaro:setGlobal("TeclaBanochicos", "Activada");
end
end, 3000)
end
end
Lien vers le commentaire
Partager sur d’autres sites

Could you test this in a lua scene et click once, twice, and heldown please


 

--[[
%% events
124 CentralSceneEvent
--]]


local source = fibaro:getSourceTrigger().event.data;
local ID = sourceTrigger.event.data.keyId
local Attribute = sourceTrigger.event.data.keyAttribute
 
fibaro:debug("ID : ".. ID .." - keyAttribute : ".. Attribute)

 

Lien vers le commentaire
Partager sur d’autres sites

Il y a 1 heure, pepite a dit :

Could you test this in a lua scene et click once, twice, and heldown please


 


--[[
%% events
124 CentralSceneEvent
--]]


local source = fibaro:getSourceTrigger().event.data;
local ID = sourceTrigger.event.data.keyId
local Attribute = sourceTrigger.event.data.keyAttribute
 
fibaro:debug("ID : ".. ID .." - keyAttribute : ".. Attribute)

 

 

I get the following error:

[DEBUG] 14:34:54: 2019-02-13 14:34:54.683156 [ fatal] Unknown exception: /opt/fibaro/scenes/100.lua:6: attempt to index field 'event' (a nil value)

Lien vers le commentaire
Partager sur d’autres sites

sorry ma fault ;-) @Smart


 

--[[
%% events
124 CentralSceneEvent
--]]


local source = fibaro:getSourceTrigger().event.data;
local ID = source.keyId
local Attribute = source.keyAttribute
 
fibaro:debug("ID : ".. ID .." - keyAttribute : ".. Attribute)

 

Lien vers le commentaire
Partager sur d’autres sites

Le 13/02/2019 à 16:58, pepite a dit :

sorry ma fault ;-) @Smart


 


--[[
%% events
124 CentralSceneEvent
--]]


local source = fibaro:getSourceTrigger().event.data;
local ID = source.keyId
local Attribute = source.keyAttribute
 
fibaro:debug("ID : ".. ID .." - keyAttribute : ".. Attribute)

 

Good morning, the script continues to throw me an error

Lien vers le commentaire
Partager sur d’autres sites

×
×
  • Créer...