Repository: home-assistant/core
File: homeassistant/components/switcher_kis/sensor.py (Python)

Code before:
]
TIME_SENSORS: list[SwitcherSensorEntityDescription] = [
    SwitcherSensorEntityDescription(
        key="remaining_time",
        translation_key="remaining_time",
        value_fn=lambda data: cast(SwitcherTimedBase, data).remaining_time,
    ),
    SwitcherSensorEntityDescription(
        key="auto_off_set",
        translation_key="auto_shutdown",
        entity_registry_enabled_default=False,
        value_fn=lambda data: cast(SwitcherTimedBase, data).auto_shutdown,
    ),
]
TEMPERATURE_SENSORS: list[SwitcherSensorEntityDescription] = [
    SwitcherSensorEntityDescription(
        key="temperature",
        device_class=SensorDeviceClass.TEMPERATURE,
        native_unit_of_measurement=UnitOfTemperature.CELSIUS,
        state_class=SensorStateClass.MEASUREMENT,
        value_fn=lambda data: cast(SwitcherThermostatBase, data).temperature,
    ),
]

POWER_PLUG_SENSORS = POWER_SENSORS
WATER_HEATER_SENSORS = [*POWER_SENSORS, *TIME_SENSORS]
THERMOSTAT_SENSORS = TEMPERATURE_SENSORS
HEATER_SENSORS = [*POWER_SENSORS, *TIME_SENSORS]


async def async_setup_entry(
    hass: HomeAssistant,
    config_entry: SwitcherConfigEntry,
    async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
    """Set up Switcher sensor from config entry."""

    @callback
    def async_add_sensors(coordinator: SwitcherDataUpdateCoordinator) -> None:
        """Add sensors from Switcher device."""
        if coordinator.data.device_type.category == DeviceCategory.POWER_PLUG:
            async_add_entities(
                SwitcherSensorEntity(coordinator, description)
                for description in POWER_PLUG_SENSORS
            )
        elif coordinator.data.device_type.category == DeviceCategory.WATER_HEATER:
            async_add_entities(
                SwitcherSensorEntity(coordinator, description)
                for description in WATER_HEATER_SENSORS
            )
        elif coordinator.data.device_type.category == DeviceCategory.THERMOSTAT:

Review comment (suggestion):
You don't need another const that has the same sensors, just create one const (e.g.  `HEATER_SENSORS` )

Code after:
]
TIME_SENSORS: list[SwitcherSensorEntityDescription] = [
    SwitcherSensorEntityDescription(
        key="remaining_time",
        translation_key="remaining_time",
        value_fn=lambda data: cast(SwitcherTimedBase, data).remaining_time,
    ),
    SwitcherSensorEntityDescription(
        key="auto_off_set",
        translation_key="auto_shutdown",
        entity_registry_enabled_default=False,
        value_fn=lambda data: cast(SwitcherTimedBase, data).auto_shutdown,
    ),
]
TEMPERATURE_SENSORS: list[SwitcherSensorEntityDescription] = [
    SwitcherSensorEntityDescription(
        key="temperature",
        device_class=SensorDeviceClass.TEMPERATURE,
        native_unit_of_measurement=UnitOfTemperature.CELSIUS,
        state_class=SensorStateClass.MEASUREMENT,
        value_fn=lambda data: cast(SwitcherThermostatBase, data).temperature,
    ),
]

POWER_PLUG_SENSORS = POWER_SENSORS
HEATER_SENSORS = [*POWER_SENSORS, *TIME_SENSORS]
THERMOSTAT_SENSORS = TEMPERATURE_SENSORS


async def async_setup_entry(
    hass: HomeAssistant,
    config_entry: SwitcherConfigEntry,
    async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
    """Set up Switcher sensor from config entry."""

    @callback
    def async_add_sensors(coordinator: SwitcherDataUpdateCoordinator) -> None:
        """Add sensors from Switcher device."""
        if coordinator.data.device_type.category == DeviceCategory.POWER_PLUG:
            async_add_entities(
                SwitcherSensorEntity(coordinator, description)
                for description in POWER_PLUG_SENSORS
            )
        elif coordinator.data.device_type.category in [
            DeviceCategory.WATER_HEATER,
            DeviceCategory.HEATER,
        ]:
            async_add_entities(
                SwitcherSensorEntity(coordinator, description)
                for description in HEATER_SENSORS