mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Add Roborock to strict typing (#120379)
This commit is contained in:
parent
0d2aeb846f
commit
69e0227682
@ -370,6 +370,7 @@ homeassistant.components.rhasspy.*
|
|||||||
homeassistant.components.ridwell.*
|
homeassistant.components.ridwell.*
|
||||||
homeassistant.components.ring.*
|
homeassistant.components.ring.*
|
||||||
homeassistant.components.rituals_perfume_genie.*
|
homeassistant.components.rituals_perfume_genie.*
|
||||||
|
homeassistant.components.roborock.*
|
||||||
homeassistant.components.roku.*
|
homeassistant.components.roku.*
|
||||||
homeassistant.components.romy.*
|
homeassistant.components.romy.*
|
||||||
homeassistant.components.rpi_power.*
|
homeassistant.components.rpi_power.*
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
"""Support for Roborock image."""
|
"""Support for Roborock image."""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from datetime import datetime
|
||||||
import io
|
import io
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
|
||||||
@ -48,6 +49,7 @@ class RoborockMap(RoborockCoordinatedEntity, ImageEntity):
|
|||||||
"""A class to let you visualize the map."""
|
"""A class to let you visualize the map."""
|
||||||
|
|
||||||
_attr_has_entity_name = True
|
_attr_has_entity_name = True
|
||||||
|
image_last_updated: datetime
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -76,7 +78,7 @@ class RoborockMap(RoborockCoordinatedEntity, ImageEntity):
|
|||||||
self._attr_entity_category = EntityCategory.DIAGNOSTIC
|
self._attr_entity_category = EntityCategory.DIAGNOSTIC
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self):
|
def available(self) -> bool:
|
||||||
"""Determines if the entity is available."""
|
"""Determines if the entity is available."""
|
||||||
return self.cached_map != b""
|
return self.cached_map != b""
|
||||||
|
|
||||||
@ -98,7 +100,7 @@ class RoborockMap(RoborockCoordinatedEntity, ImageEntity):
|
|||||||
and bool(self.coordinator.roborock_device_info.props.status.in_cleaning)
|
and bool(self.coordinator.roborock_device_info.props.status.in_cleaning)
|
||||||
)
|
)
|
||||||
|
|
||||||
def _handle_coordinator_update(self):
|
def _handle_coordinator_update(self) -> None:
|
||||||
# Bump last updated every third time the coordinator runs, so that async_image
|
# Bump last updated every third time the coordinator runs, so that async_image
|
||||||
# will be called and we will evaluate on the new coordinator data if we should
|
# will be called and we will evaluate on the new coordinator data if we should
|
||||||
# update the cache.
|
# update the cache.
|
||||||
|
@ -107,7 +107,8 @@ class RoborockNumberEntity(RoborockEntity, NumberEntity):
|
|||||||
@property
|
@property
|
||||||
def native_value(self) -> float | None:
|
def native_value(self) -> float | None:
|
||||||
"""Get native value."""
|
"""Get native value."""
|
||||||
return self.get_cache(self.entity_description.cache_key).value
|
val: float = self.get_cache(self.entity_description.cache_key).value
|
||||||
|
return val
|
||||||
|
|
||||||
async def async_set_native_value(self, value: float) -> None:
|
async def async_set_native_value(self, value: float) -> None:
|
||||||
"""Set number value."""
|
"""Set number value."""
|
||||||
|
@ -167,9 +167,9 @@ class RoborockSwitch(RoborockEntity, SwitchEntity):
|
|||||||
@property
|
@property
|
||||||
def is_on(self) -> bool | None:
|
def is_on(self) -> bool | None:
|
||||||
"""Return True if entity is on."""
|
"""Return True if entity is on."""
|
||||||
return (
|
status = self.get_cache(self.entity_description.cache_key).value.get(
|
||||||
self.get_cache(self.entity_description.cache_key).value.get(
|
self.entity_description.attribute
|
||||||
self.entity_description.attribute
|
|
||||||
)
|
|
||||||
== 1
|
|
||||||
)
|
)
|
||||||
|
if status is None:
|
||||||
|
return status
|
||||||
|
return bool(status)
|
||||||
|
10
mypy.ini
10
mypy.ini
@ -3463,6 +3463,16 @@ disallow_untyped_defs = true
|
|||||||
warn_return_any = true
|
warn_return_any = true
|
||||||
warn_unreachable = true
|
warn_unreachable = true
|
||||||
|
|
||||||
|
[mypy-homeassistant.components.roborock.*]
|
||||||
|
check_untyped_defs = true
|
||||||
|
disallow_incomplete_defs = true
|
||||||
|
disallow_subclassing_any = true
|
||||||
|
disallow_untyped_calls = true
|
||||||
|
disallow_untyped_decorators = true
|
||||||
|
disallow_untyped_defs = true
|
||||||
|
warn_return_any = true
|
||||||
|
warn_unreachable = true
|
||||||
|
|
||||||
[mypy-homeassistant.components.roku.*]
|
[mypy-homeassistant.components.roku.*]
|
||||||
check_untyped_defs = true
|
check_untyped_defs = true
|
||||||
disallow_incomplete_defs = true
|
disallow_incomplete_defs = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user