Sotolotl / meater-python

Python wrapper for the Apption Labs Meater cooking probe using v1 of their public API.
Apache License 2.0
8 stars 2 forks source link

Example code #2

Open Pangel71 opened 3 years ago

Pangel71 commented 3 years ago

Would it be possible to get a working example that just prints the information from the heater cloud?

Thanks.

Kind regards Peter

Sotolotl commented 3 years ago

Something like this should get you started. I'll add a proper example script to the repository once I get the chance :)

import asyncio
import aiohttp
from meater import MeaterApi
from pprint import pprint

async def printDevices():
    session = aiohttp.ClientSession()

    api = MeaterApi(session)

    await api.authenticate('<your email address>','<your password>')

    devices = await api.get_all_devices()

    for device in devices:
        pprint(vars(device))
        if device.cook is not None:
            pprint(vars(device.cook))

loop = asyncio.get_event_loop()
loop.run_until_complete(printDevices())
loop.close()

Replace <your email address> and <your password> accordingly for now.

You do need to make sure you've got aiohttp installed, too.

Also worth noting; this code will throw an exception at the end because it's not closing resources properly, but it should be enough to help you get started :)