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


Recommended Posts

Lets see if i got this right

Please login or register to see this code.

Rule #1 will pressButton on my VD when i arrive at home and it is dark

Rule #2 same as #1 except user

Rule #3 will pressButton 2 after 15min if Label1 is "ON"

 

All true @jgab ?

Share this post


Link to post
Share on other sites
  • Topic Author
  • 40 minutes ago, jompa68 said:

    Lets see if i got this right

    Please login or register to see this code.

    Rule #1 will pressButton on my VD when i arrive at home and it is dark

    Rule #2 same as #1 except user

    Rule #3 will pressButton 2 after 15min if Label1 is "ON"

     

    All true @jgab ?

    Yes, but "event triggers" can't have any other tests on the left hand side (it may change in the future), so you move the darkness test to the right.

    Please login or register to see this code.

    Ok, but if you are already home and Mona comes home and it's dark it still presses the button? That's why I had the logic that when the first person came home it sent #presence{state='home'} and one could trigger on that.

    <exprA> & <exprB> is like an IF <exprA> then  <exprB>...

    Third rule looks ok.

    Share this post


    Link to post
    Share on other sites

    @jgab do you know how often phone location update to apple servers?
    It did take almost 5 min before it did update when i did arrive to home, this mean the lights did not turn on like i want.
    Have you notice the same behavior?

     

    Update

    I notice that i was not logged on to "find my iPhone" app, perhaps it was that?

    Edited by jompa68

    Share this post


    Link to post
    Share on other sites
  • Topic Author
  • 18 minutes ago, jompa68 said:

    @jgab do you know how often phone location update to apple servers?
    It did take almost 5 min before it did update when i did arrive to home, this mean the lights did not turn on like i want.
    Have you notice the same behavior?

    Well, it seems like they update every minute (when you run the FindFriends app on the phone it updates every minute).

    Having said that, I have seen a lot of varying update intervals. 

    The loop in the iOSLocator loops through the people/family members checking one person each minute, so if you are 4 person it check each person every 4 minutes, are you 2, it becomes every second minute. You can try to lower that interval (line 222 in iOSLocator), to check more often. However, too frequent checks to the server (10''s per minute for the same person) seems to make Apple block you for a while... I had that bug once :-) 

    You can also experiment with the radius to the home so iOSLocator detects that you are close to home earlier. I used to have a radius of 800m to detect if people were home or not and start/stop the alarm, and it worked 9/10 times (I usually arrived by car). Now I just moved so I don't have an alarm yet.

    Share this post


    Link to post
    Share on other sites
    16 hours ago, jgab said:

    You can try to lower that interval (line 222 in iOSLocator), to check more often.

     

    This line

    Please login or register to see this code.

    to

    Please login or register to see this code.

    :?:

    Share this post


    Link to post
    Share on other sites
  • Topic Author
  • 26 minutes ago, jompa68 said:

     

    This line

    Please login or register to see this code.

    to

    Please login or register to see this code.

    :?:

    Yes.

    Do you have a large enough radius defining “home”? 

    Share this post


    Link to post
    Share on other sites
  • Topic Author
  • 7 minutes ago, jompa68 said:

    Yes i think so. 

    Please login or register to see this code.

     

    Yes, that should work.

    Share this post


    Link to post
    Share on other sites

    @jgab

     

    is ti possible to check variable that wasn't change for some period of time? (I know it will generate error but maybe you have some simple solution in your framework)

     

      rule("for(00:02, test==10) => log('Variable test had 2 minutes value 10')")
     

    Share this post


    Link to post
    Share on other sites
  • Topic Author
  • 42 minutes ago, petrkl12 said:

    @jgab

     

    is ti possible to check variable that wasn't change for some period of time? (I know it will generate error but maybe you have some simple solution in your framework)

     

      rule("for(00:02, test==10) => log('Variable test had 2 minutes value 10')")
     

    No, it only works for fibaro globals now i.e. $x. I'm afraid that triggering on local variables could cause a lot of strange unintended behaviours and even performance issues... I have to trigger all rules where the local is used, ex.

    Please login or register to see this code.

    That last expression would trigger the first two rules (and the second would log)...

    To let this loose on variables in general feels a bit dangerous...

    Maybe some special kind of trigger variable, so one doesn't need to use a fibaro global. 

    Let me think about it.

    Now one could do.

    Please login or register to see this code.

     

    Do you have a specific use case? The solution can differ a lot depending what it is you want to achieve.

    Edited by jgab

    Share this post


    Link to post
    Share on other sites

    OK, I know it will be complicated

    but what about to use for example special type of value: $$ and trigger only this variables

     

    Please login or register to see this code.

     

     

    Edited by petrkl12

    Share this post


    Link to post
    Share on other sites
  • Topic Author
  • 1 hour ago, petrkl12 said:

    OK, I know it will be complicated

    but what about to use for example special type of value: $$ and trigger only this variables

     

    Please login or register to see this code.

     

     

    Ok, pushed a new version that triggers on variables starting with an underscore.

    Please login or register to see this code.

    Whenever the value of a variable starting with underscore is changed an event {type='variable, name=<name>, value=<value>} is posted.

    So, it works ok for now but I will optimise it a bit how these events are dispatched in the future.

    • Like 1

    Share this post


    Link to post
    Share on other sites
  • Topic Author
  • With great power comes great responsibility.

    Please login or register to see this code.

    Will create an infinite loop. (that's why there shouldn't be any side effects on the left hand side of a rule)

    On the other hand

    Please login or register to see this code.

    is a rather elegant loop construct.

     

    Edited by jgab

    Share this post


    Link to post
    Share on other sites

    OK, Thanks for explanation of potential issue

    BUT I think that it has really huge potential how to use it!

     

    Share this post


    Link to post
    Share on other sites
  • Topic Author
  • 13 minutes ago, petrkl12 said:

    OK, Thanks for explanation of potential issue

    BUT I think that it has really huge potential how to use it!

     

    Ok,

    I just pushed a new version where there is a script compiler error if a trigger variable or a fibaro global is assigned in the rule header (left hand side).

    e.g.

    Please login or register to see this code.

    A subtlety is also that trigger variables will not trigger if their values changes (from whatever old value they held). That is more consistent on how fibaro's own global variables behave. 

    e.g.

    Please login or register to see this code.

    will not create an infinite loop.

    Edited by jgab

    Share this post


    Link to post
    Share on other sites
  • Topic Author
  • Made some changes in EventScript syntax. New version pushed.

    CentralSceneEvent is triggered like this.

    Please login or register to see this code.

    What's happening behind the scene is that an event of type

    {type='event', event={type=<eventType>, data={...}}}

    is internally reposted as {type='property', deviceID=<ID>, propertyName=<eventType>, data=data}.

    I have to know what <eventType> it is to be able to pick up the <ID> and insert it in the new event (seems to be no consistency in naming event data fields...).

    So for the moment it can only deal with CentralSceneEvent and AccessControlEvent. If you know about other types of event I can easily add them.

    Anyway, it results in that I can easier use the ':property' syntax like in the example. It also means that the event in 'env.event' has the structure {type='property', deviceID=<ID>, propertyName=<eventType>, data=data}

     

    AccessControlEvent is similar.

    Please login or register to see this code.

    Both the ':central' and ':access' returns the 'data' field of the event.

    SceneActivation is still accessed as 55:scene

    Edited by jgab

    Share this post


    Link to post
    Share on other sites
  • Topic Author
  • 1 minute ago, petrkl12 said:

    @jgab

    Thanks for adding that features.

     

    How to use in :central for example long press of button?

    Please login or register to see this code.

     

    Share this post


    Link to post
    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
    Reply to this topic...

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