mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Switch to a dataclass for lutron_caseta entry data (#73500)
This commit is contained in:
parent
77c92b0b77
commit
16dd70ba99
@ -32,11 +32,8 @@ from .const import (
|
|||||||
ATTR_LEAP_BUTTON_NUMBER,
|
ATTR_LEAP_BUTTON_NUMBER,
|
||||||
ATTR_SERIAL,
|
ATTR_SERIAL,
|
||||||
ATTR_TYPE,
|
ATTR_TYPE,
|
||||||
BRIDGE_DEVICE,
|
|
||||||
BRIDGE_DEVICE_ID,
|
BRIDGE_DEVICE_ID,
|
||||||
BRIDGE_LEAP,
|
|
||||||
BRIDGE_TIMEOUT,
|
BRIDGE_TIMEOUT,
|
||||||
BUTTON_DEVICES,
|
|
||||||
CONF_CA_CERTS,
|
CONF_CA_CERTS,
|
||||||
CONF_CERTFILE,
|
CONF_CERTFILE,
|
||||||
CONF_KEYFILE,
|
CONF_KEYFILE,
|
||||||
@ -50,6 +47,7 @@ from .device_trigger import (
|
|||||||
DEVICE_TYPE_SUBTYPE_MAP_TO_LIP,
|
DEVICE_TYPE_SUBTYPE_MAP_TO_LIP,
|
||||||
LEAP_TO_DEVICE_TYPE_SUBTYPE_MAP,
|
LEAP_TO_DEVICE_TYPE_SUBTYPE_MAP,
|
||||||
)
|
)
|
||||||
|
from .models import LutronCasetaData
|
||||||
from .util import serial_to_unique_id
|
from .util import serial_to_unique_id
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -186,11 +184,9 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
# Store this bridge (keyed by entry_id) so it can be retrieved by the
|
# Store this bridge (keyed by entry_id) so it can be retrieved by the
|
||||||
# platforms we're setting up.
|
# platforms we're setting up.
|
||||||
hass.data[DOMAIN][entry_id] = {
|
hass.data[DOMAIN][entry_id] = LutronCasetaData(
|
||||||
BRIDGE_LEAP: bridge,
|
bridge, bridge_device, button_devices
|
||||||
BRIDGE_DEVICE: bridge_device,
|
)
|
||||||
BUTTON_DEVICES: button_devices,
|
|
||||||
}
|
|
||||||
|
|
||||||
hass.config_entries.async_setup_platforms(config_entry, PLATFORMS)
|
hass.config_entries.async_setup_platforms(config_entry, PLATFORMS)
|
||||||
|
|
||||||
@ -319,9 +315,8 @@ async def async_unload_entry(
|
|||||||
hass: HomeAssistant, entry: config_entries.ConfigEntry
|
hass: HomeAssistant, entry: config_entries.ConfigEntry
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Unload the bridge bridge from a config entry."""
|
"""Unload the bridge bridge from a config entry."""
|
||||||
data = hass.data[DOMAIN][entry.entry_id]
|
data: LutronCasetaData = hass.data[DOMAIN][entry.entry_id]
|
||||||
smartbridge: Smartbridge = data[BRIDGE_LEAP]
|
await data.bridge.close()
|
||||||
await smartbridge.close()
|
|
||||||
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
|
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
return unload_ok
|
return unload_ok
|
||||||
@ -402,7 +397,8 @@ async def async_remove_config_entry_device(
|
|||||||
hass: HomeAssistant, entry: config_entries.ConfigEntry, device_entry: dr.DeviceEntry
|
hass: HomeAssistant, entry: config_entries.ConfigEntry, device_entry: dr.DeviceEntry
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Remove lutron_caseta config entry from a device."""
|
"""Remove lutron_caseta config entry from a device."""
|
||||||
bridge: Smartbridge = hass.data[DOMAIN][entry.entry_id][BRIDGE_LEAP]
|
data: LutronCasetaData = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
bridge = data.bridge
|
||||||
devices = bridge.get_devices()
|
devices = bridge.get_devices()
|
||||||
buttons = bridge.buttons
|
buttons = bridge.buttons
|
||||||
occupancy_groups = bridge.occupancy_groups
|
occupancy_groups = bridge.occupancy_groups
|
||||||
|
@ -12,7 +12,8 @@ from homeassistant.helpers.entity import DeviceInfo
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import DOMAIN as CASETA_DOMAIN, LutronCasetaDevice, _area_and_name_from_name
|
from . import DOMAIN as CASETA_DOMAIN, LutronCasetaDevice, _area_and_name_from_name
|
||||||
from .const import BRIDGE_DEVICE, BRIDGE_LEAP, CONFIG_URL, MANUFACTURER
|
from .const import CONFIG_URL, MANUFACTURER
|
||||||
|
from .models import LutronCasetaData
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
@ -25,9 +26,9 @@ async def async_setup_entry(
|
|||||||
Adds occupancy groups from the Caseta bridge associated with the
|
Adds occupancy groups from the Caseta bridge associated with the
|
||||||
config_entry as binary_sensor entities.
|
config_entry as binary_sensor entities.
|
||||||
"""
|
"""
|
||||||
data = hass.data[CASETA_DOMAIN][config_entry.entry_id]
|
data: LutronCasetaData = hass.data[CASETA_DOMAIN][config_entry.entry_id]
|
||||||
bridge = data[BRIDGE_LEAP]
|
bridge = data.bridge
|
||||||
bridge_device = data[BRIDGE_DEVICE]
|
bridge_device = data.bridge_device
|
||||||
occupancy_groups = bridge.occupancy_groups
|
occupancy_groups = bridge.occupancy_groups
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
LutronOccupancySensor(occupancy_group, bridge, bridge_device)
|
LutronOccupancySensor(occupancy_group, bridge, bridge_device)
|
||||||
|
@ -10,9 +10,6 @@ STEP_IMPORT_FAILED = "import_failed"
|
|||||||
ERROR_CANNOT_CONNECT = "cannot_connect"
|
ERROR_CANNOT_CONNECT = "cannot_connect"
|
||||||
ABORT_REASON_CANNOT_CONNECT = "cannot_connect"
|
ABORT_REASON_CANNOT_CONNECT = "cannot_connect"
|
||||||
|
|
||||||
BRIDGE_LEAP = "leap"
|
|
||||||
BRIDGE_DEVICE = "bridge_device"
|
|
||||||
BUTTON_DEVICES = "button_devices"
|
|
||||||
LUTRON_CASETA_BUTTON_EVENT = "lutron_caseta_button_event"
|
LUTRON_CASETA_BUTTON_EVENT = "lutron_caseta_button_event"
|
||||||
|
|
||||||
BRIDGE_DEVICE_ID = "1"
|
BRIDGE_DEVICE_ID = "1"
|
||||||
|
@ -12,7 +12,8 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import LutronCasetaDeviceUpdatableEntity
|
from . import LutronCasetaDeviceUpdatableEntity
|
||||||
from .const import BRIDGE_DEVICE, BRIDGE_LEAP, DOMAIN as CASETA_DOMAIN
|
from .const import DOMAIN as CASETA_DOMAIN
|
||||||
|
from .models import LutronCasetaData
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
@ -25,9 +26,9 @@ async def async_setup_entry(
|
|||||||
Adds shades from the Caseta bridge associated with the config_entry as
|
Adds shades from the Caseta bridge associated with the config_entry as
|
||||||
cover entities.
|
cover entities.
|
||||||
"""
|
"""
|
||||||
data = hass.data[CASETA_DOMAIN][config_entry.entry_id]
|
data: LutronCasetaData = hass.data[CASETA_DOMAIN][config_entry.entry_id]
|
||||||
bridge = data[BRIDGE_LEAP]
|
bridge = data.bridge
|
||||||
bridge_device = data[BRIDGE_DEVICE]
|
bridge_device = data.bridge_device
|
||||||
cover_devices = bridge.get_devices_by_domain(DOMAIN)
|
cover_devices = bridge.get_devices_by_domain(DOMAIN)
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
LutronCasetaCover(cover_device, bridge, bridge_device)
|
LutronCasetaCover(cover_device, bridge, bridge_device)
|
||||||
|
@ -29,11 +29,11 @@ from .const import (
|
|||||||
ATTR_ACTION,
|
ATTR_ACTION,
|
||||||
ATTR_BUTTON_NUMBER,
|
ATTR_BUTTON_NUMBER,
|
||||||
ATTR_SERIAL,
|
ATTR_SERIAL,
|
||||||
BUTTON_DEVICES,
|
|
||||||
CONF_SUBTYPE,
|
CONF_SUBTYPE,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
LUTRON_CASETA_BUTTON_EVENT,
|
LUTRON_CASETA_BUTTON_EVENT,
|
||||||
)
|
)
|
||||||
|
from .models import LutronCasetaData
|
||||||
|
|
||||||
SUPPORTED_INPUTS_EVENTS_TYPES = [ACTION_PRESS, ACTION_RELEASE]
|
SUPPORTED_INPUTS_EVENTS_TYPES = [ACTION_PRESS, ACTION_RELEASE]
|
||||||
|
|
||||||
@ -411,9 +411,9 @@ def get_button_device_by_dr_id(hass: HomeAssistant, device_id: str):
|
|||||||
if DOMAIN not in hass.data:
|
if DOMAIN not in hass.data:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
for config_entry in hass.data[DOMAIN]:
|
for entry_id in hass.data[DOMAIN]:
|
||||||
button_devices = hass.data[DOMAIN][config_entry][BUTTON_DEVICES]
|
data: LutronCasetaData = hass.data[DOMAIN][entry_id]
|
||||||
if device := button_devices.get(device_id):
|
if device := data.button_devices.get(device_id):
|
||||||
return device
|
return device
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
@ -3,19 +3,19 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from pylutron_caseta.smartbridge import Smartbridge
|
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from .const import BRIDGE_LEAP, DOMAIN
|
from .const import DOMAIN
|
||||||
|
from .models import LutronCasetaData
|
||||||
|
|
||||||
|
|
||||||
async def async_get_config_entry_diagnostics(
|
async def async_get_config_entry_diagnostics(
|
||||||
hass: HomeAssistant, entry: ConfigEntry
|
hass: HomeAssistant, entry: ConfigEntry
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
"""Return diagnostics for a config entry."""
|
"""Return diagnostics for a config entry."""
|
||||||
bridge: Smartbridge = hass.data[DOMAIN][entry.entry_id][BRIDGE_LEAP]
|
data: LutronCasetaData = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
bridge = data.bridge
|
||||||
return {
|
return {
|
||||||
"entry": {
|
"entry": {
|
||||||
"title": entry.title,
|
"title": entry.title,
|
||||||
|
@ -13,7 +13,8 @@ from homeassistant.util.percentage import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from . import LutronCasetaDeviceUpdatableEntity
|
from . import LutronCasetaDeviceUpdatableEntity
|
||||||
from .const import BRIDGE_DEVICE, BRIDGE_LEAP, DOMAIN as CASETA_DOMAIN
|
from .const import DOMAIN as CASETA_DOMAIN
|
||||||
|
from .models import LutronCasetaData
|
||||||
|
|
||||||
DEFAULT_ON_PERCENTAGE = 50
|
DEFAULT_ON_PERCENTAGE = 50
|
||||||
ORDERED_NAMED_FAN_SPEEDS = [FAN_LOW, FAN_MEDIUM, FAN_MEDIUM_HIGH, FAN_HIGH]
|
ORDERED_NAMED_FAN_SPEEDS = [FAN_LOW, FAN_MEDIUM, FAN_MEDIUM_HIGH, FAN_HIGH]
|
||||||
@ -29,9 +30,9 @@ async def async_setup_entry(
|
|||||||
Adds fan controllers from the Caseta bridge associated with the config_entry
|
Adds fan controllers from the Caseta bridge associated with the config_entry
|
||||||
as fan entities.
|
as fan entities.
|
||||||
"""
|
"""
|
||||||
data = hass.data[CASETA_DOMAIN][config_entry.entry_id]
|
data: LutronCasetaData = hass.data[CASETA_DOMAIN][config_entry.entry_id]
|
||||||
bridge = data[BRIDGE_LEAP]
|
bridge = data.bridge
|
||||||
bridge_device = data[BRIDGE_DEVICE]
|
bridge_device = data.bridge_device
|
||||||
fan_devices = bridge.get_devices_by_domain(DOMAIN)
|
fan_devices = bridge.get_devices_by_domain(DOMAIN)
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
LutronCasetaFan(fan_device, bridge, bridge_device) for fan_device in fan_devices
|
LutronCasetaFan(fan_device, bridge, bridge_device) for fan_device in fan_devices
|
||||||
|
@ -14,7 +14,8 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import LutronCasetaDeviceUpdatableEntity
|
from . import LutronCasetaDeviceUpdatableEntity
|
||||||
from .const import BRIDGE_DEVICE, BRIDGE_LEAP, DOMAIN as CASETA_DOMAIN
|
from .const import DOMAIN as CASETA_DOMAIN
|
||||||
|
from .models import LutronCasetaData
|
||||||
|
|
||||||
|
|
||||||
def to_lutron_level(level):
|
def to_lutron_level(level):
|
||||||
@ -37,9 +38,9 @@ async def async_setup_entry(
|
|||||||
Adds dimmers from the Caseta bridge associated with the config_entry as
|
Adds dimmers from the Caseta bridge associated with the config_entry as
|
||||||
light entities.
|
light entities.
|
||||||
"""
|
"""
|
||||||
data = hass.data[CASETA_DOMAIN][config_entry.entry_id]
|
data: LutronCasetaData = hass.data[CASETA_DOMAIN][config_entry.entry_id]
|
||||||
bridge = data[BRIDGE_LEAP]
|
bridge = data.bridge
|
||||||
bridge_device = data[BRIDGE_DEVICE]
|
bridge_device = data.bridge_device
|
||||||
light_devices = bridge.get_devices_by_domain(DOMAIN)
|
light_devices = bridge.get_devices_by_domain(DOMAIN)
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
LutronCasetaLight(light_device, bridge, bridge_device)
|
LutronCasetaLight(light_device, bridge, bridge_device)
|
||||||
|
18
homeassistant/components/lutron_caseta/models.py
Normal file
18
homeassistant/components/lutron_caseta/models.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
"""The lutron_caseta integration models."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from dataclasses import dataclass
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from pylutron_caseta.smartbridge import Smartbridge
|
||||||
|
|
||||||
|
from homeassistant.helpers.device_registry import DeviceEntry
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class LutronCasetaData:
|
||||||
|
"""Data for the lutron_caseta integration."""
|
||||||
|
|
||||||
|
bridge: Smartbridge
|
||||||
|
bridge_device: dict[str, Any]
|
||||||
|
button_devices: dict[str, DeviceEntry]
|
@ -10,7 +10,8 @@ from homeassistant.helpers.entity import DeviceInfo
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import _area_and_name_from_name
|
from . import _area_and_name_from_name
|
||||||
from .const import BRIDGE_DEVICE, BRIDGE_LEAP, DOMAIN as CASETA_DOMAIN
|
from .const import DOMAIN as CASETA_DOMAIN
|
||||||
|
from .models import LutronCasetaData
|
||||||
from .util import serial_to_unique_id
|
from .util import serial_to_unique_id
|
||||||
|
|
||||||
|
|
||||||
@ -24,9 +25,9 @@ async def async_setup_entry(
|
|||||||
Adds scenes from the Caseta bridge associated with the config_entry as
|
Adds scenes from the Caseta bridge associated with the config_entry as
|
||||||
scene entities.
|
scene entities.
|
||||||
"""
|
"""
|
||||||
data = hass.data[CASETA_DOMAIN][config_entry.entry_id]
|
data: LutronCasetaData = hass.data[CASETA_DOMAIN][config_entry.entry_id]
|
||||||
bridge: Smartbridge = data[BRIDGE_LEAP]
|
bridge = data.bridge
|
||||||
bridge_device = data[BRIDGE_DEVICE]
|
bridge_device = data.bridge_device
|
||||||
scenes = bridge.get_scenes()
|
scenes = bridge.get_scenes()
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
LutronCasetaScene(scenes[scene], bridge, bridge_device) for scene in scenes
|
LutronCasetaScene(scenes[scene], bridge, bridge_device) for scene in scenes
|
||||||
|
@ -6,7 +6,8 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import LutronCasetaDeviceUpdatableEntity
|
from . import LutronCasetaDeviceUpdatableEntity
|
||||||
from .const import BRIDGE_DEVICE, BRIDGE_LEAP, DOMAIN as CASETA_DOMAIN
|
from .const import DOMAIN as CASETA_DOMAIN
|
||||||
|
from .models import LutronCasetaData
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
@ -19,9 +20,9 @@ async def async_setup_entry(
|
|||||||
Adds switches from the Caseta bridge associated with the config_entry as
|
Adds switches from the Caseta bridge associated with the config_entry as
|
||||||
switch entities.
|
switch entities.
|
||||||
"""
|
"""
|
||||||
data = hass.data[CASETA_DOMAIN][config_entry.entry_id]
|
data: LutronCasetaData = hass.data[CASETA_DOMAIN][config_entry.entry_id]
|
||||||
bridge = data[BRIDGE_LEAP]
|
bridge = data.bridge
|
||||||
bridge_device = data[BRIDGE_DEVICE]
|
bridge_device = data.bridge_device
|
||||||
switch_devices = bridge.get_devices_by_domain(DOMAIN)
|
switch_devices = bridge.get_devices_by_domain(DOMAIN)
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
LutronCasetaLight(switch_device, bridge, bridge_device)
|
LutronCasetaLight(switch_device, bridge, bridge_device)
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""The tests for Lutron Caséta device triggers."""
|
"""The tests for Lutron Caséta device triggers."""
|
||||||
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components import automation
|
from homeassistant.components import automation
|
||||||
@ -15,12 +17,12 @@ from homeassistant.components.lutron_caseta import (
|
|||||||
ATTR_TYPE,
|
ATTR_TYPE,
|
||||||
)
|
)
|
||||||
from homeassistant.components.lutron_caseta.const import (
|
from homeassistant.components.lutron_caseta.const import (
|
||||||
BUTTON_DEVICES,
|
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
LUTRON_CASETA_BUTTON_EVENT,
|
LUTRON_CASETA_BUTTON_EVENT,
|
||||||
MANUFACTURER,
|
MANUFACTURER,
|
||||||
)
|
)
|
||||||
from homeassistant.components.lutron_caseta.device_trigger import CONF_SUBTYPE
|
from homeassistant.components.lutron_caseta.device_trigger import CONF_SUBTYPE
|
||||||
|
from homeassistant.components.lutron_caseta.models import LutronCasetaData
|
||||||
from homeassistant.const import CONF_DEVICE_ID, CONF_DOMAIN, CONF_PLATFORM, CONF_TYPE
|
from homeassistant.const import CONF_DEVICE_ID, CONF_DOMAIN, CONF_PLATFORM, CONF_TYPE
|
||||||
from homeassistant.helpers import device_registry
|
from homeassistant.helpers import device_registry
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
@ -83,15 +85,17 @@ async def _async_setup_lutron_with_picos(hass, device_reg):
|
|||||||
)
|
)
|
||||||
dr_button_devices[dr_device.id] = device
|
dr_button_devices[dr_device.id] = device
|
||||||
|
|
||||||
hass.data[DOMAIN][config_entry.entry_id] = {BUTTON_DEVICES: dr_button_devices}
|
hass.data[DOMAIN][config_entry.entry_id] = LutronCasetaData(
|
||||||
|
MagicMock(), MagicMock(), dr_button_devices
|
||||||
|
)
|
||||||
return config_entry.entry_id
|
return config_entry.entry_id
|
||||||
|
|
||||||
|
|
||||||
async def test_get_triggers(hass, device_reg):
|
async def test_get_triggers(hass, device_reg):
|
||||||
"""Test we get the expected triggers from a lutron pico."""
|
"""Test we get the expected triggers from a lutron pico."""
|
||||||
config_entry_id = await _async_setup_lutron_with_picos(hass, device_reg)
|
config_entry_id = await _async_setup_lutron_with_picos(hass, device_reg)
|
||||||
dr_button_devices = hass.data[DOMAIN][config_entry_id][BUTTON_DEVICES]
|
data: LutronCasetaData = hass.data[DOMAIN][config_entry_id]
|
||||||
|
dr_button_devices = data.button_devices
|
||||||
device_id = list(dr_button_devices)[0]
|
device_id = list(dr_button_devices)[0]
|
||||||
|
|
||||||
expected_triggers = [
|
expected_triggers = [
|
||||||
@ -142,7 +146,8 @@ async def test_if_fires_on_button_event(hass, calls, device_reg):
|
|||||||
"""Test for press trigger firing."""
|
"""Test for press trigger firing."""
|
||||||
|
|
||||||
config_entry_id = await _async_setup_lutron_with_picos(hass, device_reg)
|
config_entry_id = await _async_setup_lutron_with_picos(hass, device_reg)
|
||||||
dr_button_devices = hass.data[DOMAIN][config_entry_id][BUTTON_DEVICES]
|
data: LutronCasetaData = hass.data[DOMAIN][config_entry_id]
|
||||||
|
dr_button_devices = data.button_devices
|
||||||
device_id = list(dr_button_devices)[0]
|
device_id = list(dr_button_devices)[0]
|
||||||
device = dr_button_devices[device_id]
|
device = dr_button_devices[device_id]
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
@ -224,7 +229,8 @@ async def test_validate_trigger_config_unknown_device(hass, calls, device_reg):
|
|||||||
"""Test for no press with an unknown device."""
|
"""Test for no press with an unknown device."""
|
||||||
|
|
||||||
config_entry_id = await _async_setup_lutron_with_picos(hass, device_reg)
|
config_entry_id = await _async_setup_lutron_with_picos(hass, device_reg)
|
||||||
dr_button_devices = hass.data[DOMAIN][config_entry_id][BUTTON_DEVICES]
|
data: LutronCasetaData = hass.data[DOMAIN][config_entry_id]
|
||||||
|
dr_button_devices = data.button_devices
|
||||||
device_id = list(dr_button_devices)[0]
|
device_id = list(dr_button_devices)[0]
|
||||||
device = dr_button_devices[device_id]
|
device = dr_button_devices[device_id]
|
||||||
device["type"] = "unknown"
|
device["type"] = "unknown"
|
||||||
@ -267,7 +273,8 @@ async def test_validate_trigger_config_unknown_device(hass, calls, device_reg):
|
|||||||
async def test_validate_trigger_invalid_triggers(hass, device_reg):
|
async def test_validate_trigger_invalid_triggers(hass, device_reg):
|
||||||
"""Test for click_event with invalid triggers."""
|
"""Test for click_event with invalid triggers."""
|
||||||
config_entry_id = await _async_setup_lutron_with_picos(hass, device_reg)
|
config_entry_id = await _async_setup_lutron_with_picos(hass, device_reg)
|
||||||
dr_button_devices = hass.data[DOMAIN][config_entry_id][BUTTON_DEVICES]
|
data: LutronCasetaData = hass.data[DOMAIN][config_entry_id]
|
||||||
|
dr_button_devices = data.button_devices
|
||||||
device_id = list(dr_button_devices)[0]
|
device_id = list(dr_button_devices)[0]
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user