Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Siri requests target heating cooling state of auto even when its not a valid value #60203

Closed
RefineryX opened this issue Nov 23, 2021 · 15 comments · Fixed by #60220
Closed

Siri requests target heating cooling state of auto even when its not a valid value #60203

RefineryX opened this issue Nov 23, 2021 · 15 comments · Fixed by #60220

Comments

@RefineryX
Copy link
Contributor

RefineryX commented Nov 23, 2021

The problem

I have a Tado Thermostat in HomeKit via the HA HomeKit Controller. When turning the thermostat on or changing the temperature via Siri, I get two errors within the HA logs.... however the temperature still changes as expected.

The thermostat only supports heating (off, heat) and there is no cooling element.

I am unsure if it is related, though I did report a simular issue this time last year #44076

These particular errors showed when asking Siri to turn the temperature to 22 degrees. (The current temp was 21 and the thermostat was in the 'off' state).

Error 1

('10.10.1.12', 49379): Error while setting characteristic TargetHeatingCoolingState to 3

Logger: pyhap.accessory_driver
Source: /usr/local/lib/python3.9/site-packages/pyhap/accessory_driver.py:76 
First occurred: 11:31:14 (1 occurrences) 
Last logged: 11:31:14

('10.10.1.12', 49379): Error while setting characteristic TargetHeatingCoolingState to 3
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/pyhap/accessory_driver.py", line 74, in _wrap_char_setter
    char.client_update_value(value, client_addr)
  File "/usr/local/lib/python3.9/site-packages/pyhap/characteristic.py", line 282, in client_update_value
    value = self.to_valid_value(value)
  File "/usr/local/lib/python3.9/site-packages/pyhap/characteristic.py", line 194, in to_valid_value
    raise ValueError(error_msg)
ValueError: TargetHeatingCoolingState: value=3 is an invalid value.

Error 2

TargetHeatingCoolingState: value=3 is an invalid value.

Logger: pyhap.characteristic
Source: /usr/local/lib/python3.9/site-packages/pyhap/characteristic.py:193
First occurred: 11:31:14 (1 occurrences) 
Last logged: 11:31:14

TargetHeatingCoolingState: value=3 is an invalid value.

What version of Home Assistant Core has the issue?

Core

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

HomeKit Controller

Link to integration documentation on our website

https://www.home-assistant.io/integrations/homekit_controller/

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

@probot-home-assistant
Copy link

homekit_controller documentation
homekit_controller source
(message by IssueLinks)

@probot-home-assistant
Copy link

Hey there @Jc2k, @bdraco, mind taking a look at this issue as it has been labeled with an integration (homekit_controller) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@Jc2k
Copy link
Member

Jc2k commented Nov 23, 2021

The exception is in pyhap, which is part of the homekit bridge, not homekit_controller.

The question is whether Siri is generating unexpected data that the bridge doesn't like, or whether it's homekit_controller.

Do you only get these errors with Siri and not when you use the HA Ui? What about the Apple Home app?

@Jc2k
Copy link
Member

Jc2k commented Nov 23, 2021

Does the Ha UI correctly see the valid modes? (It dossnt show auto or cooling?)

Does the Apple Home app show the correct modes?

@Jc2k
Copy link
Member

Jc2k commented Nov 23, 2021

Looking at the other issue I'm going to pre-emptively move this issue as it looks like it's homekit, not homekit_controller.

@probot-home-assistant
Copy link

homekit documentation
homekit source
(message by IssueLinks)

@RefineryX
Copy link
Contributor Author

RefineryX commented Nov 23, 2021

Do you only get these errors with Siri and not when you use the HA Ui? What about the Apple Home app?

So I have ran a couple more tests. The conditions of the tests were starting with the thermostat in the 'off' state, the current temp is 21 degrees (c) and requesting the temp to change to 22 degrees (c).

  • When asking via Siri, "hey Siri, turn the temp to 22 degrees) the errors appear on the logs as above.
  • However, requesting (manually turning on and setting the temp to 22 degrees) via the Apple HomeKit app, the error does not appear on the logs and the functionality works as expected.

