Improve z-wave thermostat support (#27040)
* Improve z-wave thermostat support Discover thermostat using COMMAND_CLASS_THERMOSTAT_MODE so that it is a single entitiy in case there are multiple setpoints. z-wave docs mention it is always present. Add support for single/range target temperature depending on the current thermostat mode. * Remove debug print * Refactor Z-Wave dynamic setpoint(s) selection - use explicit mapping between modes and setpoints as defined in Z-Wave specs - add tests for away (2 setpoints) and heat eco (1 setpoint) modes * Add non-standard thermostat mode aliases
This commit is contained in:
1 parent
807de1aeb3
commit
f5c01cc30d
4 files changed
+479
-115
No files matched your search
@@ -574,18 +574,33 @@ async def test_value_discovery_existing_entity(hass, mock_openzwave):
|
||||
assert len(mock_receivers) == 1
|
||||
|
||||
node = MockNode(node_id=11, generic=const.GENERIC_TYPE_THERMOSTAT)
|
||||
setpoint = MockValue(
|
||||
thermostat_mode = MockValue(
|
||||
data="Heat",
|
||||
data_items=["Off", "Heat"],
|
||||
node=node,
|
||||
command_class=const.COMMAND_CLASS_THERMOSTAT_MODE,
|
||||
genre=const.GENRE_USER,
|
||||
)
|
||||
setpoint_heating = MockValue(
|
||||
data=22.0,
|
||||
node=node,
|
||||
index=12,
|
||||
instance=13,
|
||||
command_class=const.COMMAND_CLASS_THERMOSTAT_SETPOINT,
|
||||
index=1,
|
||||
genre=const.GENRE_USER,
|
||||
units="C",
|
||||
)
|
||||
hass.async_add_job(mock_receivers[0], node, setpoint)
|
||||
|
||||
hass.async_add_job(mock_receivers[0], node, thermostat_mode)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
def mock_update(self):
|
||||
self.hass.add_job(self.async_update_ha_state)
|
||||
|
||||
with patch.object(
|
||||
zwave.node_entity.ZWaveBaseEntity, "maybe_schedule_update", new=mock_update
|
||||
):
|
||||
hass.async_add_job(mock_receivers[0], node, setpoint_heating)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert (
|
||||
hass.states.get("climate.mock_node_mock_value").attributes["temperature"]
|
||||
== 22.0
|
||||
@@ -597,9 +612,6 @@ async def test_value_discovery_existing_entity(hass, mock_openzwave):
|
||||
is None
|
||||
)
|
||||
|
||||
def mock_update(self):
|
||||
self.hass.add_job(self.async_update_ha_state)
|
||||
|
||||
with patch.object(
|
||||
zwave.node_entity.ZWaveBaseEntity, "maybe_schedule_update", new=mock_update
|
||||
):
|
||||
@@ -607,7 +619,6 @@ async def test_value_discovery_existing_entity(hass, mock_openzwave):
|
||||
data=23.5,
|
||||
node=node,
|
||||
index=1,
|
||||
instance=13,
|
||||
command_class=const.COMMAND_CLASS_SENSOR_MULTILEVEL,
|
||||
genre=const.GENRE_USER,
|
||||
units="C",
|
||||
|
||||
Reference in new issue
Block a user