Activate mypy for surepetcare (#55079)
This commit is contained in:
parent
5bb9aa8f3d
commit
0ab99fc8bf
6 changed files with 11 additions and 11 deletions
|
@ -1002,6 +1002,7 @@ omit =
|
||||||
homeassistant/components/suez_water/*
|
homeassistant/components/suez_water/*
|
||||||
homeassistant/components/supervisord/sensor.py
|
homeassistant/components/supervisord/sensor.py
|
||||||
homeassistant/components/surepetcare/__init__.py
|
homeassistant/components/surepetcare/__init__.py
|
||||||
|
homeassistant/components/surepetcare/binary_sensor.py
|
||||||
homeassistant/components/surepetcare/sensor.py
|
homeassistant/components/surepetcare/sensor.py
|
||||||
homeassistant/components/swiss_hydrological_data/sensor.py
|
homeassistant/components/swiss_hydrological_data/sensor.py
|
||||||
homeassistant/components/swiss_public_transport/sensor.py
|
homeassistant/components/swiss_public_transport/sensor.py
|
||||||
|
|
|
@ -138,7 +138,7 @@ class SurePetcareAPI:
|
||||||
"""Initialize the Sure Petcare object."""
|
"""Initialize the Sure Petcare object."""
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
self.surepy = surepy
|
self.surepy = surepy
|
||||||
self.states = {}
|
self.states: dict[int, Any] = {}
|
||||||
|
|
||||||
async def async_update(self, _: Any = None) -> None:
|
async def async_update(self, _: Any = None) -> None:
|
||||||
"""Get the latest data from Sure Petcare."""
|
"""Get the latest data from Sure Petcare."""
|
||||||
|
|
|
@ -28,7 +28,7 @@ async def async_setup_platform(
|
||||||
if discovery_info is None:
|
if discovery_info is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
entities: list[SurepyEntity] = []
|
entities: list[SurepyEntity | Pet | Hub | DeviceConnectivity] = []
|
||||||
|
|
||||||
spc: SurePetcareAPI = hass.data[DOMAIN][SPC]
|
spc: SurePetcareAPI = hass.data[DOMAIN][SPC]
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ class Hub(SurePetcareBinarySensor):
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
self._attr_extra_state_attributes = None
|
self._attr_extra_state_attributes = {}
|
||||||
_LOGGER.debug("%s -> state: %s", self.name, state)
|
_LOGGER.debug("%s -> state: %s", self.name, state)
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ class Pet(SurePetcareBinarySensor):
|
||||||
"where": state.where,
|
"where": state.where,
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
self._attr_extra_state_attributes = None
|
self._attr_extra_state_attributes = {}
|
||||||
_LOGGER.debug("%s -> state: %s", self.name, state)
|
_LOGGER.debug("%s -> state: %s", self.name, state)
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
|
@ -171,6 +171,6 @@ class DeviceConnectivity(SurePetcareBinarySensor):
|
||||||
"hub_rssi": f'{state["signal"]["hub_rssi"]:.2f}',
|
"hub_rssi": f'{state["signal"]["hub_rssi"]:.2f}',
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
self._attr_extra_state_attributes = None
|
self._attr_extra_state_attributes = {}
|
||||||
_LOGGER.debug("%s -> state: %s", self.name, state)
|
_LOGGER.debug("%s -> state: %s", self.name, state)
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
|
@ -59,7 +59,10 @@ class SureBattery(SensorEntity):
|
||||||
surepy_entity: SurepyEntity = self._spc.states[_id]
|
surepy_entity: SurepyEntity = self._spc.states[_id]
|
||||||
|
|
||||||
self._attr_device_class = DEVICE_CLASS_BATTERY
|
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_native_unit_of_measurement = PERCENTAGE
|
||||||
self._attr_unique_id = (
|
self._attr_unique_id = (
|
||||||
f"{surepy_entity.household_id}-{surepy_entity.id}-battery"
|
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}",
|
f"{ATTR_VOLTAGE}_per_battery": f"{voltage_per_battery:.2f}",
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
self._attr_extra_state_attributes = None
|
self._attr_extra_state_attributes = {}
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
_LOGGER.debug("%s -> state: %s", self.name, state)
|
_LOGGER.debug("%s -> state: %s", self.name, state)
|
||||||
|
|
||||||
|
|
3
mypy.ini
3
mypy.ini
|
@ -1601,9 +1601,6 @@ ignore_errors = true
|
||||||
[mypy-homeassistant.components.stt.*]
|
[mypy-homeassistant.components.stt.*]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
[mypy-homeassistant.components.surepetcare.*]
|
|
||||||
ignore_errors = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.switchbot.*]
|
[mypy-homeassistant.components.switchbot.*]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,6 @@ IGNORED_MODULES: Final[list[str]] = [
|
||||||
"homeassistant.components.sonos.*",
|
"homeassistant.components.sonos.*",
|
||||||
"homeassistant.components.spotify.*",
|
"homeassistant.components.spotify.*",
|
||||||
"homeassistant.components.stt.*",
|
"homeassistant.components.stt.*",
|
||||||
"homeassistant.components.surepetcare.*",
|
|
||||||
"homeassistant.components.switchbot.*",
|
"homeassistant.components.switchbot.*",
|
||||||
"homeassistant.components.system_health.*",
|
"homeassistant.components.system_health.*",
|
||||||
"homeassistant.components.system_log.*",
|
"homeassistant.components.system_log.*",
|
||||||
|
|
Loading…
Add table
Reference in a new issue