This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.

The Homey Community has been moved to https://community.athom.com.

This forum is now read-only for archive purposes.

Setup Homey with MQTT for location detection

2456711

Comments

  • webwalserwebwalser Member
    edited February 2017
    hi all

    how can i see mine android owntrack app is connected with mqtt client?

    between websocket-client and homey i have a connection. 
    between mqtt lens and homey i have a connection.
    but if i send a message from homey to one of these two i don"t see the text

    on my owntrack app i have my external ip adress from mine nas with port 1883
    en mqtt lens and homy and websockets-client i have mine internal ip adress
  • EternityEternity Member
    edited February 2017
    Sorry for the screen  shot in a separate post..

    I manged to setup up and configure my Syno and my Android phone and established a connection succesfully (hey, I needed to edit the config file on my Syno... that was tricky).

    Now it seems that my Homey doesn't allow to install the App ???
    I am on version firmware 1.1.9

    What to do 
  • If MQTT package is not starting:

    1) ssh to your synology and log in with your normal account

    2) execute: cd /var/packages/mosquitto/scripts

    3) sudo vi start-stop-status (you need to be root, hence the sudo), give your admin password when requested

    4) using vi, comment the line which declares the USER such that it reads:

    #USER="mosquitto"

    and you need to ad 

    listener 9001
    listener 1883
    websockets 

    to mosquitto.conf

  • ingmar said:
    EvertorN said:
    ingmar said:
    EvertorN said:
    My flows are not triggered. The log says it's trying to trigger an event for 'undefined':

    20170225-10:35:48 Accuracy is within limits
    20170225-10:35:48 Trigger enter card for undefined
    20170225-10:35:48 Trigger generic card for undefined
    20170225-10:35:48 state.topic = owntracks/marvin/sailfish/event topic = owntracks/marvin/sailfish/event state.fence = undefined geofence = Home

    Any idea? I have configured my flow with
    owntracks/marvin/sailfish/event and Home
    Sometimes disabling and enabling the homey OwnTracks app works. Also check if Home is really Home in your app instead of home. Mind case sensitivity
    Changed it to 'home' in the flows and on my phone and restarted the app, still no luck. 20170225-10:58:47 waiting owntracks/marvin/sailfish/event 20170225-11:00:31 getLogLines called 20170225-11:02:32 OnMessage called 20170225-11:02:32 received '{"_type":"transition","tid":"sh","acc":19.2948,"event":"enter","lat":-37.86688484,"lon":145.00134072,"tst":1487981023,"wtst":1487977183,"t":"c"}' on 'owntracks/marvin/sailfish/event' 20170225-11:02:32 Accuracy is within limits 20170225-11:02:32 Trigger enter card for undefined 20170225-11:02:32 Trigger generic card for undefined Any idea? When I check my phone (android) > status it says 'not available' for 'Endpoint state message', could this be the cause?
    I don't see your region in the message, that's why you get undefined : '{"_type":"transition","tid":"sh","acc":19.2948,"event":"enter","lat":-37.86688484,"lon":145.00134072,"tst":1487981023,"wtst":1487977183,"t":"c"}' on 'owntracks/marvin/sailfish/event'

    i suggest to remove the region and recreate it. 

    Recreating the region did the trick, works like a charm now. Cheers mate!
  • Eternity said:
    Sorry for the screen  shot in a separate post..

    I manged to setup up and configure my Syno and my Android phone and established a connection succesfully (hey, I needed to edit the config file on my Syno... that was tricky).

    Now it seems that my Homey doesn't allow to install the App ???
    I am on version firmware 1.1.9

    What to do 
    You need to install the owntracks app, not musquitto
  • @ingmar
    I edited the app.json file in the zip:

    "compatibility": "1.x"    =>     "compatibility": "1.x.x"

    and was able to install it. But, I seem to have to install a different App om Homey ;-)

    Thanks for pointing me in the right direction!
  • YannickYannick Member
    edited February 2017
    Just ordered a cheap 8 euro iBeacon on banggood.com. How cool would it be if the iBeacon would message my iPhone (owntracks) which would then connect to the CloudMqtt which would then be picked up by Homey which would then send a message to my Vera which would then connect to my Yale z-wave lock to open the door if I'm nearby.
    Only 6 points of failure :smiley:
  • I have installed the Homey Owntracks App and removed the Mosquitto App  and it seems to work

    Recap:
    - installed Mosquitto on my Synology NAS, edited the the config file
    - installed Owntracks App on my Android phone, set a region and set the Syno MQTT server
    - installed Owntracks on my Homey, configured it

    and now I see log entries :-)
  • Eternity said:
    @ingmar
    I edited the app.json file in the zip:

    "compatibility": "1.x"    =>     "compatibility": "1.x.x"

    and was able to install it. But, I seem to have to install a different App om Homey ;-)

    Thanks for pointing me in the right direction!

    you're welcome ;-)
  • For the people who do not want to host their own MQTT broker:
    https://forum.athom.com/discussion/2810/use-cloudmqtt-as-a-broker-for-owntracks-or-mqtt-app


    nice
  • ingmar said:
    Great work! Thanks for writing this! 


    You're welcome.

    If you have any suggestions for the app, let me know. I have some new stuff in the develop branch like reverse geo lookup and user/location table. Idea was to be able to ask homey for the location of user and that homey responds with adress or geo fence name. 

    But did not find the time to complete that (the interaction with homey) 

    What might be interesting is adding some extra functionality on the iBeacon like distance measurement. Currently the Owntracks app sees my iBeacon, but as the beacon is very strong it is currently not suitable for e.g. room detection. I don't know if you get that information ?
  • ingmar said:

    What might be interesting is adding some extra functionality on the iBeacon like distance measurement. Currently the Owntracks app sees my iBeacon, but as the beacon is very strong it is currently not suitable for e.g. room detection. I don't know if you get that information ?
    Most iBeacons have the option to configure the transmission power.
    Also there is a separte json message sent when you enable "beacon ranging" (iOS only) which is capable of determining the distance to a beacon. Drains phone battery though. See: http://owntracks.org/booklet/tech/json/#_typebeacon
  • Yannick said:
    ingmar said:

    What might be interesting is adding some extra functionality on the iBeacon like distance measurement. Currently the Owntracks app sees my iBeacon, but as the beacon is very strong it is currently not suitable for e.g. room detection. I don't know if you get that information ?
    Most iBeacons have the option to configure the transmission power.
    Also there is a separte json message sent when you enable "beacon ranging" (iOS only) which is capable of determining the distance to a beacon. Drains phone battery though. See: http://owntracks.org/booklet/tech/json/#_typebeacon
    Yannick said:
    ingmar said:

    What might be interesting is adding some extra functionality on the iBeacon like distance measurement. Currently the Owntracks app sees my iBeacon, but as the beacon is very strong it is currently not suitable for e.g. room detection. I don't know if you get that information ?
    Most iBeacons have the option to configure the transmission power.
    Also there is a separte json message sent when you enable "beacon ranging" (iOS only) which is capable of determining the distance to a beacon. Drains phone battery though. See: http://owntracks.org/booklet/tech/json/#_typebeacon
    Ok, then it would be great to have the message with type beacon being added to the app
    {
            "_type":"beacon",
            "uuid":"CA271EAE-5FA8-4E80-8F08-2A302A95A959",
            "major":1,
            "minor":1,
            "tst": 1399028969,
            "acc":n,
            "rssi":n,
            "prox":n,
    }

    @MennoVanGrinsven, is that something you can do in a new release?


  • ingmar said:
    Yannick said:
    ingmar said:

    What might be interesting is adding some extra functionality on the iBeacon like distance measurement. Currently the Owntracks app sees my iBeacon, but as the beacon is very strong it is currently not suitable for e.g. room detection. I don't know if you get that information ?
    Most iBeacons have the option to configure the transmission power.
    Also there is a separte json message sent when you enable "beacon ranging" (iOS only) which is capable of determining the distance to a beacon. Drains phone battery though. See: http://owntracks.org/booklet/tech/json/#_typebeacon
    Yannick said:
    ingmar said:

    What might be interesting is adding some extra functionality on the iBeacon like distance measurement. Currently the Owntracks app sees my iBeacon, but as the beacon is very strong it is currently not suitable for e.g. room detection. I don't know if you get that information ?
    Most iBeacons have the option to configure the transmission power.
    Also there is a separte json message sent when you enable "beacon ranging" (iOS only) which is capable of determining the distance to a beacon. Drains phone battery though. See: http://owntracks.org/booklet/tech/json/#_typebeacon
    Ok, then it would be great to have the message with type beacon being added to the app
    {
            "_type":"beacon",
            "uuid":"CA271EAE-5FA8-4E80-8F08-2A302A95A959",
            "major":1,
            "minor":1,
            "tst": 1399028969,
            "acc":n,
            "rssi":n,
            "prox":n,
    }

    @MennoVanGrinsven, is that something you can do in a new release?


    It can be added. It is just another JSON message and i already use the _type field for message type detection.
    Only problem is that i do not own an iOS device so no way that i can test any of this.

    But the question is what do you want to do with the info ?
  • edited February 2017
    @ingmar
    https://github.com/scanno/nl.scanno.owntracks/tree/beta

    Added the beacon message and contents is displayed in log. As i cannot test this, it is up to you to see if it works :)



    based on the "test" message in the documentation, above shows it working (correctly parsed).
  • @ingmar
    https://github.com/scanno/nl.scanno.owntracks/tree/beta

    Added the beacon message and contents is displayed in log. As i cannot test this, it is up to you to see if it works :)



    based on the "test" message in the documentation, above shows it working (correctly parsed).
    Thanks, will look into it tomorrow.
  • @ingmar
    You know that the owntracks app supports wildcards in topics. So if you have a generic geofence name for home, you can create a trigger card with topic owntracks/+/+/event and as geofence home, then it will trigger for everyone that enters or leaves the fence home. 
  • @ingmar
    You know that the owntracks app supports wildcards in topics. So if you have a generic geofence name for home, you can create a trigger card with topic owntracks/+/+/event and as geofence home, then it will trigger for everyone that enters or leaves the fence home. 
    Ok good to know to replace the last plus with "home", but I have to specify the first plus to differentiate between users, right?
  • ingmar said:
    @ingmar
    You know that the owntracks app supports wildcards in topics. So if you have a generic geofence name for home, you can create a trigger card with topic owntracks/+/+/event and as geofence home, then it will trigger for everyone that enters or leaves the fence home. 
    Ok good to know to replace the last plus with "home", but I have to specify the first plus to differentiate between users, right?


    The first + is user, the second + is device
    So if you have more phones you use owntracks/ingmar/+/event as topic. The + can be any value. So if you have a device with device id=nexus, owntracks app will receive a message on topic owntracks/ingmar/nexus/event
    You can see that in the log when the app is matching the topics it is listening to. 

    The geofence name is part of the json message it receives. 

    So if you use a topic like owntracks/+/+/event in the trigger card, it will trigger on:
    owntracks/ingmar/nexus/event
    owntracks/menno/pixel/event

    And if you use the same geofence name in the owntracks apps on the phones of the persons in your household, then it will trigger. 
  • ingmar said:
    @ingmar
    You know that the owntracks app supports wildcards in topics. So if you have a generic geofence name for home, you can create a trigger card with topic owntracks/+/+/event and as geofence home, then it will trigger for everyone that enters or leaves the fence home. 
    Ok good to know to replace the last plus with "home", but I have to specify the first plus to differentiate between users, right?


    The first + is user, the second + is device
    So if you have more phones you use owntracks/ingmar/+/event as topic. The + can be any value. So if you have a device with device id=nexus, owntracks app will receive a message on topic owntracks/ingmar/nexus/event
    You can see that in the log when the app is matching the topics it is listening to. 

    The geofence name is part of the json message it receives. 

    So if you use a topic like owntracks/+/+/event in the trigger card, it will trigger on:
    owntracks/ingmar/nexus/event
    owntracks/menno/pixel/event

    And if you use the same geofence name in the owntracks apps on the phones of the persons in your household, then it will trigger. 

    ok, so in a nutshell, let's say I have 10 household members, I can just make one flow instead of a flow per person?
    I can get the ingmar/nexus or menno/pixel somehow and connect them to a global variable as I am doing now?

  • edited February 2017
    @Ingmar almost <span>:smile:</span>

    I already have the users in an array, so I can give the userid back as tag so it can be used in something like better logic. 

    Hmm that way we can even get rid of the need to enter a topic. 
  • ingmaringmar Member
    edited February 2017
    @Ingmar almost <span>:smile:</span>

    I already have the users in an array, so I can give the userid back as tag so it can be used in something like better logic. 

    Hmm that way we can even get rid of the need to enter a topic. 
    would be great if you just good provide tags for user and/or device, the name of the geofence. I think the event you have now like enter and leave geofence are good. Is that achievable?

    And if somehow you could also add see if it's a geofence based on latlon or iBeacon (including the proximity http://owntracks.org/booklet/tech/json/#_typebeacon), that would be awesome!

  • ingmar said:
    @Ingmar almost <span>:smile:</span>

    I already have the users in an array, so I can give the userid back as tag so it can be used in something like better logic. 

    Hmm that way we can even get rid of the need to enter a topic. 
    would be great if you just good provide tags for user and/or device, the name of the geofence. I think the event you have now like enter and leave geofence are good. Is that achievable?

    And if somehow you could also add see if it's a geofence based on latlon or iBeacon (including the proximity http://owntracks.org/booklet/tech/json/#_typebeacon), that would be awesome!


    prox The relative distance to the beacon where n indicates
    • 0 = the proximity of the beacon could not be determined.
    • 1 = the beacon is in the user’s immediate vicinity.
    • 2 = the beacon is relatively close to the user.
    • 3 = the beacon is far away."
  • edited February 2017
    @ingmar
    cool it is working 



    Created a tag "Gebruiker" and set a variable 



    you get the variable menno with value enter (or leave)



    You know that when you enable "extended data" you can have homey tell you when to recharge your battery .....
  • The iBeacon proximity is a bit hard. First it is iOS dependent. Second the beacon message is a separate message. That means I have to store received messages per user. The question also is how to relate the beacon messages to a transition message. 
  • All I get in the log is this:
    20170226-18:04:39 changedSettings called
    20170226-18:04:39 [object Object]
    20170226-18:04:39 topics:
    20170226-18:04:39 topics:
    20170226-18:04:42 getLogLines called

    The Owntracks app on Android says I'm connected though, what am I doing wrong? :)
  • The iBeacon proximity is a bit hard. First it is iOS dependent. Second the beacon message is a separate message. That means I have to store received messages per user. The question also is how to relate the beacon messages to a transition message. 
    Let me get back about this and yes, it's a iOS only thing ;-)
  • @ingmar
    cool it is working 



    Created a tag "Gebruiker" and set a variable 



    you get the variable menno with value enter (or leave)



    You know that when you enable "extended data" you can have homey tell you when to recharge your battery .....
    Looks great, but will it still be usable as my tutorial? So knowing who is coming home and leaving. Based on that doing some some logic determining if everybody left the house?

    As you are really enthusiastic and quick in developing new stuff, we might go some steps further. I am thinking of specifying a household, so adding some users and keeping track if they are or aren't in the home geofence. The users specified must be the same ids as in the app on iOS/android as well as the home geofence. Based on that you could create a condition someone home, everybody home etc etc. Is this something you want to work out with me? :-)
Sign In or Register to comment.