mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Perform some RainMachine code cleanup (#58865)
This commit is contained in:
parent
5b5b79f0e5
commit
568df3d972
@ -13,7 +13,6 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ATTRIBUTION,
|
|
||||||
CONF_DEVICE_ID,
|
CONF_DEVICE_ID,
|
||||||
CONF_IP_ADDRESS,
|
CONF_IP_ADDRESS,
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
@ -166,9 +165,6 @@ async def async_update_programs_and_zones(
|
|||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up RainMachine as config entry."""
|
"""Set up RainMachine as config entry."""
|
||||||
hass.data.setdefault(DOMAIN, {})
|
|
||||||
hass.data[DOMAIN][entry.entry_id] = {}
|
|
||||||
|
|
||||||
websession = aiohttp_client.async_get_clientsession(hass)
|
websession = aiohttp_client.async_get_clientsession(hass)
|
||||||
client = Client(session=websession)
|
client = Client(session=websession)
|
||||||
|
|
||||||
@ -184,9 +180,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
# regenmaschine can load multiple controllers at once, but we only grab the one
|
# regenmaschine can load multiple controllers at once, but we only grab the one
|
||||||
# we loaded above:
|
# we loaded above:
|
||||||
controller = hass.data[DOMAIN][entry.entry_id][
|
controller = get_client_controller(client)
|
||||||
DATA_CONTROLLER
|
|
||||||
] = get_client_controller(client)
|
|
||||||
|
|
||||||
entry_updates: dict[str, Any] = {}
|
entry_updates: dict[str, Any] = {}
|
||||||
if not entry.unique_id or is_ip_address(entry.unique_id):
|
if not entry.unique_id or is_ip_address(entry.unique_id):
|
||||||
@ -244,7 +238,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
controller_init_tasks.append(coordinator.async_refresh())
|
controller_init_tasks.append(coordinator.async_refresh())
|
||||||
|
|
||||||
await asyncio.gather(*controller_init_tasks)
|
await asyncio.gather(*controller_init_tasks)
|
||||||
hass.data[DOMAIN][entry.entry_id][DATA_COORDINATOR] = coordinators
|
|
||||||
|
hass.data.setdefault(DOMAIN, {})
|
||||||
|
hass.data[DOMAIN][entry.entry_id] = {
|
||||||
|
DATA_CONTROLLER: controller,
|
||||||
|
DATA_COORDINATOR: coordinators,
|
||||||
|
}
|
||||||
|
|
||||||
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
|
|
||||||
@ -354,7 +353,7 @@ class RainMachineEntity(CoordinatorEntity):
|
|||||||
),
|
),
|
||||||
sw_version=controller.software_version,
|
sw_version=controller.software_version,
|
||||||
)
|
)
|
||||||
self._attr_extra_state_attributes = {ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION}
|
self._attr_extra_state_attributes = {}
|
||||||
self._attr_name = f"{controller.name} {description.name}"
|
self._attr_name = f"{controller.name} {description.name}"
|
||||||
# The colons are removed from the device MAC simply because that value
|
# The colons are removed from the device MAC simply because that value
|
||||||
# (unnecessarily) makes up the existing unique ID formula and we want to avoid
|
# (unnecessarily) makes up the existing unique ID formula and we want to avoid
|
||||||
|
Loading…
x
Reference in New Issue
Block a user