Add support for multiple vera controller hubs (#33613)

This commit is contained in:
Robert Van Gorkom authored and GitHub committed 2020-09-14 22:06:52 -05:00
1 parent 938e06c00e
commit 903afb62d0
24 files changed
+323 -149

No files matched your search

@@ -12,7 +12,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity
from . import VeraDevice
from .const import DOMAIN
from .common import ControllerData, get_controller_data
_LOGGER = logging.getLogger(__name__)
@@ -23,10 +23,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(
[
VeraBinarySensor(device, controller_data.controller)
VeraBinarySensor(device, controller_data)
for device in controller_data.devices.get(PLATFORM_DOMAIN)
]
)
@@ -35,10 +35,10 @@ async def async_setup_entry(
class VeraBinarySensor(VeraDevice, BinarySensorEntity):
"""Representation of a Vera Binary Sensor."""
def __init__(self, vera_device, controller):
def __init__(self, vera_device, controller_data: ControllerData):
"""Initialize the binary_sensor."""
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)
@property