Repository: home-assistant/core
File: homeassistant/components/lg_thinq/vacuum.py (Python)

Code before:
                )

    if entities:
        async_add_entities(entities)


class ThinQStateVacuumEntity(ThinQEntity, StateVacuumEntity):
    """Represent a thinq vacuum platform."""

    _attr_supported_features = (
        VacuumEntityFeature.SEND_COMMAND
        | VacuumEntityFeature.STATE
        | VacuumEntityFeature.BATTERY
        | VacuumEntityFeature.START
        | VacuumEntityFeature.PAUSE
        | VacuumEntityFeature.RETURN_HOME
    )

    def _update_status(self) -> None:
        """Update status itself."""
        super()._update_status()

        # Update state.
        self._attr_activity = ROBOT_STATUS_TO_HA.get(
            self.data.current_state, VacuumActivity.CLEANING
        )

        # Update battery.
        if (level := self.data.battery) is not None:
            self._attr_battery_level = (
                level if isinstance(level, int) else ROBOT_BATT_TO_HA.get(level, 0)
            )

        _LOGGER.debug(
            "[%s:%s] update status: %s -> %s (battery_level=%s)",
            self.coordinator.device_name,
            self.property_id,
            self.data.current_state,
            self.state,
            self.battery_level,
        )

    async def async_start(self, **kwargs) -> None:
        """Start the device."""
        if self.data.current_state == State.SLEEP:
            value = State.WAKE_UP
        elif self._attr_activity == VacuumActivity.PAUSED:
            value = State.RESUME
        else:
            value = State.START


Review comment (suggestion):
Thank you for your contribution!

If we can't translate the state from the vacuum, we should set it to `None` (which will get translated to "Unkown") instead of setting a default state.

Code after:
                entities.extend(
                    ThinQStateVacuumEntity(coordinator, description, property_id)
                    for property_id in coordinator.api.get_active_idx(description.key)
                )

    if entities:
        async_add_entities(entities)


class ThinQStateVacuumEntity(ThinQEntity, StateVacuumEntity):
    """Represent a thinq vacuum platform."""

    _attr_supported_features = (
        VacuumEntityFeature.SEND_COMMAND
        | VacuumEntityFeature.STATE
        | VacuumEntityFeature.BATTERY
        | VacuumEntityFeature.START
        | VacuumEntityFeature.PAUSE
        | VacuumEntityFeature.RETURN_HOME
    )

    def _update_status(self) -> None:
        """Update status itself."""
        super()._update_status()

        # Update state.
        self._attr_activity = ROBOT_STATUS_TO_HA.get(self.data.current_state)

        # Update battery.
        if (level := self.data.battery) is not None:
            self._attr_battery_level = (
                level if isinstance(level, int) else ROBOT_BATT_TO_HA.get(level, 0)
            )

        _LOGGER.debug(
            "[%s:%s] update status: %s -> %s (battery_level=%s)",
            self.coordinator.device_name,
            self.property_id,
            self.data.current_state,
            self.state,
            self.battery_level,
        )

    async def async_start(self, **kwargs) -> None:
        """Start the device."""
        if self.data.current_state == State.SLEEP:
            value = State.WAKE_UP
        elif self._attr_activity == VacuumActivity.PAUSED:
            value = State.RESUME
        else:
            value = State.START