DSMR: Complete full strictly typed (#52162)
This commit is contained in:
parent
fba7118d44
commit
a2be9a487f
4 changed files with 20 additions and 5 deletions
|
@ -26,6 +26,7 @@ homeassistant.components.cover.*
|
||||||
homeassistant.components.device_automation.*
|
homeassistant.components.device_automation.*
|
||||||
homeassistant.components.device_tracker.*
|
homeassistant.components.device_tracker.*
|
||||||
homeassistant.components.dnsip.*
|
homeassistant.components.dnsip.*
|
||||||
|
homeassistant.components.dsmr.*
|
||||||
homeassistant.components.dunehd.*
|
homeassistant.components.dunehd.*
|
||||||
homeassistant.components.elgato.*
|
homeassistant.components.elgato.*
|
||||||
homeassistant.components.fitbit.*
|
homeassistant.components.fitbit.*
|
||||||
|
|
|
@ -51,14 +51,16 @@ class DSMRConnection:
|
||||||
"""Equipment identifier."""
|
"""Equipment identifier."""
|
||||||
if self._equipment_identifier in self._telegram:
|
if self._equipment_identifier in self._telegram:
|
||||||
dsmr_object = self._telegram[self._equipment_identifier]
|
dsmr_object = self._telegram[self._equipment_identifier]
|
||||||
return getattr(dsmr_object, "value", None)
|
identifier: str | None = getattr(dsmr_object, "value", None)
|
||||||
|
return identifier
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def equipment_identifier_gas(self) -> str | None:
|
def equipment_identifier_gas(self) -> str | None:
|
||||||
"""Equipment identifier gas."""
|
"""Equipment identifier gas."""
|
||||||
if obis_ref.EQUIPMENT_IDENTIFIER_GAS in self._telegram:
|
if obis_ref.EQUIPMENT_IDENTIFIER_GAS in self._telegram:
|
||||||
dsmr_object = self._telegram[obis_ref.EQUIPMENT_IDENTIFIER_GAS]
|
dsmr_object = self._telegram[obis_ref.EQUIPMENT_IDENTIFIER_GAS]
|
||||||
return getattr(dsmr_object, "value", None)
|
identifier: str | None = getattr(dsmr_object, "value", None)
|
||||||
|
return identifier
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def validate_connect(self, hass: core.HomeAssistant) -> bool:
|
async def validate_connect(self, hass: core.HomeAssistant) -> bool:
|
||||||
|
@ -142,7 +144,7 @@ class DSMRFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
def _abort_if_host_port_configured(
|
def _abort_if_host_port_configured(
|
||||||
self,
|
self,
|
||||||
port: str,
|
port: str,
|
||||||
host: str = None,
|
host: str | None = None,
|
||||||
updates: dict[Any, Any] | None = None,
|
updates: dict[Any, Any] | None = None,
|
||||||
reload_on_update: bool = True,
|
reload_on_update: bool = True,
|
||||||
) -> FlowResult | None:
|
) -> FlowResult | None:
|
||||||
|
|
|
@ -89,7 +89,7 @@ async def async_setup_entry(
|
||||||
)
|
)
|
||||||
|
|
||||||
@Throttle(min_time_between_updates)
|
@Throttle(min_time_between_updates)
|
||||||
def update_entities_telegram(telegram: dict[str, DSMRObject]):
|
def update_entities_telegram(telegram: dict[str, DSMRObject]) -> None:
|
||||||
"""Update entities with latest telegram and trigger state update."""
|
"""Update entities with latest telegram and trigger state update."""
|
||||||
# Make all device entities aware of new telegram
|
# Make all device entities aware of new telegram
|
||||||
for entity in entities:
|
for entity in entities:
|
||||||
|
@ -222,7 +222,8 @@ class DSMREntity(SensorEntity):
|
||||||
|
|
||||||
# Get the attribute value if the object has it
|
# Get the attribute value if the object has it
|
||||||
dsmr_object = self.telegram[self._sensor.obis_reference]
|
dsmr_object = self.telegram[self._sensor.obis_reference]
|
||||||
return getattr(dsmr_object, attribute, None)
|
attr: str | None = getattr(dsmr_object, attribute)
|
||||||
|
return attr
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self) -> StateType:
|
def state(self) -> StateType:
|
||||||
|
|
11
mypy.ini
11
mypy.ini
|
@ -297,6 +297,17 @@ no_implicit_optional = true
|
||||||
warn_return_any = true
|
warn_return_any = true
|
||||||
warn_unreachable = true
|
warn_unreachable = true
|
||||||
|
|
||||||
|
[mypy-homeassistant.components.dsmr.*]
|
||||||
|
check_untyped_defs = true
|
||||||
|
disallow_incomplete_defs = true
|
||||||
|
disallow_subclassing_any = true
|
||||||
|
disallow_untyped_calls = true
|
||||||
|
disallow_untyped_decorators = true
|
||||||
|
disallow_untyped_defs = true
|
||||||
|
no_implicit_optional = true
|
||||||
|
warn_return_any = true
|
||||||
|
warn_unreachable = true
|
||||||
|
|
||||||
[mypy-homeassistant.components.dunehd.*]
|
[mypy-homeassistant.components.dunehd.*]
|
||||||
check_untyped_defs = true
|
check_untyped_defs = true
|
||||||
disallow_incomplete_defs = true
|
disallow_incomplete_defs = true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue