From 2dd856ee0aff116b2c07ab50f5e2d008fc99bf84 Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Thu, 16 Jul 2026 18:35:42 -0700 Subject: [PATCH] fix: alarm sensor false-positive when alarm code is 0 The Alarm binary sensor OR'd an unreliable top-level "alarm" API flag with the alarm_code bitfield, so a truthy-but-benign top-level flag could report PROBLEM even when alarm_code (s20) was 0 (no fault). Drop the top-level flag and derive the sensor solely from alarm_code. Fixes #17 --- custom_components/pentair_cloud/binary_sensor.py | 8 +++----- custom_components/pentair_cloud/pentaircloud.py | 6 +----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/custom_components/pentair_cloud/binary_sensor.py b/custom_components/pentair_cloud/binary_sensor.py index aaf66c5..c3d0770 100644 --- a/custom_components/pentair_cloud/binary_sensor.py +++ b/custom_components/pentair_cloud/binary_sensor.py @@ -33,12 +33,10 @@ class PentairBinarySensorEntityDescription(BinarySensorEntityDescription): key="alarm", name="Alarm", device_class=BinarySensorDeviceClass.PROBLEM, - # The device-level "alarm" flag is what Pentair reports; the numeric - # fault bits are exposed separately as the "Alarm code" sensor. + # s20 (alarm_code) is the authoritative fault bitfield: 0 = no fault. + # The numeric code is also exposed separately as the "Alarm code" sensor. value_fn=lambda device: ( - bool(device.alarm) or bool(device.alarm_code) - if device.alarm is not None or device.alarm_code is not None - else None + device.alarm_code != 0 if device.alarm_code is not None else None ), ), PentairBinarySensorEntityDescription( diff --git a/custom_components/pentair_cloud/pentaircloud.py b/custom_components/pentair_cloud/pentaircloud.py index 8669514..b7bcd97 100644 --- a/custom_components/pentair_cloud/pentaircloud.py +++ b/custom_components/pentair_cloud/pentaircloud.py @@ -63,7 +63,6 @@ def __init__(self, LOGGER: Logger, pentair_device_id: str, nickname: str) -> Non self.motor_speed_pct = None # s19 - Current Motor Speed (%) self.flow_gpm = None # s26 - Current Estimated Flow (gallons per minute) self.pressure_psi = None # s17 - Current Pressure (psi) - self.alarm = None # device-level alarm flag (Pentair reported) self.alarm_code = None # s20 - Alarm Condition bitfield (0 = no fault) self.online = None # device connectivity flag # Optimistic program selection: when the user starts/stops a program we @@ -99,7 +98,6 @@ def get_value(key): self.pressure_psi = float(pressure) / 100 if pressure is not None else None self.alarm_code = int(alarm_code) if alarm_code is not None else None # Device-level flags live at the top of the response, not in "fields". - self.alarm = device_response.get("alarm") self.online = device_response.get("online") if DEBUG_INFO: self.LOGGER.info( @@ -113,9 +111,7 @@ def get_value(key): + str(self.flow_gpm) + "GPM pressure=" + str(self.pressure_psi) - + "psi alarm=" - + str(self.alarm) - + " code=" + + "psi alarm_code=" + str(self.alarm_code) )