mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 22:07:10 +00:00
Migrate lupusec to use runtime_data (#147476)
This commit is contained in:
parent
10d1affd81
commit
2bcdc03661
@ -12,8 +12,6 @@ from homeassistant.core import HomeAssistant
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DOMAIN = "lupusec"
|
||||
|
||||
NOTIFICATION_ID = "lupusec_notification"
|
||||
NOTIFICATION_TITLE = "Lupusec Security Setup"
|
||||
|
||||
@ -24,8 +22,10 @@ PLATFORMS: list[Platform] = [
|
||||
Platform.SWITCH,
|
||||
]
|
||||
|
||||
type LupusecConfigEntry = ConfigEntry[lupupy.Lupusec]
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: LupusecConfigEntry) -> bool:
|
||||
"""Set up this integration using UI."""
|
||||
|
||||
host = entry.data[CONF_HOST]
|
||||
@ -43,7 +43,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
_LOGGER.error("Failed to connect to Lupusec device at %s", host)
|
||||
return False
|
||||
|
||||
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = lupusec_system
|
||||
entry.runtime_data = lupusec_system
|
||||
|
||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||
|
||||
|
@ -11,12 +11,12 @@ from homeassistant.components.alarm_control_panel import (
|
||||
AlarmControlPanelEntityFeature,
|
||||
AlarmControlPanelState,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
||||
from . import DOMAIN
|
||||
from . import LupusecConfigEntry
|
||||
from .const import DOMAIN
|
||||
from .entity import LupusecDevice
|
||||
|
||||
SCAN_INTERVAL = timedelta(seconds=2)
|
||||
@ -24,11 +24,11 @@ SCAN_INTERVAL = timedelta(seconds=2)
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
config_entry: LupusecConfigEntry,
|
||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up an alarm control panel for a Lupusec device."""
|
||||
data = hass.data[DOMAIN][config_entry.entry_id]
|
||||
data = config_entry.runtime_data
|
||||
|
||||
alarm = await hass.async_add_executor_job(data.get_alarm)
|
||||
|
||||
|
@ -12,11 +12,10 @@ 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 AddConfigEntryEntitiesCallback
|
||||
|
||||
from . import DOMAIN
|
||||
from . import LupusecConfigEntry
|
||||
from .entity import LupusecBaseSensor
|
||||
|
||||
SCAN_INTERVAL = timedelta(seconds=2)
|
||||
@ -26,12 +25,12 @@ _LOGGER = logging.getLogger(__name__)
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
config_entry: LupusecConfigEntry,
|
||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up a binary sensors for a Lupusec device."""
|
||||
|
||||
data = hass.data[DOMAIN][config_entry.entry_id]
|
||||
data = config_entry.runtime_data
|
||||
|
||||
device_types = CONST.TYPE_OPENING + CONST.TYPE_SENSOR
|
||||
|
||||
|
@ -9,11 +9,10 @@ from typing import Any
|
||||
import lupupy.constants as CONST
|
||||
|
||||
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 . import DOMAIN
|
||||
from . import LupusecConfigEntry
|
||||
from .entity import LupusecBaseSensor
|
||||
|
||||
SCAN_INTERVAL = timedelta(seconds=2)
|
||||
@ -21,12 +20,12 @@ SCAN_INTERVAL = timedelta(seconds=2)
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
config_entry: LupusecConfigEntry,
|
||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up Lupusec switch devices."""
|
||||
|
||||
data = hass.data[DOMAIN][config_entry.entry_id]
|
||||
data = config_entry.runtime_data
|
||||
|
||||
device_types = CONST.TYPE_SWITCH
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user