diff --git a/nibe/connection/__init__.py b/nibe/connection/__init__.py index 54210ec..cd4e2c3 100644 --- a/nibe/connection/__init__.py +++ b/nibe/connection/__init__.py @@ -2,9 +2,10 @@ from abc import ABC, abstractmethod from collections.abc import AsyncIterator, Iterable +from contextlib import suppress from nibe.coil import Coil, CoilData -from nibe.exceptions import ReadException, ReadExceptionGroup +from nibe.exceptions import ReadException, ReadExceptionGroup, WriteDeniedException from nibe.heatpump import HeatPump, ProductInfo, Series DEFAULT_TIMEOUT: float = 5 @@ -82,6 +83,10 @@ async def verify_connectivity_read_write_alarm( To verify connection, we read the alarm reset field and write it as 0 this will be ignored by the pump, this will throw exceptions on failure. + + We ignore if the write was denied since that is still indicative of a + working connection. F-series pumps that is MyUplink upgraded seem to + reject these writes. """ if heatpump.series == Series.S: coil = heatpump.get_coil_by_name("reset-alarm-40023") @@ -93,4 +98,6 @@ async def verify_connectivity_read_write_alarm( if coil.mappings: value = coil.mappings[str(value)] coil_data.value = value - await connection.write_coil(coil_data) + + with suppress(WriteDeniedException): + await connection.write_coil(coil_data) diff --git a/nibe/connection/modbus.py b/nibe/connection/modbus.py index 89ed9c4..329a5be 100644 --- a/nibe/connection/modbus.py +++ b/nibe/connection/modbus.py @@ -16,6 +16,7 @@ ReadIOException, ReadTimeoutException, ValidationError, + WriteDeniedException, WriteIOException, WriteTimeoutException, ) @@ -153,7 +154,7 @@ async def write_coil( raise ReadIOException(f"Unsupported entity type {entity_type}") if not result: - raise WriteIOException(f"Heatpump denied writing {coil.name}") + raise WriteDeniedException(f"Heatpump denied writing {coil.name}") else: logger.info(f"Write succeeded for {coil.name}") except ValidationError as exc: diff --git a/nibe/connection/nibegw.py b/nibe/connection/nibegw.py index f360520..abc4c96 100644 --- a/nibe/connection/nibegw.py +++ b/nibe/connection/nibegw.py @@ -65,7 +65,7 @@ ReadIOException, ReadSendException, ReadTimeoutException, - WriteException, + WriteDeniedException, WriteIOException, WriteTimeoutException, ) @@ -369,7 +369,7 @@ async def write_coil( result = self._futures["write"].result() if not result: - raise WriteException(f"Heatpump denied writing {coil.name}") + raise WriteDeniedException(f"Heatpump denied writing {coil.name}") else: logger.info(f"Write succeeded for {coil.name}") except asyncio.TimeoutError: diff --git a/nibe/exceptions.py b/nibe/exceptions.py index e915b23..b956ce9 100644 --- a/nibe/exceptions.py +++ b/nibe/exceptions.py @@ -33,6 +33,10 @@ class WriteException(NibeException): pass +class WriteDeniedException(WriteException): + """Raised a write of a value was rejected by the pump.""" + + class WriteIOException(WriteException): """Use this and child exceptions if IO has failed and you want to retry."""