Use dataclass to carry data in ping (#99803)

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Jan-Philipp Benecke 2023-10-20 23:46:33 +02:00 committed by GitHub
parent b881057aa6
commit 3c455391c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 11 deletions

View file

@ -25,7 +25,8 @@ from homeassistant.util import dt as dt_util
from homeassistant.util.async_ import gather_with_limited_concurrency
from homeassistant.util.process import kill_subprocess
from .const import DOMAIN, ICMP_TIMEOUT, PING_ATTEMPTS_COUNT, PING_PRIVS, PING_TIMEOUT
from . import PingDomainData
from .const import DOMAIN, ICMP_TIMEOUT, PING_ATTEMPTS_COUNT, PING_TIMEOUT
_LOGGER = logging.getLogger(__name__)
@ -97,7 +98,9 @@ async def async_setup_scanner(
) -> bool:
"""Set up the Host objects and return the update function."""
privileged = hass.data[DOMAIN][PING_PRIVS]
data: PingDomainData = hass.data[DOMAIN]
privileged = data.privileged
ip_to_dev_id = {ip: dev_id for (dev_id, ip) in config[CONF_HOSTS].items()}
interval = config.get(
CONF_SCAN_INTERVAL,