I would assume this is isolated to Siri.

Does the Ha UI correctly see the valid modes? (It dossnt show auto or cooling?)

The HA UI sees the correct valid mode and does not show auto or cooling.
Screenshot 2021-11-23 at 12 13 46

I also checked in the Customise Entities section, and see

Hvac modes (JSON formatted)
["off","heat"]

Screenshot 2021-11-23 at 12 12 58

Does the Apple Home app show the correct modes?

HomeKit also sees the correct modes

Screenshot 2021-11-23 at 12 14 35

@bdraco
Copy link
Member

bdraco commented Nov 23, 2021

Siri is asking for Auto even though its not a valid value

HC_HEAT_COOL_AUTO = 3

We had another user experience this siri issue a while back. I'll see if I can find how it was solved

@bdraco
Copy link
Member

bdraco commented Nov 23, 2021

Related PR #44236

@bdraco
Copy link
Member

bdraco commented Nov 23, 2021

😆 Looks like I'm actually remembering your previous issue #44076

@bdraco
Copy link
Member

bdraco commented Nov 23, 2021

pyhap since added validation to prevent invalid values from leaking into the HomeKit state machine

@bdraco
Copy link
Member

bdraco commented Nov 23, 2021

I don't see a way to fix this without removing the validation from pyhap and letting the invalid data into the state machine. I'm not sure we want to do that though as it will re-introduce other bugs

@Jc2k
Copy link
Member

Jc2k commented Nov 23, 2021

With hkc, we bend over backwards to cope with the same bugs in devices that iOS copes with (like the hideous JSON trailing comma that we dealt with a while back). I think this is the same situation. iOS/Siri is doing something dumb, but it is "always right" so we have to deal with it?

I.e. we should tolerate crap coming in, but follow the spec for stuff we are sending out.

We could clamp all ints to minValue/maxValue. This makes sense for things like temperature (if you request -5 C, we'll get you as close as possible but it might only be 10 C). And it happens to work here, maxValue is 1 or HEAT. My gut feeling is that this sort of clamping might be how this has gone unnoticed?

@Jc2k
Copy link
Member

Jc2k commented Nov 23, 2021

(To be clear: pyhap clamps to minValue/maxValue for stuff coming from iOS to HA, but still validates for stuff coming from HA to iOS)

bdraco added a commit to bdraco/ha-HAP-python that referenced this issue Nov 23, 2021
As of iOS 15.1, Siri requests TargetHeatingCoolingState
as Auto reguardless if its a valid value or not.

Consumers of this api may wish to set allow_invalid_client_values
to True and handle converting the Auto state to Cool or Heat
depending on the device.

Reference: home-assistant/core#60203
bdraco added a commit to bdraco/ha-HAP-python that referenced this issue Nov 23, 2021
As of iOS 15.1, Siri requests TargetHeatingCoolingState
as Auto reguardless if its a valid value or not.

Consumers of this api may wish to set allow_invalid_client_values
to True and handle converting the Auto state to Cool or Heat
depending on the device.

Reference: home-assistant/core#60203
bdraco added a commit to bdraco/home-assistant that referenced this issue Nov 23, 2021
- Siri will request an invalid thermostat mode (auto) when
  the device does not support it. Allow the value to be
  converted to a mode the device supports

- Requires ikalchev/HAP-python#392

- Fixes home-assistant#60203
@bdraco
Copy link
Member

bdraco commented Nov 23, 2021

I created a workaround for this issue in #60220

We will have to wait for a new release of HAP-python with this PR: ikalchev/HAP-python#392

@bdraco bdraco changed the title HomeKit Controller Presents errors when thermostat is controlled via Siri Siri requests target heating cooling state of auto even when its not a valid value Nov 23, 2021
@github-actions github-actions bot added the stale label Dec 23, 2021
@bdraco bdraco reopened this Jan 11, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Feb 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants