Convert siri requests for target heating cooling state auto to a valid mode (#60220)

This commit is contained in:
J. Nick Koston 2022-01-12 13:06:09 -10:00 committed by GitHub
parent b23be22c67
commit d3f980d402
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 5 deletions

View file

@ -3,7 +3,7 @@
"name": "HomeKit",
"documentation": "https://www.home-assistant.io/integrations/homekit",
"requirements": [
"HAP-python==4.3.0",
"HAP-python==4.4.0",
"fnvhash==0.1.0",
"PyQRCode==1.2.1",
"base36==0.1.1"

View file

@ -174,6 +174,7 @@ class Thermostat(HomeAccessory):
self.char_target_heat_cool.override_properties(
valid_values=self.hc_hass_to_homekit
)
self.char_target_heat_cool.allow_invalid_client_values = True
# Current and target temperature characteristics
self.char_current_temp = serv_thermostat.configure_char(
@ -252,7 +253,6 @@ class Thermostat(HomeAccessory):
hvac_mode = state.state
homekit_hvac_mode = HC_HASS_TO_HOMEKIT[hvac_mode]
# Homekit will reset the mode when VIEWING the temp
# Ignore it if its the same mode
if (
@ -282,7 +282,7 @@ class Thermostat(HomeAccessory):
target_hc,
hc_fallback,
)
target_hc = hc_fallback
self.char_target_heat_cool.value = target_hc = hc_fallback
break
params[ATTR_HVAC_MODE] = self.hc_homekit_to_hass[target_hc]

View file

@ -17,7 +17,7 @@ Adafruit-SHT31==1.0.2
Adax-local==0.1.3
# homeassistant.components.homekit
HAP-python==4.3.0
HAP-python==4.4.0
# homeassistant.components.mastodon
Mastodon.py==1.5.1

View file

@ -10,7 +10,7 @@ AEMET-OpenData==0.2.1
Adax-local==0.1.3
# homeassistant.components.homekit
HAP-python==4.3.0
HAP-python==4.4.0
# homeassistant.components.flick_electric
PyFlick==0.0.2

View file

@ -1266,6 +1266,7 @@ async def test_thermostat_hvac_modes_with_heat_only(hass, hk_driver):
await hass.async_block_till_done()
hap = acc.char_target_heat_cool.to_HAP()
assert hap["valid-values"] == [HC_HEAT_COOL_OFF, HC_HEAT_COOL_HEAT]
assert acc.char_target_heat_cool.allow_invalid_client_values is True
assert acc.char_target_heat_cool.value == HC_HEAT_COOL_HEAT
acc.char_target_heat_cool.set_value(HC_HEAT_COOL_HEAT)
@ -1303,6 +1304,29 @@ async def test_thermostat_hvac_modes_with_heat_only(hass, hk_driver):
assert call_set_hvac_mode[0].data[ATTR_ENTITY_ID] == entity_id
assert call_set_hvac_mode[0].data[ATTR_HVAC_MODE] == HVAC_MODE_HEAT
acc.char_target_heat_cool.client_update_value(HC_HEAT_COOL_OFF)
await hass.async_block_till_done()
assert acc.char_target_heat_cool.value == HC_HEAT_COOL_OFF
hass.states.async_set(
entity_id, HVAC_MODE_OFF, {ATTR_HVAC_MODES: [HVAC_MODE_HEAT, HVAC_MODE_OFF]}
)
await hass.async_block_till_done()
hk_driver.set_characteristics(
{
HAP_REPR_CHARS: [
{
HAP_REPR_AID: acc.aid,
HAP_REPR_IID: char_target_heat_cool_iid,
HAP_REPR_VALUE: HC_HEAT_COOL_AUTO,
},
]
},
"mock_addr",
)
await hass.async_block_till_done()
assert acc.char_target_heat_cool.value == HC_HEAT_COOL_HEAT
async def test_thermostat_hvac_modes_with_cool_only(hass, hk_driver):
"""Test if unsupported HVAC modes are deactivated in HomeKit and siri calls get converted to cool."""