Use configured speed ranges for HomeSeer FC200+ fan controllers in zwave_js (#59697)

* Use configured speed ranges for HomeSeer FC200+ fan controllers in zwave_js

* Fix pylint errors

* Remove unused param in tests

* Fix test values

* Address various review notes

* Remove now-redundant assertion

* Add an additional test case for set_percentage=0

* Use round() instead of int() for percentage computations; this makes the percentage setting match the setpoints in the UI

* Add additional tests

* Fix pct conversions

* Make conversion tests exhaustive

* Add tests for discovery data templates

* Revert "Add tests for discovery data templates"

This reverts commit 85dcbc0903.

* Improve typing on ConfigurableFanSpeedDataTemplate#resolve_data

* Move config error handling to the discovery data template

* Fix checks for config data

* Revise fallback logic in percentage_to_zwave_speed and ensure that the speed list is non-empty

* Rework error handling

* Fix runtime fan speed updates

* Use warning instead of warn

* Move data validation to get_speed_config; turns out that resolve_data is only called once, at startup.

* Temporarily remove the not-yet-used fixed fan speed template.  Add an additional assertion to ensure speeds are sorted.

* Add a comment about the assertions in discovery_data_template.py

* Update homeassistant/components/zwave_js/discovery_data_template.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Fix typo in comment

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Michael Kowalchuk 2021-11-24 02:31:59 -08:00 committed by GitHub
parent 8e6a3b2799
commit 74cfbf5f42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 10843 additions and 28 deletions

View file

@ -332,6 +332,12 @@ def in_wall_smart_fan_control_state_fixture():
return json.loads(load_fixture("zwave_js/in_wall_smart_fan_control_state.json"))
@pytest.fixture(name="hs_fc200_state", scope="session")
def hs_fc200_state_fixture():
"""Load the HS FC200+ node state fixture data."""
return json.loads(load_fixture("zwave_js/fan_hs_fc200_state.json"))
@pytest.fixture(name="gdc_zw062_state", scope="session")
def motorized_barrier_cover_state_fixture():
"""Load the motorized barrier cover node state fixture data."""
@ -697,6 +703,14 @@ def in_wall_smart_fan_control_fixture(client, in_wall_smart_fan_control_state):
return node
@pytest.fixture(name="hs_fc200")
def hs_fc200_fixture(client, hs_fc200_state):
"""Mock a fan node."""
node = Node(client, copy.deepcopy(hs_fc200_state))
client.driver.controller.nodes[node.node_id] = node
return node
@pytest.fixture(name="null_name_check")
def null_name_check_fixture(client, null_name_check_state):
"""Mock a node with no name."""