Convert powerwall to use entry.runtime_data (#121643)

This commit is contained in:
J. Nick Koston 2024-07-09 23:20:29 -07:00 committed by GitHub
parent 9120115577
commit 8d0d8fd006
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 29 additions and 30 deletions

View file

@ -8,13 +8,11 @@ from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,
BinarySensorEntity,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DOMAIN
from .entity import PowerWallEntity
from .models import PowerwallRuntimeData
from .models import PowerwallConfigEntry
CONNECTED_GRID_STATUSES = {
GridStatus.TRANSITION_TO_GRID,
@ -24,11 +22,11 @@ CONNECTED_GRID_STATUSES = {
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
entry: PowerwallConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the powerwall sensors."""
powerwall_data: PowerwallRuntimeData = hass.data[DOMAIN][config_entry.entry_id]
powerwall_data = entry.runtime_data
async_add_entities(
[
sensor_class(powerwall_data)