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

Problem with a timer


Question

Posted

Hi,

hope some of you can help me. I wrote a timer script but it do not really run. Sometimes it runs, sometimes not.

Via a virtual module I can set the time in std_heizung and min_heizung. This values are stored as a variable.

heizung_aktiv is the variable which turns the scene on or off.

But when I start the timer the heater (ID 89) don't turn on. What is my mistake?

Has someone an idea?

 

Please login or register to see this code.

 

14 answers to this question

Recommended Posts

  • 0
Posted

What is the trigger for the scene?

  • 0
Posted

@SteMo You need your global ‘trigger’  decleared in the header.

The scene will then start everytime that global changes state.

Then it is the conditions in the scene that determine which state of the global does what action.

—[[

%% autostart

%% properties

%% events

%% globals

heizung_aktiv

—]]

  • 0
Posted
11 hours ago, Jamie mccrostie said:

@SteMo You need your global ‘trigger’  decleared in the header.

The scene will then start everytime that global changes state.

Then it is the conditions in the scene that determine which state of the global does what action.

—[[

%% autostart

%% properties

%% events

%% globals

heizung_aktiv

—]]

 

and remove infinity loop + autostart from header

 

  • 0
  • Inquirer
  • Posted

    many thanks for the support. It seems to run. I will check whether it runs also tomorrow.

    By the way, I do not understand the meaning of

     

    —[[

    %% autostart

    %% properties

    %% events

    %% globals

    heizung_aktiv

    —]]

     

    When I have to use what and what is the infinity loop. Sorry, I am not an expert.

    • 0
    Posted

    The topic has been moved from "

    Please login or register to see this link.

    " to "

    Please login or register to see this link.

    ".

     

    Temat został przeniesiony z "

    Please login or register to see this link.

    " do "

    Please login or register to see this link.

    ".

    • 0
    Posted (edited)
    12 hours ago, SteMo said:

    many thanks for the support. It seems to run. I will check whether it runs also tomorrow.

    By the way, I do not understand the meaning of

     

    —[[

    %% autostart

    %% properties

    %% events

    %% globals

    heizung_aktiv

    —]]

     

    When I have to use what and what is the infinity loop. Sorry, I am not an expert.

    @SteMo

    1/delete  ‘%%autostart’ 

    from your scene header (this will stop the scene from running when HC2 boots up)

    2/ add you global ‘heizung_aktiv’

    under “ %% globals “in scene header

    (this is your scene trigger)

    3/delete “if true do” in your scene (which causes the scene to keep looping forever)

    and replace with “if”.

     

    Then the scene will only trigger with your global state change

    and run once.

    Edited by Jamie mccrostie
    • 0
  • Inquirer
  • Posted

    Hi Jamie,

     

    thank you for this really good explenation, but I have a problem with the

    Quote

     

    3/delete “if true do” in your scene (which causes the scene to keep looping forever)

    and replace with “if”.

     

     

    In my skript I have the

    Please login or register to see this code.

    but this I can't replace with an

    Please login or register to see this code.

    Or is this an misunderstanding?

    • 0
  • Inquirer
  • Posted

    then my script look like this. But it don't run. The trigger do not trigger. What is wrong here. By the way, sometimes it run. I'm really confused.

     

    Please login or register to see this code.

     

    • 0
    Posted

    In my opinion, your question is hard to answer, because the problem is not (yet) very well defined... So you and other forum have a different understanding of how it should work.

     

    Can we try to establish exactly what you are trying to do?

    • When device 89 turns on, do you want to limit the time it stays on to 30 minutes? Or does it not matter if someone turns it on. But then, what should the timer do?
    • If someone turns off device 89, what do you want to do? Turn it back on when heizung_aktiv has a certain value?
    • Does heizung_aktiv simply mean "I want the heating to turn on at Time 1 HH:MM"? So, if time is past HH:MM (so maybe 1 minute later) and you set heizung_aktiv then you want nothing to happen Or, do you mean if heizung_aktiv and time is between Time 1 and Time 2 then always turn on the heater. And if heizung_aktiv changes to 0 during that time period, do you want to turn off the heater?
    • Do you have other scenes that might interact with this one? If so, how do you want them to interact?

    Please note, changing a value in the variables panel does not trigger a scene. If you want to test a scene, triggered by heizung_aktiv, then you'll have to write a second scene or VD and change that variable in that scene.

     

    Also, you have a SUBTLE bug in this line which might not be too import right now but might bite you if you use it in other scenes:

     

    10 hours ago, SteMo said:

    fibaro:sleep(1*60000); -- läuft jede Minute 1 x

     

    You say it runs every minute, but that is not true at all!

     

    It runs for 60000 ms + the time it takes to start and run your scene... Best case, it runs about once every 1.001 minutes but it could be even slower. If your code takes 6 seconds, it runs once every 1.1 minutes. So it might miss (skip) the transition from one minute to the next...

    • 0
  • Inquirer
  • Posted

    Hi,

    I try to explain what I want.

    I have a heater (device 89) which shall turn on at a certain time. After 30 minutes it shall turn off.

    Therefore I created a virtual device (pls. see the attachment) where I can set the time and turn the trigger 'heizung_aktiv' between 2 conditions, 1 and 2. If it's turned to 1 the scene shall start.

    Please login or register to see this code.

    Then the timer starts and compares each minute if whether the requested time is reached.

    Please login or register to see this code.

    After 30 minutes the device 89 shall turn off

    Please login or register to see this code.

    and the trigger change the state back to 2 - off. I do not want that the timer starts again without the manual setting via the virtual device. The timer is for my bathroom heater and I need the heater only if I have to stand up very early in the morning before the central heater starts.

    Please login or register to see this code.

    But the trigger don't run. The skript seems not to start. But why ?

    I hope now it's more understandable.

    Please login or register to see this attachment.

    • 0
  • Inquirer
  • Posted

    Thanks for all your help. In the meantime I could solve my problem. Finally it was really easy. With the virtual device I start the timer scene. And this is the scene:


     

    Please login or register to see this code.

    Thats it.

    • 0
    Posted

    @SteMo I am sorry for the delay. I am glad you found a workaround.

     

    Here is one small thing. If you are editing your scene, do CTRL-A to select all then SHIFT-TAB and the editor will format the code for you. It will be easier to read.

     

     

    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...