Anyone integrated tile tracker into OH3?

Hi everyone,

I would like to integrate my tile PRO into openhab 3, but I am not familiar enough with python to use this:

So, just in case someone here made use of pytile (or could provide information to integrate tiles into OH another way), I would greatly appreciate some help.
Thanks in advance.

If you don’t know python at all, it’ll be hard! :wink:
I don’t have a tile tracker unfortunately, but you could easily go into the code and add some integration to openHAB using either REST API or MQTT to update your OH3 items with the properties - provided you understand at least a bit of (python) programming… :wink:

I know, but I am willing to learn.

I am using pybotvac to retrieve the last map of my neato robot, but that’s just executing the script.
pytile seems to be more difficult, so I need to try.

I will post my progress here and would still be open for “accelerator”-support :wink:

1 Like

Don’t they work with the bluetooth binding?

Thanks for the suggestion.

I used the BT binding (FlowerCare), but was not really happy with it.
Furthermore it does not fit my needs:
Because there is some inofficial API to retrieve the location of the tile (community location), this is what I would like to make use of for geofencing (and not presence detection in BT range only).

HA!
I am able to retrieve the location with the python stuff and created the following script:

#!/usr/bin/python3
import asyncio
from aiohttp import ClientSession
from pytile import async_login

email    = 'me@you.com'
password = 'geheim'
#Rucksack uuid = xxx
async def main() -> None:
    """Run!"""
    async with ClientSession() as session:
        api = await async_login(email, password, session)
        tiles = await api.async_get_tiles()
        for tile_uuid, tile in tiles.items():
            print(tile.latitude,tile.longitude)
            if tile.uuid == "xxx":
                break

asyncio.run(main())

As I mentioned already, I am not familiar with python (yet) and would like to return the first result only (the second one is my iphone I already read using icloud binding).
So, if someone has a suggestion to get rid of the pathetic for loop with break, I am more than happy to hear about it. :slight_smile:

Open: Read the location using REGEX into a location item.

if it works - it works! small steps.
so, the easiest part would be to use the os-capabilities and start a curl to send your information to openHAB via REST API:

...
import os
...

    os.system('curl --header "Content-Type: text/plain" --request PUT --data "' + str(VALUE) + '" http://YOUROPENHAB:8080/rest/items/' + str(ITEMNAME) + '/state')
...

what this does is simply invoke a shell and put the command in it, in this case it’s a curl with the PUT option to your openHAB REST API.

later on, you can switch to either:

I don’t know, what you mean by that, as I don’t know the tiles-API but I see “tile.latitude and tile.longitude”, I assume you already have all information on hand to just add them together like this - provided the API response is in decimal degrees:

tilePosition = tile.latitude+", "+tile.longitude

nevertheless, Regex is a cool thing, so here’s some tutorial on that:

Thank you for your guidance.

I actually (still) use the old DSL rules so I created a rule based on another rule running a script and “digest” it with REGEX.

However, I did not think about using the REST API (and never did before), so this might be a good way to go, too.

Once I have my rule up and running, I will check it out.

Of course I will update this thread with my rule soon as well.

Again, thank you for your help.

ok. got it. you just mentioned the two main ways to incorporate Data into openHAB:

  1. using a rule within OH to execute a commandline and use the output
  2. using a script/program/… to execute on some machine, which sends the data to OH (via REST or MQTT)

ad 1
this one is limited to scripts/programs/… available on the OS running openHAB and of course you have to handle the output, if it’s complicated

ad 2
every machine capable of reaching either your openHAB (REST) or your broker (I’d recommend running the MQTT broker not on the same machine as your openHAB) can send data to your openHAB

that being said:
my example from earlier still works, if you combine lng and lat you can use it in your existing DSL rule and update your position item with the output.

Thank you for the summary.
That totally makes sense.
I actually used mosquitto in the past (for gps tracking), but replaced it with icloud.
However setting up mqtt is not a big deal and I will consider it.

Most of the setups here use mqtt on the same host as OH (mine definitely) and I assume it’s the “normal” use case.
So, why do you recommend to run mqtt separately?

ok, my openHAB installation is quite big (around 1.000 items, all sorts of bindings, rules …), so I want to have as much load and parallel deamons off of my openHAB Raspberry Pi.
As I use Synlogy as NAS, it serves as persistance (MariaDB), MQTT Broker (mosquitto), backup server, …

tl:>dr;
My openHAB Pi has more perfomance - and stability - dedicated for solely running openHAB and nothing else.

Got it - thanks.
I have 782 items and use 25 bindings, so it’s reasonably large as well.
However, since a few weeks I run OH on a NUC:

and I am very happy about it so far.
That being said - performance is not the issue of my setup :wink:

Again, thank for your help.

1 Like