From 77866b6e89070e59b6bad79654a8743aba3943fe Mon Sep 17 00:00:00 2001 From: Tom Dryer Date: Wed, 18 Jan 2023 21:49:36 -0800 Subject: [PATCH] Document ineffective brightness setting --- README.md | 13 ++++++++++--- eh_fifty.py | 7 ++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ed09892..974c779 100644 --- a/README.md +++ b/README.md @@ -61,10 +61,15 @@ in bytes, not including this byte. The first byte of a response is `0x02`. -The second byte of a response is `0x02` for "success" or `0x01` for "error". +The second byte of a response may be either: -The third byte of a response is the remaining length of the response measured -in bytes, not including this byte. +* `0x00` for "no response" +* `0x01` for "error" +* `0x02` for "success" + +Unless the second byte represents "no response", the third byte of a response +is the remaining length of the response measured in bytes, not including this +byte. ### Saved Values @@ -101,9 +106,11 @@ Type | Description 0x72 | get balance 0x73 | set default balance ... | +0x75 | set brightness (ineffective) 0x76 | set alert volume 0x77 | get default balance ... | +0x79 | get brightness 0x7A | get alert volume ... | 0x7C | get battery status diff --git a/eh_fifty.py b/eh_fifty.py index 0cba1e4..985f7bc 100644 --- a/eh_fifty.py +++ b/eh_fifty.py @@ -63,7 +63,7 @@ def _request( raise LOGGER.debug("Received %s response\n%s", request_type, hexdump(resp)) assert resp[0] == 0x02 - assert resp[1] == _ResponseStatus.OK.value + assert resp[1] in {_ResponseStatus.NO_RESPONSE.value, _ResponseStatus.OK.value} length = resp[2] return bytes(resp[3 : 3 + length]) @@ -330,8 +330,9 @@ class _CommandType(Enum): class _ResponseStatus(Enum): - ERROR = 0x1 - OK = 0x2 + NO_RESPONSE = 0 + ERROR = 1 + OK = 2 @dataclass