Add support for multiple vera controller hubs (#33613)
This commit is contained in:
parent
938e06c00e
commit
903afb62d0
24 changed files with 323 additions and 149 deletions
|
@ -13,7 +13,7 @@ from homeassistant.helpers.entity import Entity
|
|||
from homeassistant.util import convert
|
||||
|
||||
from . import VeraDevice
|
||||
from .const import DOMAIN
|
||||
from .common import ControllerData, get_controller_data
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -24,10 +24,10 @@ async def async_setup_entry(
|
|||
async_add_entities: Callable[[List[Entity], bool], None],
|
||||
) -> None:
|
||||
"""Set up the sensor config entry."""
|
||||
controller_data = hass.data[DOMAIN]
|
||||
controller_data = get_controller_data(hass, entry)
|
||||
async_add_entities(
|
||||
[
|
||||
VeraSwitch(device, controller_data.controller)
|
||||
VeraSwitch(device, controller_data)
|
||||
for device in controller_data.devices.get(PLATFORM_DOMAIN)
|
||||
]
|
||||
)
|
||||
|
@ -36,10 +36,10 @@ async def async_setup_entry(
|
|||
class VeraSwitch(VeraDevice, SwitchEntity):
|
||||
"""Representation of a Vera Switch."""
|
||||
|
||||
def __init__(self, vera_device, controller):
|
||||
def __init__(self, vera_device, controller_data: ControllerData):
|
||||
"""Initialize the Vera device."""
|
||||
self._state = False
|
||||
VeraDevice.__init__(self, vera_device, controller)
|
||||
VeraDevice.__init__(self, vera_device, controller_data)
|
||||
self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue