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.
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
MennoVanGrinsven
Member
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:
https://forum.athom.com/discussion/2810/use-cloudmqtt-as-a-broker-for-owntracks-or-mqtt-app
@ingmar made a very nice tutorial how to setup Owntracks:
https://forum.athom.com/discussion/2804/setup-homey-with-mqtt-for-location-detection/p1
@ingmar made a very nice tutorial how to setup Owntracks:
https://forum.athom.com/discussion/2804/setup-homey-with-mqtt-for-location-detection/p1
Tagged:
Comments
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:
- 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
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?
Should be fixed in version 0.3.7
Only I noticed in my brokers logs that the homey app opens up a new connection every second, is that ok?
Can't reproduce it, idk. It works! Thank you! Nice app, now my thermostat is set when I leave from work
Not yet. I am working on skimming this app down and make a replacement for the app from Johan Kuster.
for instance I don't know what to enter for TrackerID, UserID and Password
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?
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'
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.
Thanks for the help
Please remove the trigger card and add it again with the same event topic that you used before.
geofence binnengekomen -> Nok
geofence verlaten -> Nok
ontvang geofence trigger -> Ok
Found a bug.. New version pending approval.
- 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.
Using MQTT has advantages above using HTTP.