Skip to content

Commit

Permalink
Add support for S2125 and correct model aliases (#73)
Browse files Browse the repository at this point in the history
- Add support for S2125
home-assistant/home-assistant.io#25129
- Avoid model enum aliases that break display
home-assistant/core#83057
- Set series as part of enum
- Expose event for product info
  • Loading branch information
yozik04 authored Dec 3, 2022
2 parents f2a2cbf + 259c295 commit e5db8e7
Show file tree
Hide file tree
Showing 5 changed files with 7,976 additions and 40 deletions.
2 changes: 1 addition & 1 deletion nibe/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.4.1"
__version__ = "1.5.0"
11 changes: 8 additions & 3 deletions nibe/connection/nibegw.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def __str__(self):

class NibeGW(asyncio.DatagramProtocol, Connection, EventServer):
CONNECTION_STATUS_EVENT = "connection_status"
PRODUCT_INFO_EVENT = "product_info"
_futures: Dict[str, Future]
_status: ConnectionStatus

Expand Down Expand Up @@ -206,8 +207,13 @@ def datagram_received(self, data: bytes, addr):
elif cmd == "RMU_DATA_MSG":
self._on_rmu_data(msg.fields.value)
elif cmd == "PRODUCT_INFO_MSG":
data = msg.fields.value.data
product_info = ProductInfo(data["model"], data["version"])
with suppress(InvalidStateError, CancelledError, KeyError):
self._futures["product_info"].set_result(msg.fields.value.data)
self._futures["product_info"].set_result(product_info)
self.notify_event_listeners(
self.PRODUCT_INFO_EVENT, product_info=product_info
)
elif not isinstance(cmd, EnumIntegerString):
logger.debug(f"Unknown command {cmd}")
except ChecksumError:
Expand All @@ -227,8 +233,7 @@ async def read_product_info(
) -> ProductInfo:
self._futures["product_info"] = asyncio.get_event_loop().create_future()
try:
result = await asyncio.wait_for(self._futures["product_info"], timeout)
return ProductInfo(result["model"], result["version"])
return await asyncio.wait_for(self._futures["product_info"], timeout)
except asyncio.TimeoutError:
raise ProductInfoReadTimeoutException("Timeout waiting for product message")
finally:
Expand Down
Loading

0 comments on commit e5db8e7

Please sign in to comment.