Use dataclass for abode system class (#101138)

This commit is contained in:
Jan Bouwhuis 2023-09-30 10:44:46 +02:00 committed by GitHub
parent 9444a474ec
commit 42eb849cae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
"""Support for the Abode Security System.""" """Support for the Abode Security System."""
from __future__ import annotations from __future__ import annotations
from dataclasses import dataclass, field
from functools import partial from functools import partial
from jaraco.abode.automation import Automation as AbodeAuto from jaraco.abode.automation import Automation as AbodeAuto
@ -25,7 +26,7 @@ from homeassistant.const import (
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
Platform, Platform,
) )
from homeassistant.core import Event, HomeAssistant, ServiceCall from homeassistant.core import CALLBACK_TYPE, Event, HomeAssistant, ServiceCall
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
from homeassistant.helpers import config_validation as cv, entity from homeassistant.helpers import config_validation as cv, entity
from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.device_registry import DeviceInfo
@ -71,15 +72,14 @@ PLATFORMS = [
] ]
@dataclass
class AbodeSystem: class AbodeSystem:
"""Abode System class.""" """Abode System class."""
def __init__(self, abode: Abode, polling: bool) -> None: abode: Abode
"""Initialize the system.""" polling: bool
self.abode = abode entity_ids: set[str | None] = field(default_factory=set)
self.polling = polling logout_listener: CALLBACK_TYPE | None = None
self.entity_ids: set[str | None] = set()
self.logout_listener = None
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: