core icon indicating copy to clipboard operation
core copied to clipboard

Setting fan speed from homekit automation results in incorrect speed

Open rcork opened this issue 1 year ago • 6 comments

The problem

I am using the BAF integration and exposing the fans to Homekit. When i include the fan in a Homekit automation, whether its a Scene or the action for one of my homekit buttons, i've noticed the fan speed being set incorrectly. For example, if create a scene that sets my fan to 85% and then trigger the scene, the fan will turn on and set the speed to 85%, but then immediately set the speed to something lower like 57%. However if i just control the fan manually from the iOS home app and set the speed to 100%, it works correctly.

When i look in the logbook after triggering the scene, i see two entries one right after the other. First is the command to set the speed to 85% followed right after by the turn_on command. I think whats happening is the turn_on command is setting the fan to some default speed, overwriting the percentage set in the previous command. Here's the messages from the log book in ascending order by time (latest event on top)

Homekit send command turn_on for Master Bedroom HomeKit send command set_percentage to 85.71428571428572 for Master Bedroom

I've tried the homebridge baf i6 plugin and it doens't have the same issue with homekit scenes or automations but prefer HA's integration as its more feature rich and flexible

What version of Home Assistant Core has the issue?

core-2024.6.3

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

Big Ass Fans (baf)

Link to integration documentation on our website

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

Diagnostics information

I don't see any debug logging for the baf integration in the log but including it anyways

home-assistant_baf_2024-06-20T21-10-01.061Z.log

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

rcork avatar Jun 20 '24 21:06 rcork

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

Code owner commands

Code owners of baf can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign baf Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


baf documentation baf source (message by IssueLinks)

home-assistant[bot] avatar Jun 20 '24 21:06 home-assistant[bot]

Thanks for the report. I'll try to look into this next week. Maybe @bdraco will chime in as well.

jfroy avatar Jun 20 '24 22:06 jfroy

I can't get this to happen.

Probably going to need debug logs for homeassistant.core to see what service calls are being made

bdraco avatar Jun 20 '24 23:06 bdraco

I enabled debug logging on HomeKit Bridge and BAF and captured the homekit automation trigger event. Does this help? At the end of the log it looks like it sets the speed to 85% but then receives a request to set preset to auto and speed to 57%.

2024-06-21 09:09:43.067 DEBUG (MainThread) [pyhap.hap_protocol] ('192.168.10.237', 57458) (012e4d1c-69c6-47a6-999a-cb54b48d75fe): Recv decrypted: b'PUT /characteristics HTTP/1.1\r\nHost: HASS\\032Bridge\\032Z6\\0328809D1._hap._tcp.local\r\nContent-Length: 189\r\nContent-Type: application/hap+json\r\n\r\n{"characteristics":[{"aid":1587517433,"iid":10,"value":0},{"aid":1587517433,"iid":12,"value":0},{"aid":1587517433,"iid":9,"value":1},{"aid":1587517433,"iid":11,"value":85.714285714285722}]}'
2024-06-21 09:09:43.067 DEBUG (MainThread) [pyhap.hap_protocol] ('192.168.10.237', 57458) (012e4d1c-69c6-47a6-999a-cb54b48d75fe): h11 Event: PAUSED
2024-06-21 09:09:43.067 DEBUG (MainThread) [pyhap.hap_protocol] ('192.168.10.237', 57458) (012e4d1c-69c6-47a6-999a-cb54b48d75fe): h11 Event: Request(method=b'PUT', headers=<Headers([(b'host', b'HASS\\032Bridge\\032Z6\\0328809D1._hap._tcp.local'), (b'content-length', b'189'), (b'content-type', b'application/hap+json')])>, target=b'/characteristics', http_version=b'1.1')
2024-06-21 09:09:43.068 DEBUG (MainThread) [pyhap.hap_protocol] ('192.168.10.237', 57458) (012e4d1c-69c6-47a6-999a-cb54b48d75fe): h11 Event: Data(data=bytearray(b'{"characteristics":[{"aid":1587517433,"iid":10,"value":0},{"aid":1587517433,"iid":12,"value":0},{"aid":1587517433,"iid":9,"value":1},{"aid":1587517433,"iid":11,"value":85.714285714285722}]}'), chunk_start=False, chunk_end=False)
2024-06-21 09:09:43.068 DEBUG (MainThread) [pyhap.hap_protocol] ('192.168.10.237', 57458) (012e4d1c-69c6-47a6-999a-cb54b48d75fe): h11 Event: EndOfMessage(headers=<Headers([])>)
2024-06-21 09:09:43.068 DEBUG (MainThread) [pyhap.hap_handler] ('192.168.10.237', 57458): Request PUT for path '/characteristics': {'host': 'HASS\\032Bridge\\032Z6\\0328809D1._hap._tcp.local', 'content-length': '189', 'content-type': 'application/hap+json'}
2024-06-21 09:09:43.068 DEBUG (MainThread) [pyhap.hap_handler] ('192.168.10.237', 57458): Set characteristics content: {'characteristics': [{'aid': 1587517433, 'iid': 10, 'value': 0}, {'aid': 1587517433, 'iid': 12, 'value': 0}, {'aid': 1587517433, 'iid': 9, 'value': 1}, {'aid': 1587517433, 'iid': 11, 'value': 85.71428571428572}]}
2024-06-21 09:09:43.068 DEBUG (MainThread) [pyhap.characteristic] client_update_value: RotationDirection to 0 (original: 0) from client: ('192.168.10.237', 57458)
2024-06-21 09:09:43.068 DEBUG (MainThread) [pyhap.characteristic] client_update_value: TargetFanState to 0 (original: 0) from client: ('192.168.10.237', 57458)
2024-06-21 09:09:43.068 DEBUG (MainThread) [pyhap.characteristic] client_update_value: Active to 1 (original: 1) from client: ('192.168.10.237', 57458)
2024-06-21 09:09:43.068 DEBUG (MainThread) [pyhap.characteristic] client_update_value: RotationSpeed to 85.71428571428572 (original: 85.71428571428572) from client: ('192.168.10.237', 57458)
2024-06-21 09:09:43.068 DEBUG (MainThread) [pyhap.accessory_driver] Send event: topic(1587517433.11), data({'aid': 1587517433, 'iid': 11, 'value': 85.71428571428572}), sender_client_addr(('192.168.10.237', 57458))
2024-06-21 09:09:43.068 DEBUG (MainThread) [pyhap.accessory_driver] Skip sending event to client since its the client that made the characteristic change: ('192.168.10.237', 57458)
2024-06-21 09:09:43.068 DEBUG (MainThread) [homeassistant.components.homekit.type_fans] Fan _set_chars: {'RotationDirection': 0, 'TargetFanState': 0, 'Active': 1, 'RotationSpeed': 85.71428571428572}
2024-06-21 09:09:43.068 DEBUG (MainThread) [homeassistant.components.homekit.type_fans] fan.master_bedroom: Set direction to 0
2024-06-21 09:09:43.070 DEBUG (MainThread) [homeassistant.components.homekit.type_fans] fan.master_bedroom: Set speed to 85
2024-06-21 09:09:43.070 DEBUG (MainThread) [homeassistant.components.homekit.type_fans] fan.master_bedroom: Set auto to 0
2024-06-21 09:09:43.072 DEBUG (MainThread) [pyhap.hap_protocol] ('192.168.10.237', 57458) (012e4d1c-69c6-47a6-999a-cb54b48d75fe): Send encrypted: b'HTTP/1.1 204 No Content\r\n\r\n'
2024-06-21 09:09:43.072 DEBUG (MainThread) [pyhap.hap_protocol] ('192.168.10.237', 57458) (012e4d1c-69c6-47a6-999a-cb54b48d75fe): h11 Event: NEED_DATA
2024-06-21 09:09:43.267 DEBUG (MainThread) [homeassistant.components.homekit.accessories] New_state: <state fan.master_bedroom=on; preset_modes=['auto'], direction=forward, percentage=85, percentage_step=14.285714285714286, preset_mode=None, friendly_name=Master Bedroom, supported_features=13 @ 2024-06-21T09:08:45.219655-07:00>
2024-06-21 09:09:43.268 DEBUG (MainThread) [pyhap.characteristic] set_value: Active to 1
2024-06-21 09:09:43.268 DEBUG (MainThread) [pyhap.characteristic] set_value: RotationDirection to 0
2024-06-21 09:09:43.268 DEBUG (MainThread) [pyhap.characteristic] set_value: RotationSpeed to 85
2024-06-21 09:09:43.268 DEBUG (MainThread) [pyhap.characteristic] set_value: TargetFanState to 0
2024-06-21 09:09:43.615 DEBUG (MainThread) [homeassistant.components.homekit.accessories] New_state: <state fan.master_bedroom=on; preset_modes=['auto'], direction=forward, percentage=57, percentage_step=14.285714285714286, preset_mode=None, friendly_name=Master Bedroom, supported_features=13 @ 2024-06-21T09:08:45.219655-07:00>
2024-06-21 09:09:43.616 DEBUG (MainThread) [pyhap.characteristic] set_value: Active to 1
2024-06-21 09:09:43.616 DEBUG (MainThread) [pyhap.characteristic] set_value: RotationDirection to 0
2024-06-21 09:09:43.616 DEBUG (MainThread) [pyhap.characteristic] set_value: RotationSpeed to 57
2024-06-21 09:09:43.616 DEBUG (MainThread) [pyhap.accessory_driver] Send event: topic(1587517433.11), data({'aid': 1587517433, 'iid': 11, 'value': 57.14285714285715}), sender_client_addr(None)
2024-06-21 09:09:43.616 DEBUG (MainThread) [pyhap.accessory_driver] Sending event to client: ('192.168.10.237', 57458), immediate: False
2024-06-21 09:09:43.616 DEBUG (MainThread) [pyhap.characteristic] set_value: TargetFanState to 0
2024-06-21 09:09:44.117 DEBUG (MainThread) [pyhap.hap_protocol] ('192.168.10.237', 57458) (012e4d1c-69c6-47a6-999a-cb54b48d75fe): Send encrypted: b'EVENT/1.0 200 OK\r\nContent-Type: application/hap+json\r\nContent-Length: 75\r\n\r\n{"characteristics":[{"aid":1587517433,"iid":11,"value":57.14285714285715}]}'

rcork avatar Jun 21 '24 16:06 rcork

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.