Skip to content

Commit

Permalink
Convert siri requests for target heating cooling state auto to a vali…
Browse files Browse the repository at this point in the history
…d mode (#60220)
  • Loading branch information
bdraco committed Jan 12, 2022
1 parent b23be22 commit d3f980d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/homekit/manifest.json
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/homekit/type_thermostats.py
Expand Up @@ -174,6 +174,7 @@ def __init__(self, *args):
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(
Expand Down Expand Up @@ -252,7 +253,6 @@ def _set_chars(self, char_values):

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 (
Expand Down Expand Up @@ -282,7 +282,7 @@ def _set_chars(self, char_values):
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]
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions tests/components/homekit/test_type_thermostats.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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."""
Expand Down

0 comments on commit d3f980d

Please sign in to comment.