Compare commits

...

3 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
7d10c45fbc Rename ProgettihwswConfigEntry to ProgettiHWSWConfigEntry
Agent-Logs-Url: https://github.com/home-assistant/core/sessions/27e905d8-a0a6-4cf2-8ac3-e3c38f9a14ac

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2026-04-02 07:34:59 +00:00
copilot-swe-agent[bot]
4a3ced3059 Initial plan 2026-04-02 07:32:59 +00:00
epenet
8fe6072bff Migrate progettihwsw to use runtime_data
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 07:20:03 +00:00
3 changed files with 23 additions and 26 deletions

View File

@@ -8,33 +8,32 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from .const import DOMAIN
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SWITCH]
type ProgettiHWSWConfigEntry = ConfigEntry[ProgettiHWSWAPI]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def async_setup_entry(
hass: HomeAssistant, entry: ProgettiHWSWConfigEntry
) -> bool:
"""Set up ProgettiHWSW Automation from a config entry."""
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = ProgettiHWSWAPI(
f"{entry.data['host']}:{entry.data['port']}"
)
api = ProgettiHWSWAPI(f"{entry.data['host']}:{entry.data['port']}")
# Check board validation again to load new values to API.
await hass.data[DOMAIN][entry.entry_id].check_board()
await api.check_board()
entry.runtime_data = api
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
return True
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def async_unload_entry(
hass: HomeAssistant, entry: ProgettiHWSWConfigEntry
) -> bool:
"""Unload a config entry."""
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unload_ok:
hass.data[DOMAIN].pop(entry.entry_id)
return unload_ok
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
def setup_input(api: ProgettiHWSWAPI, input_number: int) -> Input:

View File

@@ -7,7 +7,6 @@ import logging
from ProgettiHWSW.input import Input
from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from homeassistant.helpers.update_coordinator import (
@@ -15,19 +14,19 @@ from homeassistant.helpers.update_coordinator import (
DataUpdateCoordinator,
)
from . import setup_input
from .const import DEFAULT_POLLING_INTERVAL_SEC, DOMAIN
from . import ProgettiHWSWConfigEntry, setup_input
from .const import DEFAULT_POLLING_INTERVAL_SEC
_LOGGER = logging.getLogger(DOMAIN)
_LOGGER = logging.getLogger(__name__)
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
config_entry: ProgettiHWSWConfigEntry,
async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
"""Set up the binary sensors from a config entry."""
board_api = hass.data[DOMAIN][config_entry.entry_id]
board_api = config_entry.runtime_data
input_count = config_entry.data["input_count"]
async def async_update_data():

View File

@@ -8,7 +8,6 @@ from typing import Any
from ProgettiHWSW.relay import Relay
from homeassistant.components.switch import SwitchEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from homeassistant.helpers.update_coordinator import (
@@ -16,19 +15,19 @@ from homeassistant.helpers.update_coordinator import (
DataUpdateCoordinator,
)
from . import setup_switch
from .const import DEFAULT_POLLING_INTERVAL_SEC, DOMAIN
from . import ProgettiHWSWConfigEntry, setup_switch
from .const import DEFAULT_POLLING_INTERVAL_SEC
_LOGGER = logging.getLogger(DOMAIN)
_LOGGER = logging.getLogger(__name__)
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
config_entry: ProgettiHWSWConfigEntry,
async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
"""Set up the switches from a config entry."""
board_api = hass.data[DOMAIN][config_entry.entry_id]
board_api = config_entry.runtime_data
relay_count = config_entry.data["relay_count"]
async def async_update_data():