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

  • Topic Author
  • Posted (edited)
    4 hours ago, jompa68 said:

    All sorted now. In my HomeTable i define scene not scenes that are setup with iOSLocator.
    Added scenes and moved iOSLocator parts to that and all working as we want when we set

    Please login or register to see this code.

    Thanks again.

    Now time for 1000m swimming before go to work, have a nice morning.

    Cool, have you added the place for the swimming pool to iOSLocator? :-)

     

    If you have any tips how to make these services easier to setup let me know, I have some ideas about other services too, and it would be nice to make them as easy as possible to install.

    I guess that many of the scenes people have developed in this community, like notifiers, loggers, etc that use fibaro:startScene({...}) can just be used as is. However, if based on the EventRunner framework we can easily both send and receive events from them - like subroutines that can return values. 

    In the iOSLocator example it was one way as the iOSLocator only sent events to the client scene. However, iOSLocator also listen to the event  '{type= 'getLocations'} and responds with resending all locations it is aware of to the asking scene. That means that the client scene(s) when they start up can ask the iOSLocator for all the known locations and get a response immediately. Otherwise the client need to wait until people move to get an update (if iOSLocator already knows where everyone is it will only send events when someone moves). Ex. Client rule:

    Please login or register to see this code.

    ..and the scene will immediately start to receive #location events for each person the iOSLocator knows about. This is very convenient if the client scene needs to restart. However, if the whole HC2 is restarted it is a good chance that the iOSLocator has not got any updates yet, and it may take some minutes.
     

     

    Edited by jgab
    misspelled getLocations
    Posted (edited)
    53 minutes ago, jgab said:

    Cool, have you added the place for the swimming pool to iOSLocator?

    Haha, i will add that and send some updates to my HC2, perhaps set a RGB bulb to a fancy color :D

     

    53 minutes ago, jgab said:

    Rule.eval("#autostart => iOSLocator:start=#geLocations") Rule.eval("#other => iOSLocator:start=#geLocations")

     

    Should be

    Please login or register to see this code.

     

    Edited by jompa68
  • Topic Author
  • Posted
    37 minutes ago, jompa68 said:

    Haha, i will add that and send some updates to my HC2, perhaps set a RGB bulb to a fancy color :D

     

     

    Should be

    Please login or register to see this code.

     

    Thanks, fixed.

    Posted
    21 hours ago, jgab said:

    "dist":0.8,

    Is this in kilometers?

  • Topic Author
  • Posted (edited)
    2 minutes ago, jompa68 said:

    Is this in kilometers?

    yes. sometimes iCloud can think that you are wandering around +/-100m even when you are standing still so it is good to have a margin - 200-400m radius to a place. Maybe in the future when we get better GPSes...

    Edited by jgab
    Posted

    Just a cosmetic thing.

    Please login or register to see this code.

    When using swedish letter ÅÄÖ in name it gives this

     

    Please login or register to see this image.

    /monthly_2018_10/Untitled.png.980c075b160bb403465ecc227035c235.png" alt="Untitled.png.980c075b160bb403465ecc227035c235.png" />

  • Topic Author
  • Posted (edited)

    Yes, I know about this. Something happens when strings with foreign chars are sent as arguments to fibaro:start between scenes.... I could get around it by doing an urlencode/urldecode on the payload... but I was kind of hoping that it would get fixed.... anyway, will add it in next push.

    20 hours ago, jgab said:

    Yes, I know about this. Something happens when strings with foreign chars are sent as arguments to fibaro:start between scenes.... I could get around it by doing an urlencode/urldecode on the payload... but I was kind of hoping that it would get fixed.... anyway, will add it in next push.

    Ok, I have pushed a version that urlencode the payload when doing postRemote, and urldecode when receiving events. (EventRunner.lua and iOSLocator.lua)

     

    Edited by jgab
    Posted
    19 hours ago, jgab said:

    Ok, I have pushed a version that urlencode the payload when doing postRemote, and urlencode when receiving events. (EventRunner.lua and iOSLocator.lua)

    Implemented and urlencode is ok now.

    Thank you.

    Posted

    This morning i got this error in iOSLocator.lua

     

    Please login or register to see this code.

     

  • Topic Author
  • Posted

    Ooops. have had the locator run for months and haven't seen that error before. Anyway, is the version of iOSLocator identical with the one on GitHub? i.e. is line 166 equal to "     ["X-Client-Name"]= "iPad"," ?

    Worst case, the iCloud service returns something strange that the net.HTTPClient() fails on and there is no way to capture that error, and it's crashing the iOSLocator... If that is the case, we can monitor the iOSLocator with a 'ping' routine' and restart it if it crashes. 

    Let me check some more when I come home.

    Posted

    Yes looks the same..

    Please login or register to see this code.

    A restart of scene did solve the problem.

  • Topic Author
  • Posted (edited)
    On 10/25/2018 at 2:05 PM, jompa68 said:

    Yes looks the same..

    Please login or register to see this code.

    A restart of scene did solve the problem.

    If this happens again, add this to your scene - preferably at the end of your function main() ... end It's ok to mix script rules with Lua event rules.

    Please login or register to see this code.

    In scenesToWatch it should list the scene ID of the iOSLocator scene. You main scene will then ping it every minute and if it is not running it will restart the iOSLocator scene.

    In iOSLocator there has to be code to respond to the ping, something I added to the iOSLocator I just pushed.

    Please login or register to see this code.

    If there is a scene based on the full EventFramework, the pong routine should look like.

    Please login or register to see this code.

     

    Edited by jgab
    Posted (edited)

    In watch scene there are some errors - undefined variables e.i.

    1. clientsToWatch vs. scenesToWatch , 

    2. timeoutMinutes, 

    3. type='watchScene'  vs. type='watch',

    4. cancel, ...

    etc. - could you please check your code?

     

    and also check code bellow - in my case event.type is nil - I try to use it in standard EventRunner scene

    Please login or register to see this code.

    my code:

      Event.event({type='%%PING%%'}, 
        function(env)
          Event.postRemote(env.event._from,{type='%%PONG%%'})
        end)

     

    Edited by petrkl12
  • Topic Author
  • Posted (edited)
    3 hours ago, petrkl12 said:

    In watch scene there are some errors - undefined variables e.i.

    1. clientsToWatch vs. scenesToWatch , 

    2. timeoutMinutes, 

    3. type='watchScene'  vs. type='watch',

    4. cancel, ...

    etc. - could you please check your code?

     

    and also check code bellow - in my case event.type is nil - I try to use it in standard EventRunner scene

    Please login or register to see this code.

    my code:

      Event.event({type='%%PING%%'}, 
        function(env)
          Event.postRemote(env.event._from,{type='%%PONG%%'})
        end)

     

    Thanks, it was a complete mess. I corrected the previous post (I hope).

    Yes, the pong code for iOSLocator looks like that because it's based on the EventRunnerLite framework that doesn't have the Event.* functions.

    Yes, your code is almost correct (you are getting it! :-) ). However, 

    Please login or register to see this code.

    We reuse the event we get. This way the ping client can send arguments with the ping that it will get back. In the keep alive example above the ping routine get back the scene ID and ref so it can do another watch on the same scene.

    Also pushed a new version of iOSLocator that sends back the ping arguments.

    Edited by jgab
    Posted

     

    13 hours ago, jgab said:

    If there is a scene based on the full EventFramework, the pong routine should look like.

    Please login or register to see this code.

    I use that, so should i add this to iOSLocator scene?

  • Topic Author
  • Posted
    3 minutes ago, jompa68 said:

     

    I use that, so should i add this to iOSLocator scene?

    No, it's the 

    Please login or register to see this code.

    because it's based on the EventRunnerLite framework.. However, I already added it to a version I pushed this morning. If you modified your own version of iOSLocator it could be easier to just add the above line.

    Posted

    Ok, roger that!

  • Topic Author
  • Posted

    Ok, I changed the ping/pong code again.

     

    The reason is that the ref returned from the offline version of setTimeout (sed by postRemote) contains stuff that can not be json.encoded... It doesn't really affect code on the HC2 but I like the same code to be able to run online as well as offline. Anyway, the result is that the client can't send the ref in the ping but needs to keep it in a separate table. I may change the offline setTimeout to be more compliant in the future but i's some more work...

    Posted

    I have tried your scene it looks that it's still doesn't work fully (restart scene).

    I have stoped manualy one of watch scene and I can see this message in that scene every minute:  "Aborting: Server not started yet" and scene is not starting ...

    Posted

    Another question:

     

    I have a lot of rules that use timers:

     rule("@@hh:mm") 

    it means that after restart all that rules run in one time at the beginning - impact is big load i.e. during Fibaro restart or scene restart

     

    Is there possibility to add some parameter that first run will be after end of first interval?

     

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