From cd1b993f4148fd1406864f4f6d94ccfcff98c343 Mon Sep 17 00:00:00 2001 From: Alfred Krohmer Date: Tue, 30 Jun 2020 16:51:34 +0200 Subject: [PATCH] fix: handling of control messages Version 0.4.0 of asyncio-mqtt introduces an unannounced breaking change which requires to use msg.payload to get to the string value. Allowing >=0.3.0 in setup.py installs 0.4.0 or greater which breaks. --- pyess/essmqtt.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyess/essmqtt.py b/pyess/essmqtt.py index e78c645..853eca8 100644 --- a/pyess/essmqtt.py +++ b/pyess/essmqtt.py @@ -164,7 +164,7 @@ async def handle_control(client, control, path): async for msg in messages: logger.info(f"control message received {msg}") try: - state = strtobool(msg.decode()) + state = strtobool(msg.payload.decode()) await control(state) except ValueError: logger.warning(f"ignoring incompatible value {msg} for switching") diff --git a/setup.py b/setup.py index 23d7043..628b7de 100755 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ packages=['pyess'], install_requires=[ - 'zeroconf', 'requests', 'graphyte', 'aiohttp', 'asyncio-mqtt>=0.3.0', 'ConfigArgParse' + 'zeroconf', 'requests', 'graphyte', 'aiohttp', 'asyncio-mqtt>=0.4.0', 'ConfigArgParse' ], zip_safe=False,