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

[APP] Owntracks client for Homey

edited August 2017 in Apps

Owntracks MQTT Client for Homey


Up to now using topics was the main way of identifying users. This is no longer the case. The owntracks app listens to all topcis that begin with owntracks. For MQTT users, the username is retreived automatically from the topic the phone app posts on. So it is important that you use correct usernames.

Also with version 1.5.0 it is also possible to use HTTP. HTTP can be used on its own (without a MQTT broker). The use of a MQTT broker is still possible and has some advantages over the use of HTTP. 

When using HTTP,  you have to add users that are allowed to send events to the owntracks app. To do this, go to the owntracks settings page and go to the second button (Change users). Add the user name that you want to give access by entering the name in the empty field below the already known users. Press the "+" button to add the user.


After you have added the user, the user will show up in the user list and it will have a token generated that is used in the phone app to allow receiving of the events:


You can remove a user by pressing the "-" button. The "#" button can be used to generate a new token when you think the id has been comprimised.

In the app on your phone, you should select HTTP as connection:





Then select HOST:



The URL you have to enter here is as follows:

https://<cloudid>.homey.athom.com/api/app/nl.scanno.owntracks/events/?token=<tokenid from user>

where <cloudid> is the Athom Cloud ID of your homey that you can find in Settings/System.
The tokenid is the id that is generated when you added the user.

Using the Athom Cloud is the easiest way of getting started with owntracks. If you are more skilled you can also directly connect to your Homey by port forwarding. Keep in mind that homey itself does not support TLS/SSL. If you want to have a secured session, you need to use a proxy.

In addtion you can use a MQTT broker:

For setting up a private MQTT broker in the cloud with CloudMQTT see the tutorial below:
Tagged:
«1345

