mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 08:47:10 +00:00
Remove solaredge from mypy ignore list (#74983)
This commit is contained in:
parent
9d2c213903
commit
5f4713a200
@ -23,7 +23,7 @@ class SolarEdgeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
"""Initialize the config flow."""
|
"""Initialize the config flow."""
|
||||||
self._errors = {}
|
self._errors: dict[str, str] = {}
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_current_site_ids(self) -> set[str]:
|
def _async_current_site_ids(self) -> set[str]:
|
||||||
|
@ -75,6 +75,7 @@ SENSOR_TYPES = [
|
|||||||
),
|
),
|
||||||
SolarEdgeSensorEntityDescription(
|
SolarEdgeSensorEntityDescription(
|
||||||
key="site_details",
|
key="site_details",
|
||||||
|
json_key="status",
|
||||||
name="Site details",
|
name="Site details",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
from datetime import date, datetime, timedelta
|
from datetime import date, datetime, timedelta
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from solaredge import Solaredge
|
from solaredge import Solaredge
|
||||||
from stringcase import snakecase
|
from stringcase import snakecase
|
||||||
@ -23,16 +24,17 @@ from .const import (
|
|||||||
class SolarEdgeDataService:
|
class SolarEdgeDataService:
|
||||||
"""Get and update the latest data."""
|
"""Get and update the latest data."""
|
||||||
|
|
||||||
|
coordinator: DataUpdateCoordinator
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant, api: Solaredge, site_id: str) -> None:
|
def __init__(self, hass: HomeAssistant, api: Solaredge, site_id: str) -> None:
|
||||||
"""Initialize the data object."""
|
"""Initialize the data object."""
|
||||||
self.api = api
|
self.api = api
|
||||||
self.site_id = site_id
|
self.site_id = site_id
|
||||||
|
|
||||||
self.data = {}
|
self.data: dict[str, Any] = {}
|
||||||
self.attributes = {}
|
self.attributes: dict[str, Any] = {}
|
||||||
|
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
self.coordinator = None
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_setup(self) -> None:
|
def async_setup(self) -> None:
|
||||||
@ -105,12 +107,6 @@ class SolarEdgeOverviewDataService(SolarEdgeDataService):
|
|||||||
class SolarEdgeDetailsDataService(SolarEdgeDataService):
|
class SolarEdgeDetailsDataService(SolarEdgeDataService):
|
||||||
"""Get and update the latest details data."""
|
"""Get and update the latest details data."""
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant, api: Solaredge, site_id: str) -> None:
|
|
||||||
"""Initialize the details data service."""
|
|
||||||
super().__init__(hass, api, site_id)
|
|
||||||
|
|
||||||
self.data = None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def update_interval(self) -> timedelta:
|
def update_interval(self) -> timedelta:
|
||||||
"""Update interval."""
|
"""Update interval."""
|
||||||
@ -125,7 +121,7 @@ class SolarEdgeDetailsDataService(SolarEdgeDataService):
|
|||||||
except KeyError as ex:
|
except KeyError as ex:
|
||||||
raise UpdateFailed("Missing details data, skipping update") from ex
|
raise UpdateFailed("Missing details data, skipping update") from ex
|
||||||
|
|
||||||
self.data = None
|
self.data = {}
|
||||||
self.attributes = {}
|
self.attributes = {}
|
||||||
|
|
||||||
for key, value in details.items():
|
for key, value in details.items():
|
||||||
@ -143,9 +139,13 @@ class SolarEdgeDetailsDataService(SolarEdgeDataService):
|
|||||||
]:
|
]:
|
||||||
self.attributes[key] = value
|
self.attributes[key] = value
|
||||||
elif key == "status":
|
elif key == "status":
|
||||||
self.data = value
|
self.data["status"] = value
|
||||||
|
|
||||||
LOGGER.debug("Updated SolarEdge details: %s, %s", self.data, self.attributes)
|
LOGGER.debug(
|
||||||
|
"Updated SolarEdge details: %s, %s",
|
||||||
|
self.data.get("status"),
|
||||||
|
self.attributes,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class SolarEdgeInventoryDataService(SolarEdgeDataService):
|
class SolarEdgeInventoryDataService(SolarEdgeDataService):
|
||||||
|
@ -7,7 +7,14 @@ from homeassistant.components.sensor import SensorEntityDescription
|
|||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class SolarEdgeSensorEntityDescription(SensorEntityDescription):
|
class SolarEdgeSensorEntityRequiredKeyMixin:
|
||||||
"""Sensor entity description for SolarEdge."""
|
"""Sensor entity description with json_key for SolarEdge."""
|
||||||
|
|
||||||
json_key: str | None = None
|
json_key: str
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class SolarEdgeSensorEntityDescription(
|
||||||
|
SensorEntityDescription, SolarEdgeSensorEntityRequiredKeyMixin
|
||||||
|
):
|
||||||
|
"""Sensor entity description for SolarEdge."""
|
||||||
|
@ -101,7 +101,7 @@ class SolarEdgeSensorFactory:
|
|||||||
|
|
||||||
def create_sensor(
|
def create_sensor(
|
||||||
self, sensor_type: SolarEdgeSensorEntityDescription
|
self, sensor_type: SolarEdgeSensorEntityDescription
|
||||||
) -> SolarEdgeSensorEntityDescription:
|
) -> SolarEdgeSensorEntity:
|
||||||
"""Create and return a sensor based on the sensor_key."""
|
"""Create and return a sensor based on the sensor_key."""
|
||||||
sensor_class, service = self.services[sensor_type.key]
|
sensor_class, service = self.services[sensor_type.key]
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ class SolarEdgeDetailsSensor(SolarEdgeSensorEntity):
|
|||||||
@property
|
@property
|
||||||
def native_value(self) -> str | None:
|
def native_value(self) -> str | None:
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
return self.data_service.data
|
return self.data_service.data.get(self.entity_description.json_key)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str | None:
|
def unique_id(self) -> str | None:
|
||||||
@ -169,7 +169,7 @@ class SolarEdgeInventorySensor(SolarEdgeSensorEntity):
|
|||||||
"""Representation of an SolarEdge Monitoring API inventory sensor."""
|
"""Representation of an SolarEdge Monitoring API inventory sensor."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self) -> dict[str, Any]:
|
def extra_state_attributes(self) -> dict[str, Any] | None:
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
return self.data_service.attributes.get(self.entity_description.json_key)
|
return self.data_service.attributes.get(self.entity_description.json_key)
|
||||||
|
|
||||||
@ -182,14 +182,19 @@ class SolarEdgeInventorySensor(SolarEdgeSensorEntity):
|
|||||||
class SolarEdgeEnergyDetailsSensor(SolarEdgeSensorEntity):
|
class SolarEdgeEnergyDetailsSensor(SolarEdgeSensorEntity):
|
||||||
"""Representation of an SolarEdge Monitoring API power flow sensor."""
|
"""Representation of an SolarEdge Monitoring API power flow sensor."""
|
||||||
|
|
||||||
def __init__(self, platform_name, sensor_type, data_service):
|
def __init__(
|
||||||
|
self,
|
||||||
|
platform_name: str,
|
||||||
|
sensor_type: SolarEdgeSensorEntityDescription,
|
||||||
|
data_service: SolarEdgeEnergyDetailsService,
|
||||||
|
) -> None:
|
||||||
"""Initialize the power flow sensor."""
|
"""Initialize the power flow sensor."""
|
||||||
super().__init__(platform_name, sensor_type, data_service)
|
super().__init__(platform_name, sensor_type, data_service)
|
||||||
|
|
||||||
self._attr_native_unit_of_measurement = data_service.unit
|
self._attr_native_unit_of_measurement = data_service.unit
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self) -> dict[str, Any]:
|
def extra_state_attributes(self) -> dict[str, Any] | None:
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
return self.data_service.attributes.get(self.entity_description.json_key)
|
return self.data_service.attributes.get(self.entity_description.json_key)
|
||||||
|
|
||||||
@ -208,7 +213,7 @@ class SolarEdgePowerFlowSensor(SolarEdgeSensorEntity):
|
|||||||
self,
|
self,
|
||||||
platform_name: str,
|
platform_name: str,
|
||||||
description: SolarEdgeSensorEntityDescription,
|
description: SolarEdgeSensorEntityDescription,
|
||||||
data_service: SolarEdgeDataService,
|
data_service: SolarEdgePowerFlowDataService,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the power flow sensor."""
|
"""Initialize the power flow sensor."""
|
||||||
super().__init__(platform_name, description, data_service)
|
super().__init__(platform_name, description, data_service)
|
||||||
@ -216,7 +221,7 @@ class SolarEdgePowerFlowSensor(SolarEdgeSensorEntity):
|
|||||||
self._attr_native_unit_of_measurement = data_service.unit
|
self._attr_native_unit_of_measurement = data_service.unit
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self) -> dict[str, Any]:
|
def extra_state_attributes(self) -> dict[str, Any] | None:
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
return self.data_service.attributes.get(self.entity_description.json_key)
|
return self.data_service.attributes.get(self.entity_description.json_key)
|
||||||
|
|
||||||
|
9
mypy.ini
9
mypy.ini
@ -2750,15 +2750,6 @@ ignore_errors = true
|
|||||||
[mypy-homeassistant.components.profiler]
|
[mypy-homeassistant.components.profiler]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
[mypy-homeassistant.components.solaredge.config_flow]
|
|
||||||
ignore_errors = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.solaredge.coordinator]
|
|
||||||
ignore_errors = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.solaredge.sensor]
|
|
||||||
ignore_errors = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.sonos]
|
[mypy-homeassistant.components.sonos]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
|
@ -51,9 +51,6 @@ IGNORED_MODULES: Final[list[str]] = [
|
|||||||
"homeassistant.components.onvif.sensor",
|
"homeassistant.components.onvif.sensor",
|
||||||
"homeassistant.components.plex.media_player",
|
"homeassistant.components.plex.media_player",
|
||||||
"homeassistant.components.profiler",
|
"homeassistant.components.profiler",
|
||||||
"homeassistant.components.solaredge.config_flow",
|
|
||||||
"homeassistant.components.solaredge.coordinator",
|
|
||||||
"homeassistant.components.solaredge.sensor",
|
|
||||||
"homeassistant.components.sonos",
|
"homeassistant.components.sonos",
|
||||||
"homeassistant.components.sonos.alarms",
|
"homeassistant.components.sonos.alarms",
|
||||||
"homeassistant.components.sonos.binary_sensor",
|
"homeassistant.components.sonos.binary_sensor",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user