File: main.py

package info (click to toggle)
laundrify-aio 1.2.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 100 kB
  • sloc: python: 170; makefile: 7
file content (24 lines) | stat: -rw-r--r-- 729 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Example script to show how to use laundrify_aio."""

import asyncio
import json
from laundrify_aio import LaundrifyAPI

async def main():
	# Generate a new AuthCode in the laundrify App (`Smart-Home Integration -> Home Assistant -> Integration aktivieren`)
	auth_code = '999-001'

	# exchange your auth code for a long-lived access token
	access_token = await LaundrifyAPI.exchange_auth_code(auth_code)

	# initialize a new client with the previously obtained access token
	laundrify_client = LaundrifyAPI(access_token)

	# get all machines
	machines = await laundrify_client.get_machines()

	print( json.dumps(machines, indent=4) )

if __name__ == "__main__":
	loop = asyncio.get_event_loop()
	loop.run_until_complete(main())