diff --git a/.coveragerc b/.coveragerc index 810b4d92ce1..c98d56d7d5e 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1002,6 +1002,7 @@ omit = homeassistant/components/suez_water/* homeassistant/components/supervisord/sensor.py homeassistant/components/surepetcare/__init__.py + homeassistant/components/surepetcare/binary_sensor.py homeassistant/components/surepetcare/sensor.py homeassistant/components/swiss_hydrological_data/sensor.py homeassistant/components/swiss_public_transport/sensor.py diff --git a/homeassistant/components/surepetcare/__init__.py b/homeassistant/components/surepetcare/__init__.py index 4ac27ce25a0..58890090d57 100644 --- a/homeassistant/components/surepetcare/__init__.py +++ b/homeassistant/components/surepetcare/__init__.py @@ -138,7 +138,7 @@ class SurePetcareAPI: """Initialize the Sure Petcare object.""" self.hass = hass self.surepy = surepy - self.states = {} + self.states: dict[int, Any] = {} async def async_update(self, _: Any = None) -> None: """Get the latest data from Sure Petcare.""" diff --git a/homeassistant/components/surepetcare/binary_sensor.py b/homeassistant/components/surepetcare/binary_sensor.py index 8f2b77c3c7a..0f536d6135d 100644 --- a/homeassistant/components/surepetcare/binary_sensor.py +++ b/homeassistant/components/surepetcare/binary_sensor.py @@ -28,7 +28,7 @@ async def async_setup_platform( if discovery_info is None: return - entities: list[SurepyEntity] = [] + entities: list[SurepyEntity | Pet | Hub | DeviceConnectivity] = [] spc: SurePetcareAPI = hass.data[DOMAIN][SPC] @@ -112,7 +112,7 @@ class Hub(SurePetcareBinarySensor): ), } else: - self._attr_extra_state_attributes = None + self._attr_extra_state_attributes = {} _LOGGER.debug("%s -> state: %s", self.name, state) self.async_write_ha_state() @@ -139,7 +139,7 @@ class Pet(SurePetcareBinarySensor): "where": state.where, } else: - self._attr_extra_state_attributes = None + self._attr_extra_state_attributes = {} _LOGGER.debug("%s -> state: %s", self.name, state) self.async_write_ha_state() @@ -171,6 +171,6 @@ class DeviceConnectivity(SurePetcareBinarySensor): "hub_rssi": f'{state["signal"]["hub_rssi"]:.2f}', } else: - self._attr_extra_state_attributes = None + self._attr_extra_state_attributes = {} _LOGGER.debug("%s -> state: %s", self.name, state) self.async_write_ha_state() diff --git a/homeassistant/components/surepetcare/sensor.py b/homeassistant/components/surepetcare/sensor.py index 922bfa84515..35d35e9be1f 100644 --- a/homeassistant/components/surepetcare/sensor.py +++ b/homeassistant/components/surepetcare/sensor.py @@ -59,7 +59,10 @@ class SureBattery(SensorEntity): surepy_entity: SurepyEntity = self._spc.states[_id] self._attr_device_class = DEVICE_CLASS_BATTERY - self._attr_name = f"{surepy_entity.type.name.capitalize()} {surepy_entity.name.capitalize()} Battery Level" + if surepy_entity.name: + self._attr_name = f"{surepy_entity.type.name.capitalize()} {surepy_entity.name.capitalize()} Battery Level" + else: + self._attr_name = f"{surepy_entity.type.name.capitalize()} Battery Level" self._attr_native_unit_of_measurement = PERCENTAGE self._attr_unique_id = ( f"{surepy_entity.household_id}-{surepy_entity.id}-battery" @@ -88,7 +91,7 @@ class SureBattery(SensorEntity): f"{ATTR_VOLTAGE}_per_battery": f"{voltage_per_battery:.2f}", } else: - self._attr_extra_state_attributes = None + self._attr_extra_state_attributes = {} self.async_write_ha_state() _LOGGER.debug("%s -> state: %s", self.name, state) diff --git a/mypy.ini b/mypy.ini index 0db7853177e..052e564a5f8 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1601,9 +1601,6 @@ ignore_errors = true [mypy-homeassistant.components.stt.*] ignore_errors = true -[mypy-homeassistant.components.surepetcare.*] -ignore_errors = true - [mypy-homeassistant.components.switchbot.*] ignore_errors = true diff --git a/script/hassfest/mypy_config.py b/script/hassfest/mypy_config.py index b8b80ce3afd..811c11692f8 100644 --- a/script/hassfest/mypy_config.py +++ b/script/hassfest/mypy_config.py @@ -126,7 +126,6 @@ IGNORED_MODULES: Final[list[str]] = [ "homeassistant.components.sonos.*", "homeassistant.components.spotify.*", "homeassistant.components.stt.*", - "homeassistant.components.surepetcare.*", "homeassistant.components.switchbot.*", "homeassistant.components.system_health.*", "homeassistant.components.system_log.*",