Skip to content

Commit e2a59b5

Browse files
committed
fix: adjust operation list for water heaters based on writable status of EPC_OPERATION_STATUS
1 parent d167310 commit e2a59b5

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

custom_components/echonet_lite/water_heater.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,11 @@ def __init__(
221221
self._mode_to_edt: dict[str, int] = {
222222
name: raw for raw, name in _OPERATION_MODE_MAP.items()
223223
}
224-
operation_list: list[str] = [STATE_OFF]
224+
# STATE_OFF is only meaningful when 0x80 is writable; some
225+
# always-on water heaters do not allow turning off via 0x80.
226+
operation_list: list[str] = (
227+
[STATE_OFF] if EPC_OPERATION_STATUS in node.set_epcs else []
228+
)
225229
if EPC_OPERATION_MODE in node.set_epcs:
226230
features |= WaterHeaterEntityFeature.OPERATION_MODE
227231
# Preserve the EDT-byte order so the UI lists modes in the
@@ -319,10 +323,10 @@ async def async_set_operation_mode(self, operation_mode: str) -> None:
319323
translation_key="operation_mode_not_writable",
320324
)
321325
if EPC_OPERATION_STATUS not in self._node.set_epcs:
322-
raise HomeAssistantError(
323-
translation_domain=DOMAIN,
324-
translation_key="operation_status_not_writable",
325-
)
326+
# Always-on devices do not allow writing 0x80; send only the
327+
# operation mode and let 0x80 stay at its current value.
328+
await self._async_send_property(EPC_OPERATION_MODE, bytes([edt_byte]))
329+
return
326330
# Send mode + ON together so flipping the operation mode from
327331
# the "Off" state in the UI also turns the device on.
328332
await self._async_send_properties(

0 commit comments

Comments
 (0)