From 2208d7e92cde9ea566ec0a0336fd06eb371a2f46 Mon Sep 17 00:00:00 2001 From: Brett Adams Date: Sun, 15 Feb 2026 20:18:26 +1000 Subject: [PATCH] Add island_status sensor and grid_status binary sensor to Tessie (#162975) Co-authored-by: Claude Opus 4.6 --- .../components/tessie/binary_sensor.py | 27 ++++++-- homeassistant/components/tessie/icons.json | 6 ++ homeassistant/components/tessie/sensor.py | 11 ++++ homeassistant/components/tessie/strings.json | 13 ++++ .../tessie/snapshots/test_binary_sensor.ambr | 50 ++++++++++++++ .../tessie/snapshots/test_sensor.ambr | 65 +++++++++++++++++++ 6 files changed, 165 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/tessie/binary_sensor.py b/homeassistant/components/tessie/binary_sensor.py index cdf3b0035fcc..51a5c33b0d87 100644 --- a/homeassistant/components/tessie/binary_sensor.py +++ b/homeassistant/components/tessie/binary_sensor.py @@ -160,10 +160,16 @@ VEHICLE_DESCRIPTIONS: tuple[TessieBinarySensorEntityDescription, ...] = ( ), ) -ENERGY_LIVE_DESCRIPTIONS: tuple[BinarySensorEntityDescription, ...] = ( - BinarySensorEntityDescription(key="backup_capable"), - BinarySensorEntityDescription(key="grid_services_active"), - BinarySensorEntityDescription(key="storm_mode_active"), +ENERGY_LIVE_DESCRIPTIONS: tuple[TessieBinarySensorEntityDescription, ...] = ( + TessieBinarySensorEntityDescription(key="backup_capable"), + TessieBinarySensorEntityDescription(key="grid_services_active"), + TessieBinarySensorEntityDescription( + key="grid_status", + is_on=lambda x: x == "Active", + device_class=BinarySensorDeviceClass.POWER, + entity_category=EntityCategory.DIAGNOSTIC, + ), + TessieBinarySensorEntityDescription(key="storm_mode_active"), ) @@ -225,21 +231,28 @@ class TessieBinarySensorEntity(TessieEntity, BinarySensorEntity): class TessieEnergyLiveBinarySensorEntity(TessieEnergyEntity, BinarySensorEntity): """Base class for Tessie energy live binary sensors.""" - entity_description: BinarySensorEntityDescription + entity_description: TessieBinarySensorEntityDescription def __init__( self, data: TessieEnergyData, - description: BinarySensorEntityDescription, + description: TessieBinarySensorEntityDescription, ) -> None: """Initialize the binary sensor.""" self.entity_description = description assert data.live_coordinator is not None super().__init__(data, data.live_coordinator, description.key) + @property + def available(self) -> bool: + """Return if entity is available.""" + return super().available and self._attr_available + def _async_update_attrs(self) -> None: """Update the attributes of the binary sensor.""" - self._attr_is_on = self._value + self._attr_available = self._value is not None + if self._attr_available: + self._attr_is_on = self.entity_description.is_on(self._value) class TessieEnergyInfoBinarySensorEntity(TessieEnergyEntity, BinarySensorEntity): diff --git a/homeassistant/components/tessie/icons.json b/homeassistant/components/tessie/icons.json index 5a85daae05e9..5a67cdffb5fb 100644 --- a/homeassistant/components/tessie/icons.json +++ b/homeassistant/components/tessie/icons.json @@ -25,6 +25,12 @@ "grid_services_power": { "default": "mdi:transmission-tower" }, + "grid_status": { + "state": { + "off": "mdi:transmission-tower-off", + "on": "mdi:transmission-tower" + } + }, "storm_mode_active": { "default": "mdi:weather-sunny", "state": { diff --git a/homeassistant/components/tessie/sensor.py b/homeassistant/components/tessie/sensor.py index 3c15ea7815aa..8045a8757f3f 100644 --- a/homeassistant/components/tessie/sensor.py +++ b/homeassistant/components/tessie/sensor.py @@ -344,6 +344,17 @@ ENERGY_LIVE_DESCRIPTIONS: tuple[TessieSensorEntityDescription, ...] = ( device_class=SensorDeviceClass.POWER, entity_registry_enabled_default=False, ), + TessieSensorEntityDescription( + key="island_status", + device_class=SensorDeviceClass.ENUM, + options=[ + "on_grid", + "off_grid", + "off_grid_intentional", + "off_grid_unintentional", + "island_status_unknown", + ], + ), ) WALL_CONNECTOR_DESCRIPTIONS: tuple[TessieSensorEntityDescription, ...] = ( diff --git a/homeassistant/components/tessie/strings.json b/homeassistant/components/tessie/strings.json index 034e95da55bf..dbe1697b4b58 100644 --- a/homeassistant/components/tessie/strings.json +++ b/homeassistant/components/tessie/strings.json @@ -81,6 +81,9 @@ "grid_services_active": { "name": "Grid services active" }, + "grid_status": { + "name": "Grid status" + }, "state": { "name": "Status" }, @@ -429,6 +432,16 @@ "grid_services_power": { "name": "Grid services power" }, + "island_status": { + "name": "Island status", + "state": { + "island_status_unknown": "Unknown", + "off_grid": "Off-grid", + "off_grid_intentional": "Off-grid intentional", + "off_grid_unintentional": "Off-grid unintentional", + "on_grid": "On-grid" + } + }, "load_power": { "name": "Load power" }, diff --git a/tests/components/tessie/snapshots/test_binary_sensor.ambr b/tests/components/tessie/snapshots/test_binary_sensor.ambr index 4374cb65c145..4566d7b140d0 100644 --- a/tests/components/tessie/snapshots/test_binary_sensor.ambr +++ b/tests/components/tessie/snapshots/test_binary_sensor.ambr @@ -146,6 +146,56 @@ 'state': 'off', }) # --- +# name: test_binary_sensors[binary_sensor.energy_site_grid_status-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.energy_site_grid_status', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Grid status', + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Grid status', + 'platform': 'tessie', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'grid_status', + 'unique_id': '123456-grid_status', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensors[binary_sensor.energy_site_grid_status-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'power', + 'friendly_name': 'Energy Site Grid status', + }), + 'context': , + 'entity_id': 'binary_sensor.energy_site_grid_status', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- # name: test_binary_sensors[binary_sensor.energy_site_storm_watch_active-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ diff --git a/tests/components/tessie/snapshots/test_sensor.ambr b/tests/components/tessie/snapshots/test_sensor.ambr index e48fff97bc4a..e8273456c4d8 100644 --- a/tests/components/tessie/snapshots/test_sensor.ambr +++ b/tests/components/tessie/snapshots/test_sensor.ambr @@ -299,6 +299,71 @@ 'state': '0.0', }) # --- +# name: test_sensors[sensor.energy_site_island_status-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'options': list([ + 'on_grid', + 'off_grid', + 'off_grid_intentional', + 'off_grid_unintentional', + 'island_status_unknown', + ]), + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.energy_site_island_status', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Island status', + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Island status', + 'platform': 'tessie', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'island_status', + 'unique_id': '123456-island_status', + 'unit_of_measurement': None, + }) +# --- +# name: test_sensors[sensor.energy_site_island_status-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'enum', + 'friendly_name': 'Energy Site Island status', + 'options': list([ + 'on_grid', + 'off_grid', + 'off_grid_intentional', + 'off_grid_unintentional', + 'island_status_unknown', + ]), + }), + 'context': , + 'entity_id': 'sensor.energy_site_island_status', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on_grid', + }) +# --- # name: test_sensors[sensor.energy_site_load_power-entry] EntityRegistryEntrySnapshot({ 'aliases': set({