• Stars
    star
    180
  • Rank 213,097 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created about 7 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

📡 A simple Python API for Tile® Bluetooth trackers

📡 pytile: A simple Python API for Tile® Bluetooth trackers

CI PyPI Version License Code Coverage Maintainability

Buy Me A Coffee

pytile is a simple Python library for retrieving information on Tile® Bluetooth trackers (including last location and more).

This library is built on an unpublished, unofficial Tile API; it may alter or cease operation at any point.

NOTE: Version 5.0.0

Version 5.0.0 is a complete re-architecture of pytile – as such, the API has changed. Please read the documentation carefully!

Python Versions

pytile is currently supported on:

  • Python 3.9
  • Python 3.10
  • Python 3.11

Installation

pip install pytile

Usage

Getting an API Object

pytile usage starts with an aiohttp ClientSession – note that this ClientSession is required to properly authenticate the library:

import asyncio

from aiohttp import ClientSession

from pytile import async_login


async def main() -> None:
    """Run!"""
    async with ClientSession() as session:
        api = await async_login("<EMAIL>", "<PASSWORD>", session)


asyncio.run(main())

If for some reason you need to use a specific client UUID (to, say, ensure that the Tile API sees you as a client it's seen before) or a specific locale, you can do so easily:

import asyncio

from aiohttp import ClientSession

from pytile import async_login


async def main() -> None:
    """Run!"""
    async with ClientSession() as session:
        api = await async_login(
            "<EMAIL>", "<PASSWORD>", session, client_uuid="MY_UUID", locale="en-GB"
        )


asyncio.run(main())

Getting Tiles

Tile Premium Required: No

import asyncio

from aiohttp import ClientSession

from pytile import async_login


async def main() -> None:
    """Run!"""
    async with ClientSession() as session:
        api = await async_login("<EMAIL>", "<PASSWORD>", session)

        tiles = await api.async_get_tiles()


asyncio.run(main())

The async_get_tiles coroutine returns a dict with Tile UUIDs as the keys and Tile objects as the values.

The Tile Object

The Tile object comes with several properties:

  • accuracy: the location accuracy of the Tile
  • altitude: the altitude of the Tile
  • archetype: the internal reference string that describes the Tile's "family"
  • dead: whether the Tile is inactive
  • firmware_version: the Tile's firmware version
  • hardware_version: the Tile's hardware version
  • kind: the kind of Tile (e.g., TILE, PHONE)
  • last_timestamp: the timestamp at which the current attributes were received
  • latitude: the latitude of the Tile
  • longitude: the latitude of the Tile
  • lost: whether the Tile has been marked as "lost"
  • lost_timestamp: the timestamp at which the Tile was last marked as "lost"
  • name: the name of the Tile
  • uuid: the Tile UUID
  • visible: whether the Tile is visible in the mobile app
import asyncio

from aiohttp import ClientSession

from pytile import async_login


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(f"The Tile's name is {tile.name}")
            # ...


asyncio.run(main())

In addition to these properties, the Tile object comes with an async_update coroutine which requests new data from the Tile cloud API for this Tile:

import asyncio

from aiohttp import ClientSession

from pytile import async_login


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():
            await tile.async_update()


asyncio.run(main())

Getting Premium Tile's History

Tile Premium Required: Yes

You can retrieve a Tile's history by calling its async_history coroutine:

import asyncio
from datetime import datetime

from aiohttp import ClientSession

from pytile import async_login


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():
            # Define a start and end datetime to get history for:
            start = datetime(2023, 1, 1, 0, 0, 0)
            end = datetime(2023, 1, 31, 0, 0, 0)
            history = await tile.async_history(start, end)
            # >>> { "version": 1, "revision": 1, ... }


asyncio.run(main())

Contributing

Thanks to all of our contributors so far!

  1. Check for open features/bugs or initiate a discussion on one.
  2. Fork the repository.
  3. (optional, but highly recommended) Create a virtual environment: python3 -m venv .venv
  4. (optional, but highly recommended) Enter the virtual environment: source ./.venv/bin/activate
  5. Install the dev environment: script/setup
  6. Code your new feature or bug fix on a new branch.
  7. Write tests that cover your new functionality.
  8. Run tests and ensure 100% code coverage: poetry run pytest --cov pytile tests
  9. Update README.md with any new documentation.
  10. Submit a pull request!

More Repositories

1

smart-home

⭐ (Almost) everything needed to run my smart home with Home Assistant and more!
Python
272
star
2

ecowitt2mqtt

Send data from Fine Offset weather stations (Ecowitt, Ambient Weather, Froggit, etc.) to MQTT!
Python
208
star
3

lp-vault-manager

An Alfred 2 workflow to interact with a LastPass vault.
Python
121
star
4

pinpress

A simple CLI to create text templates of Pinboard data.
Ruby
37
star
5

Sifttter-Redux

IFTTT to Day One service
Ruby
36
star
6

aioambient

🌤 A clean, async-friendly library for interacting with the Ambient Weather API
Python
32
star
7

py17track

📦 A simple API to track package info from 17track.com
Python
29
star
8

ExpandSync

A simple engine to sync aText and TextExpander iOS
Ruby
20
star
9

linkding-cli

A CLI to interface with an instance of linkding
Python
20
star
10

eufy-security-ws-python

A Python wrapper around eufy-security-ws
Python
16
star
11

aioflo

A Python3, async-friendly library for Flo by Moen Smart Water Detectors
Python
16
star
12

pyiqvia

🌻 A clean, async-focused Python3 API for IQVIA data (https://pollen.com, https://flustar.com, etc.)
Python
16
star
13

aiolinkding

A Python3, async interface to the linkding REST API
Python
15
star
14

cliutils

A library to alleviate common tasks and headaches in Ruby CLI apps
Ruby
12
star
15

regenmaschine

💧 A simple, clean, well-tested Python library for interacting with RainMachine™ smart sprinkler controllers
Python
11
star
16

pyxcel

A Simple Python API for Xcel Energy® Data
Python
11
star
17

pyairvisual

☀️ A simple, clean, well-tested Python library for interacting with AirVisual©
Python
9
star
18

aiopinboard

A Python 3, asyncio-based library to interact with the Pinboard API
Python
9
star
19

pyopenuv

☀️A simple Python API to retrieve data from openuv.io
Python
6
star
20

Code

My collection of random scripts, code snippets, and other miscellany
XSLT
5
star
21

home-assistant-addons

My personally developed Home Assistant add-ons
Shell
4
star
22

aiowwlln

⚡️A simple, asyncio-driven Python3 wrapper for the WWLLN (World Wide Lightning Location Network)
Python
4
star
23

aXel

A REALbasic-based XSLT editor and library.
XSLT
4
star
24

aiorecollect

🗑 A Python 3, asyncio-based library for the Recollect Waste API
Python
3
star
25

aiowatttime

An asyncio-based Python3 library for interacting with WattTime
Python
3
star
26

pypi-template

A template repo for the PyPI-focused Python libraries I tend to develop
Shell
3
star
27

pypollencom

🌼 A simple Python wrapper to get allergen/disease data from Pollen.com
Python
2
star
28

aioguardian

🚰 A Python3, async library to interact with Elexa Guardian valve controllers and leak detectors
Python
2
star
29

aioridwell

♻️ A Python3, asyncio-based API for interacting with Ridwell waste recycling
Python
1
star
30

pyoutbreaksnearme

☣️ pyoutbreaksnearme: A Python3 API for Outbreaks Near Me
Python
1
star
31

Markdown-to-Evernote-Modified

A modified version of Tim Lockridge's Markdown to Evernote Textmate action that includes support for checkboxes.
Ruby
1
star
32

bachya.github.io

Bachya Productions
HTML
1
star
33

aionotion

A simple, asyncio-friendly Python3 library for Notion® Home Monitoring
Python
1
star
34

pyden

📡 A Python API for getting information from the City and County of Denver, CO
Python
1
star
35

aiolookin

An asyncio-based Python3 library for interacting with LOOK.in devices
Python
1
star