pydigitalstrom is deprecated as I'm no longer using their home control system. Feel free to contact me if you'd like to take over.
Run bundled docker
$ docker-compose build
$ docker-compose up -d
$ docker-compose exec python bash
Run the tests locally
$ docker-compose run --rm python tox
pydigitalstrom supports VSCode devcontainers for code completion and test runner
Since digitalSTROM is mainly build on the concept of scenes, this library also only support setting scenes.
Currently user defined named scenes and generic scenes are supported.
import asyncio
from pydigitalstrom.apptokenhandler import DSAppTokenHandler
from pydigitalstrom.client import DSClient
async def test():
# get activated app token
apptokenhandler = DSAppTokenHandler(
host="https://dss.local:8080",
username="dssadmin",
password="mySuperSecretPassword",
)
apptoken = await apptokenhandler.request_apptoken()
# connect the client and initialize the scenes cache
client = DSClient(
host="https://dss.local:8080", apptoken=apptoken, apartment_name="Apartment"
)
await client.initialize()
# list and turn on all scenes
scenes = client.get_scenes()
for scene in scenes.values():
print(scene.unique_id)
print(scene.name)
# await scene.turn_on()
loop = asyncio.get_event_loop()
loop.run_until_complete(test())
Run an event listener to get scene call updates from digitalSTROM
import asyncio
from pydigitalstrom.apptokenhandler import DSAppTokenHandler
from pydigitalstrom.client import DSClient
from pydigitalstrom.listener import DSEventListener
async def callback(event):
print("callback called")
print(event)
# disable certificate warnings - dss uses self signed
async def test(loop):
# get activated app token
apptokenhandler = DSAppTokenHandler(
host="https://dss.local:8080",
username="dssadmin",
password="mySuperSecretPassword",
)
apptoken = await apptokenhandler.request_apptoken()
# connect listener and print all events coming in
client = DSClient(
host="https://dss.local:8080", apptoken=apptoken, apartment_name="Apartment"
)
listener = DSEventListener(
client=client, event_id=1, event_name="callScene", timeout=1, loop=loop
)
await listener.start()
listener.register(callback=callback)
while True:
await asyncio.sleep(1)
loop = asyncio.get_event_loop()
loop.run_until_complete(test(loop=loop))
bumpversion is used to manage releases.
Add your changes to the CHANGELOG, run
docker-compose run --rm python bumpversion <major|minor|patch>
then push (including tags).