python api client for digitalSTROM
Project description
pydigitalstrom
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
Concept
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.
Example usage
# -*- coding: UTF-8 -*-
import urllib3
import os
import asyncio
from pydigitalstrom.client import DSClient
# disable certificate warnings - dss uses self signed
async def test():
urllib3.disable_warnings()
config_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'config', 'auth.json')
client = DSClient(host='https://dss.local:8080', username='dssadmin', password='mySuperSecretPassword',
config_path=config_path, apartment_name='Apartment')
await client.initialize()
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())
Event listener
Run an event listener to get scene call updates from digitalSTROM
# -*- coding: UTF-8 -*-
import urllib3
import os
import asyncio
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):
urllib3.disable_warnings()
config_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'config', 'auth.json')
client = DSClient(host='https://dss.local:8080', username='dssadmin', password='mySuperSecretPassword',
config_path=config_path, 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))
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
[Unreleased]
[0.5.0] - 2019-02-09
Changed
- BREAKING - changed device unique_id to be underscore separated instead of dot separated
- updated python versions and dependencies
[0.4.1] - 2018-10-01
Changed
- Registering callbacks on the DSEventListener should not be async
[0.4.0] - 2018-10-01
Changed
- BREAKING - this library will only support scenes from now on since device actions suck on digitalSTROM!
- BREAKING - the DSEventListener will now forward event data to the callback instead of updating states on it's own
[0.3.4] - 2018-09-30
Added
- Update AreaBlind state from DSListener
[0.3.3] - 2018-09-29
Added
- Support for AreaBlind, basically converted scenes 0-9 to proper blind devices for the area
[0.3.2] - 2018-09-16
Changed
- Allow passing an asyncio loop to the DSListener
[0.3.1] - 2018-09-16
Added
- Support update callbacks on AreaLight
[0.3.0] - 2018-09-16
Added
- Support for AreaLight, basically converted scenes 0-9 to proper light devices for the area
- Event listener that can update the AreaLight status
CHanged
- BREAKING - devices etc are now initialized by DSClient.initialize() and DSClient getter functions are not async anymore
[0.2.0] - 2018-09-11
Added
- Test coverage increased
Changed
- BREAKING - All things async
- Use aiohttp to make calls and provide api-using functions as async
- Comply with PEP8 formatting rules
- BREAKING merged DSTerminal and DSDevice into DSDevice
- BREAKING minimum required Python version is now 3.5.3
- Multi version Docker environment to run full tox suite
[0.1.2] - 2018-09-10
Fixed
- Some API calls should not expect a result node in response
Changed
- Added more gitignores for docker env and app config
[0.1.1] - 2018-09-10
Added
- Tests for blind, light, meter and scene
- Add move_up, move_down and stop to blind
Changed
- DSDevice and DSTerminal signature of request now allows for responses without result node
[0.1.0] - 2018-09-09
Changed
- Complete rewrite
Added
- (yellow) Support for GE-KL200, GE-KM200
- (grey) Support for GR-KL200
- (black) Support for SW-ZW200-F, SW-TKM200
- (meter) Support for dSM12
- (server) Support for dSS IP
- Support for scenes
[0.0.1] - 2016-11-23
Added
- Initial release
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
pydigitalstrom-0.5.0.tar.gz
(12.3 kB
view hashes)