Comments

  • edited July 2017
    Also  in the user settings you can add or remove geofences:


    When the owntracks app receives an event with a geofence is does not know, its automatically added. The main purpose of this is that in the trigger cards you do not need to enter the topic names anymore (When using HTTP you cant even use them because HTTP does not use topics). The new trigger cards (they are already present in the current version of the owntracks client) allow you to just enter user and geofence:






  • Submitted an update of the owntracks app that solves two crashes:
    - a crash when first time the settings are saved
    - a crash when a non json message is received on a subscribed topic
    - updated the mqtt node library to the latest version
  • Hi @MennoVanGrinsven ;

    Nice app. Like to see it working :)
    It crached :(

    Stack trace:

    TypeError: Cannot read property 'end' of null
    at Object.changedSettings (/app.js:367:19)
    at module.exports.fn (/api.js:23:17)
    at /homey-app/manager/api.js:22:34
    at /homey-app/helpers/client.js:1:1013
    at Array.forEach (native)
    at process.<anonymous> (/homey-app/helpers/client.js:1:982)
    at emitTwo (events.js:87:13)
    at process.emit (events.js:172:7)
    at internal/child_process.js:696:12
    at nextTickCallbackWith0Args (node.js:420:9)

    Exit code: 0

    Can you take a look?


  • edited September 2016
    PBaan93 said:
    Hi @MennoVanGrinsven ;

    Nice app. Like to see it working
    It crached

    Stack trace:

    TypeError: Cannot read property 'end' of null
    at Object.changedSettings (/app.js:367:19)
    at module.exports.fn (/api.js:23:17)
    at /homey-app/manager/api.js:22:34
    at /homey-app/helpers/client.js:1:1013
    at Array.forEach (native)
    at process.<anonymous> (/homey-app/helpers/client.js:1:982)
    at emitTwo (events.js:87:13)
    at process.emit (events.js:172:7)
    at internal/child_process.js:696:12
    at nextTickCallbackWith0Args (node.js:420:9)

    Exit code: 0

    Can you take a look?


    Yeah I think I already know what it is. Should add a null check . 
    Should be fixed in version 0.3.7
  • Version 0.3.7 has been published. This should solve the settings crash.
  • Updated! I can save the settings now! Thanks
    Only I noticed in my brokers logs that the homey app opens up a new connection every second, is that ok?
  • PBaan93 said:
    Updated! I can save the settings now! Thanks
    Only I noticed in my brokers logs that the homey app opens up a new connection every second, is that ok?
    I only see a ping requests and response in my Mosquitto log. That is normal. 
  • PBaan93 said:
    Updated! I can save the settings now! Thanks
    Only I noticed in my brokers logs that the homey app opens up a new connection every second, is that ok?
    I only see a ping requests and response in my Mosquitto log. That is normal. 

    Can't reproduce it, idk. It works! Thank you! Nice app, now my thermostat is set when I leave from work ;)
  • PBaan93 said:
    PBaan93 said:
    Updated! I can save the settings now! Thanks
    Only I noticed in my brokers logs that the homey app opens up a new connection every second, is that ok?
    I only see a ping requests and response in my Mosquitto log. That is normal. 

    Can't reproduce it, idk. It works! Thank you! Nice app, now my thermostat is set when I leave from work ;)
    Do  not forget to set the accuracy (in case of location drift) 
  • Could you elaborate more on what settings I need to add to the client to be able to connect to the homey app? I'm using Owntracks on iPhone but have no idea what to enter in the settings page besides broker.hivemq.com for host.
  • Is it also possible to only use the MQTT part? Since the app from Johan Kuster is not developed anymore?
  • edited February 2017
    Yannick said:
    Could you elaborate more on what settings I need to add to the client to be able to connect to the homey app? I'm using Owntracks on iPhone but have no idea what to enter in the settings page besides broker.hivemq.com for host.
    I will see if i can write some stuff down. If you have specific question, please ask.

    vanisher said:
    Is it also possible to only use the MQTT part? Since the app from Johan Kuster is not developed anymore?
    Not yet. I am working on skimming this app down and make a replacement for the app from Johan Kuster.
  • I would love to start using this app. Can somebody help me configure the owntracks iPhone app?
    for instance I don't know what to enter for TrackerID, UserID and Password
  • EvertorNEvertorN Member
    edited February 2017
    The app is not working anymore since the last update (0.5.0). It won't recognize any topics when I try to connect to my private broker: 

    20170228-09:51:20 changedSettings called
    20170228-09:51:20 [object Object]
    20170228-09:51:20 topics:
    20170228-09:51:20 topics:
    20170228-09:51:22 getLogLines called

    Any idea? The OwnTracks app on my android phone is able to reach my endpoint and is still sending updates.
  • EvertorN said:
    The app is not working anymore since the last update (0.5.0). It won't recognize any topics when I try to connect to my private broker: 

    20170228-09:51:20 changedSettings called
    20170228-09:51:20 [object Object]
    20170228-09:51:20 topics:
    20170228-09:51:20 topics:
    20170228-09:51:22 getLogLines called

    Any idea? The OwnTracks app on my android phone is able to reach my endpoint and is still sending updates.

    Weird. Can you disable and then enable  the app?
  • EvertorN said:
    The app is not working anymore since the last update (0.5.0). It won't recognize any topics when I try to connect to my private broker: 

    20170228-09:51:20 changedSettings called
    20170228-09:51:20 [object Object]
    20170228-09:51:20 topics:
    20170228-09:51:20 topics:
    20170228-09:51:22 getLogLines called

    Any idea? The OwnTracks app on my android phone is able to reach my endpoint and is still sending updates.

    Weird. Can you disable and then enable  the app?
    Yea done that, but no luck :(. Even recreated my flows to trigger the topic monitoring but nope
  • EvertorNEvertorN Member
    edited February 2017
    It's working when I subscribe to owntracks/# for fence 'home' but not when I subscribe to owntracks/marvin/sailfish/event for fence 'home'.

    EDIT: Only the flow card 'Receive geofence triggers' works, not entering / leaving.. When I enter owntracks/# as the topic for 'Receive geofence triggers' the log shows the following:

    20170228-11:35:54 state.topic = x topic = owntracks/# state.fence = x geofence = home
    20170228-11:35:54 MQTT client connected
    20170228-11:35:54 Connected Topics: owntracks/#
    20170228-11:35:54 reconnectedClient false
    20170228-11:35:54 waiting owntracks/#
    20170228-11:35:54 OnMessage called
    20170228-11:35:54 received '{"_type":"location","tid":"sh","acc":19,"batt":76,"conn":"m","doze":false,"lat":xxxxxx,"lon":xxxxxx,"tst":1488235828}' on 'owntracks/marvin/sailfish'
  • EvertorN said:
    It's working when I subscribe to owntracks/# for fence 'home' but not when I subscribe to owntracks/marvin/sailfish/event for fence 'home'.

    EDIT: Only the flow card 'Receive geofence triggers' works, not entering / leaving.. When I enter owntracks/# as the topic for 'Receive geofence triggers' the log shows the following:

    20170228-11:35:54 state.topic = x topic = owntracks/# state.fence = x geofence = home
    20170228-11:35:54 MQTT client connected
    20170228-11:35:54 Connected Topics: owntracks/#
    20170228-11:35:54 reconnectedClient false
    20170228-11:35:54 waiting owntracks/#
    20170228-11:35:54 OnMessage called
    20170228-11:35:54 received '{"_type":"location","tid":"sh","acc":19,"batt":76,"conn":"m","doze":false,"lat":xxxxxx,"lon":xxxxxx,"tst":1488235828}' on 'owntracks/marvin/sailfish'
    Did you remove the trigger card and readd the card with the event topic? 

    Because that topic is not registered. Besides that only messages with of type transition can trigger entering/leaving a geopende. 

    If re-adding the event topic works, then I have to  be carefull next time with adding tags to existing trigger cards as they seem to  break existing trigger cards. 

    Sorry about that. 
  • Nah I haven't changed anything. I had initially set it up as /event and it was working perfectly, after the update to 0.5 it stopped working.. What should my full topic be so my cards get triggered again? 

    Thanks for the help 
  • EvertorN said:
    Nah I haven't changed anything. I had initially set it up as /event and it was working perfectly, after the update to 0.5 it stopped working.. What should my full topic be so my cards get triggered again? 

    Thanks for the help 

    Please remove the trigger card and add it again with the same event topic that you used before. 
  • mbalik79mbalik79 Member
    edited February 2017
    Here also the cards don't trigger anymore after the update..Did already made a new flow with new cards, but they would not trigger. I can see in MQTTlens that the messages are coming in...

    geofence binnengekomen -> Nok
    geofence verlaten -> Nok
    ontvang geofence trigger -> Ok


  • mbalik79 said:
    Here also the cards don't trigger anymore after the update..Did already made a new flow with new cards, but they would not trigger. I can see in MQTTlens that the messages are coming in...

    geofence binnengekomen -> Nok
    geofence verlaten -> Nok
    ontvang geofence trigger -> Ok


    Ah so the enter/leave card is working. OK thx
  • mbalik79 said:
    Here also the cards don't trigger anymore after the update..Did already made a new flow with new cards, but they would not trigger. I can see in MQTTlens that the messages are coming in...

    geofence binnengekomen -> Nok
    geofence verlaten -> Nok
    ontvang geofence trigger -> Ok


    Ah so the enter/leave card is working. OK thx
    Sorry did the test again... none of the cards are working.. (think i pressed the test button in the flow-editor, that's why it was working)
  • mbalik79 said:
    mbalik79 said:
    Here also the cards don't trigger anymore after the update..Did already made a new flow with new cards, but they would not trigger. I can see in MQTTlens that the messages are coming in...

    geofence binnengekomen -> Nok
    geofence verlaten -> Nok
    ontvang geofence trigger -> Ok


    Ah so the enter/leave card is working. OK thx
    Sorry did the test again... none of the cards are working.. (think i pressed the test button in the flow-editor, that's why it was working)

    Found a bug.. New version pending approval. 
  • mbalik79 said:
    mbalik79 said:
    Here also the cards don't trigger anymore after the update..Did already made a new flow with new cards, but they would not trigger. I can see in MQTTlens that the messages are coming in...

    geofence binnengekomen -> Nok
    geofence verlaten -> Nok
    ontvang geofence trigger -> Ok


    Ah so the enter/leave card is working. OK thx
    Sorry did the test again... none of the cards are working.. (think i pressed the test button in the flow-editor, that's why it was working)

    Found a bug.. New version pending approval. 
    Great job! Will testing it tonight if new version is approved

  • updated from github. Working fine.
  • posthok said:
    updated from github. Working fine.
    Same here! Thanks @MennoVanGrinsven

  • alles werkt ;-) top
  • Currently there is a new version in the beta channel. The owntracks app has been redesigned internally and the following functional changes have been added:
    - owntracks/#  topic is added by default. 
    - Voice capability added (NL / EN). You can ask "Wat is de locatie van xxx"  or "Waar is xxx"  and homey will tell you the geoFence that person is in.
  • With the new version 1.5.2 you need to enable MQTT. I have added a new setting that is disabled by default. Now that HTTP is introduced, the need to use MQTT is  not mandatory and for most users it is easier to just put in an URL then to create a MQTT broker. 

    Using MQTT has advantages above using HTTP. 
Sign In or Register to comment.