python interface to the dobiss developer api
Project description
pydobiss Module Repository
pydobiss
dobissapi is a python library that allows you to use dobiss's api.
Install
pip install pydobiss
Example
import asyncio
import aiohttp
import logging
from time import sleep
import dobissapi
#dobissapi.logger.setLevel(logging.DEBUG)
secret = 'secret'
host = 'my_host'
secure = False
dobiss = dobissapi.DobissAPI(secret, host, secure)
async def main():
if not await dobiss.auth_check():
print("Error authenticating dobiss")
return
print("authenticated dobiss")
asyncio.get_event_loop().create_task(dobiss.dobiss_monitor())
entities = await dobiss.discovery()
await dobiss.update_all()
# check if caching works
entities = await dobiss.discovery()
# list scenarios
scenarios = dobiss.get_devices_by_type(dobissapi.DobissScenario)
for e in scenarios:
print("{}: {}".format(e.object_id, e.json))
def get_entity(entities, name):
for e in entities:
if e.name == name:
return e
# test updating and changing entities
await get_entity(entities, "Mancave").update()
await get_entity(entities, "Mancave").toggle()
await asyncio.sleep(2)
await get_entity(entities, "Mancave").toggle()
# test callbacks
def my_callback():
print("callback happened")
get_entity(entities, "Mancave").register_callback(my_callback)
await asyncio.sleep(2)
await get_entity(entities, "Mancave").turn_on()
await asyncio.sleep(2)
await get_entity(entities, "Mancave").turn_off()
# check if new discovery works fine with old callback
await asyncio.sleep(60)
entities = await dobiss.discovery()
await asyncio.sleep(2)
await get_entity(entities, "Mancave").turn_on()
await asyncio.sleep(2)
await get_entity(entities, "Mancave").turn_off()
try:
loop = asyncio.get_event_loop()
loop.create_task(main())
loop.run_forever()
except KeyboardInterrupt:
print("Exiting")
Author
Kester (kesteraernoudt@yahoo.com)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pydobiss-0.1.12.tar.gz
(7.9 kB
view details)
File details
Details for the file pydobiss-0.1.12.tar.gz.
File metadata
- Download URL: pydobiss-0.1.12.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8509e8f9a7340a3cec6dec89c97f6212d1df4bd195653e2984d0c3818ef6eaa1
|
|
| MD5 |
ee9652d74f3f11c7609da33a0ae1ff05
|
|
| BLAKE2b-256 |
1f6ee9204cb12d4267794a72a1059a4368f7c4bbd576f5ba533a70d91cea9110
|