Add vera config entries support (#29880)

* Adding vera config entries support.

* Fixing lint error.

* Applying minimal changes necessary to get config entries working.

* Addressing PR feedback by further reducing the scope of the change.

* Addressing PR feedback.

* Fixing pyvera import to make it easier to patch.
Addressing PR feedback regarding creation of controller and scheduling of async config flow actions.

* Updating code owners file.

* Small fixes.

* Adding a user config flow step.

* Adding optional configs for user config flow.

* Updating strings to be more clear to the user.

* Adding options flow.
Fixing some PR feedback.

* Better handling of options.
PR feedback changes.

* Using config registry to update config options.

* Better managing config from file or config from UI
Disabling config through UI if config is provided from a file.
More tests to account for these adjustments.

* Address PR feedback.

* Fixing test, merging with master.

* Disabling all Vera UI for configs managed by configuration.yml.
Adding more tests.

* Updating config based on unique_id.
Addressing additional PR feedback.

* Rebasing off dev.
Addressing feedback.

* Addressing PR feedback.
This commit is contained in:
Robert Van Gorkom authored and GitHub committed 2020-04-03 09:49:50 +02:00
1 parent aef06a3544
commit ae22b5187a
28 files changed
+876 -294

No files matched your search

+7 -7
View File
@@ -1,29 +1,29 @@
"""Vera tests."""
from unittest.mock import MagicMock
from pyvera import CATEGORY_SWITCH, VeraSwitch
import pyvera as pv
from homeassistant.core import HomeAssistant
from .common import ComponentFactory
from .common import ComponentFactory, new_simple_controller_config
async def test_switch(
hass: HomeAssistant, vera_component_factory: ComponentFactory
) -> None:
"""Test function."""
vera_device = MagicMock(spec=VeraSwitch) # type: VeraSwitch
vera_device = MagicMock(spec=pv.VeraSwitch) # type: pv.VeraSwitch
vera_device.device_id = 1
vera_device.name = "dev1"
vera_device.category = CATEGORY_SWITCH
vera_device.category = pv.CATEGORY_SWITCH
vera_device.is_switched_on = MagicMock(return_value=False)
entity_id = "switch.dev1_1"
component_data = await vera_component_factory.configure_component(
hass=hass, devices=(vera_device,),
hass=hass,
controller_config=new_simple_controller_config(devices=(vera_device,)),
)
controller = component_data.controller
update_callback = controller.register.call_args_list[0][0][1]
update_callback = component_data.controller_data.update_callback
assert hass.states.get(entity_id).state == "off"