Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

cancel a delay timer with fibaro:killScenes


robmac

Question

I have a few delay timers that turn off devices n seconds after turning on.

I currently do this to cancel the timer if switched off within the delay.

It uses 2 scenes. Is there a neater way to do this?

Code from scene 15

Please login or register to see this code.

code from scene 42

Please login or register to see this code.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0
Guest Kuuno

i'd like to know the same thing....

Please login or register to see this image.

/emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

Link to comment
Share on other sites

  • 0

I tried the solution here below, basically put a variable as global and update simultaneously.

The overall mechanism is:

1. Switch on the light only after sunrise and before sunset when the PIR sensor is changing

2. The light will stay ON for 8 mins and gradually will decrease to 0 at the end of 8 mins.

3 In case of further PIR activity the counter will start over from 8 mins.

Maybe the code has still something to improve

_________________________________________________________

(113 is the PIR Sensor)

(86 is the light or led)

Global value is Timer1

--[[

%% properties

113 value

%% globals

--]]

--HERE 2 SCENES ARE POSSIBLE

fibaro:setGlobal("Timer1", "480")

--480 is something you can change = 8 mins

local Countdown = tonumber(fibaro:getGlobalValue("Timer1"))

local Wattled = Countdown/10

--FROM HERE ONWARDS 2 SCENES ARE NOT POSSIBLE

if ((fibaro:countScenes() > 1) or tonumber(fibaro:getValue(86, "value")) > 0)

then fibaro:abort() end;

if os.date("%H:%M", os.time()) > fibaro:getValue(1, "sunsetHour") or

os.date("%H:%M", os.time()) < fibaro:getValue(1, "sunriseHour")then

--switch on only when the sunlight is missing

fibaro:call(86, "turnOn")

--turno on the led RGB

while tonumber(fibaro:getGlobalValue("Timer1"))>0 do

fibaro:sleep(10*1000)

Countdown = tonumber(fibaro:getGlobalValue("Timer1"))

Countdown = Countdown - 10

fibaro:setGlobal("Timer1", Countdown)

Wattled = Countdown/10

fibaro:call(86, "setValue", Wattled)

end

fibaro:call(86, "turnOff")

end

Link to comment
Share on other sites

  • 0

Hi

I have played with countScenes a bit and my experience is that all instances of a scene is killed with fibaro:killScenes(id)

Andreas

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...