diff --git a/homeassistant/components/venstar/sensor.py b/homeassistant/components/venstar/sensor.py index 24b4b2f8b16..b4913a874d0 100644 --- a/homeassistant/components/venstar/sensor.py +++ b/homeassistant/components/venstar/sensor.py @@ -65,13 +65,15 @@ SCHEDULE_PARTS: dict[int, str] = { 255: "inactive", } +STAGES: dict[int, str] = {0: "idle", 1: "first_stage", 2: "second_stage"} + @dataclass(frozen=True, kw_only=True) class VenstarSensorEntityDescription(SensorEntityDescription): """Base description of a Sensor entity.""" value_fn: Callable[[VenstarDataUpdateCoordinator, str], Any] - name_fn: Callable[[str], str] + name_fn: Callable[[str], str] | None uom_fn: Callable[[Any], str | None] @@ -140,7 +142,8 @@ class VenstarSensor(VenstarEntity, SensorEntity): super().__init__(coordinator, config) self.entity_description = entity_description self.sensor_name = sensor_name - self._attr_name = entity_description.name_fn(sensor_name) + if entity_description.name_fn: + self._attr_name = entity_description.name_fn(sensor_name) self._config = config @property @@ -230,6 +233,17 @@ INFO_ENTITIES: tuple[VenstarSensorEntityDescription, ...] = ( value_fn=lambda coordinator, sensor_name: SCHEDULE_PARTS[ coordinator.client.get_info(sensor_name) ], - name_fn=lambda _: "Schedule Part", + name_fn=None, + ), + VenstarSensorEntityDescription( + key="activestage", + device_class=SensorDeviceClass.ENUM, + options=list(STAGES.values()), + translation_key="active_stage", + uom_fn=lambda _: None, + value_fn=lambda coordinator, sensor_name: STAGES[ + coordinator.client.get_info(sensor_name) + ], + name_fn=None, ), ) diff --git a/homeassistant/components/venstar/strings.json b/homeassistant/components/venstar/strings.json index 92dfac211fb..952353dcbfe 100644 --- a/homeassistant/components/venstar/strings.json +++ b/homeassistant/components/venstar/strings.json @@ -26,6 +26,7 @@ "entity": { "sensor": { "schedule_part": { + "name": "Schedule Part", "state": { "morning": "Morning", "day": "Day", @@ -33,6 +34,14 @@ "night": "Night", "inactive": "Inactive" } + }, + "active_stage": { + "name": "Active stage", + "state": { + "idle": "Idle", + "first_stage": "First stage", + "second_stage": "Second stage" + } } } }