core: Invalid Lennox E30 pairing flow via HomeKit controller

Home Assistant release with the issue:

0.87.0

Last working Home Assistant release (if known): None

Operating environment (Hass.io/Docker/Windows/etc.): Docker

Component/platform:

Homekit controller

Description of problem: Here’s the “normal” flow for pairing a Lennox E30 to home kit:

  • Enter the WAC mode on the Lennox E30
  • Associate it with an iOS device to a known wifi network. No pairing code appears on the Lennox E30 screen
  • Open the Home app on iOS, select add an accessory
  • Select “I don’t have a code”
  • Once the input UI appears on iOS, the pairing code appears on the Lennox E30 device
  • Type in the code, then the device is paired

Pairing a Lennox E30 with home-assistant using the HomeKit Controler does not work properly, for two reasons:

  • The homekit_python HA component does not handle properly the fact the the c# attribute is exposed as C# by the Lennox E30, making home-assistant fail for a case sensitive lookup here: https://github.com/home-assistant/home-assistant/blob/d16d14b648b00ffe97c10180472fd004a131c99c/homeassistant/components/homekit_controller/__init__.py#L353 Changing this line with an upper case C# makes the homekit_controller discover the Lennox E30 properly, and show the pairing dialog in the HA UI. This is obviously not a proper fix, but maybe homekit_python should sanitize this attribute?
  • Once the HA pairing dialog appears, asking for the pairing code, there’s no code available on the Lennox E30 screen. The pairing code only appears briefly (<250ms) on the Lennox E30 screen when entering a dummy pairing code in HA. The briefly shown pairing code changes every time a dummy code is entered in HA (to make things harder 😊).

Tracking down the issue in homekit_python, I could create a manual pairing by adding:

    pin = input("PIN: ")

at this line: https://github.com/jlusiardi/homekit_python/blob/9604d76131a9955c8b4dbd9f10dc92394cc61ae3/homekit/protocol/__init__.py#L102

and run it as CLI:

python3 pair.py -d XX:XX:XX:XX:XX:XX -f pairing.json -a "LennoxE30" -p 123456

Blocking the pairing procedure to input the pin at the precise moment (after step 3, the verify request) during the negotiation makes the pairing code appear and stay visible long enough on the Lennox E30 screen to be able to input it at the CLI.

I’ve yet to be able to reuse the pairing file in home-assistant, and I’m not sure either how to create such an asynchronous flow using the HA UI.

Update 2019-02-09: I was able to reuse in HA the pairing I made using my modified CLI of homekit_python. The name of the pairing has to be the device ID XX:XX:XX:XX:XX:XX (AccessoryPairingID value in the pairing file). I’m only able to see the temperature, modes are not available and setting the temperature does not seem to have any actual effect.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 123 (79 by maintainers)

Most upvoted comments

iOS 13.1 on iPhone 8. HA running on a Hass.io install on Intel NUC under Ubuntu 18.04. S30 firmware is version 03.50.0148 updated August 28, 2019. Using the built-in HA Thermostat card. These are the states reported by HA:

`climate.icomfort_s30_02f6a2 off hvac_modes: off,heat,cool,heat_cool current_temperature: 76 min_temp: 40 max_temp: 90 temperature: 58 current_humidity: 38 hvac_action: off friendly_name: Master Thermostat supported_features: 1`
climate.icomfort_s30_22eed8 off hvac_modes: off,heat,cool,heat_cool current_temperature: 78 min_temp: 40 max_temp: 90 temperature: 65 current_humidity: 27 hvac_action: off friendly_name: Kitchen Thermostat supported_features: 1

I haven’t restarted since the S30’s paired a couple days ago. I have loging set to “ERROR”. No errors are appearing for this integration.

– | – | –

Cheers @GaryOkie, I’m away from civilisation right now (barely have 3G) - will check in when I’m back but will be at least 8 more days I would say

The first 0.94 beta has just been tagged while i was asleep (about 8 hours ago). This includes:

  • The pairing fix for devices with screens and random pairing codes
  • The new config entry support (so your devices appear under ‘Integrations’ like Hue etc)
  • Device info support (groups entities by phsyical device and lets you put them in areas)
  • Migrates to the new zeroconf module for discovery

This is still beta so there is still time to fix any surprise gotchas. This is obviously quite a big set of changes so if anyone can run the beta and let me know how they get on please do.

For those of you who have paired manually (like @jeromelaban), 0.93 should fix a bunch more issues that were mentioned on this ticket. This includes correctly populating operation_list, support for thermostats that have humidity and target humidity features, support for auto and more.

(@jeromelaban i would appreciate an update on how this looks on your end).

The main config flow work is now on dev so should be in 0.94. If you have paired manually the pairing will be migrated over to a config entry and your device will start showing up on the Integrations screen. This doesn’t fix the underlying pairing issue but was the big change blocking me from working on pairing.

There are some other changes pending:

  • There is a related branch here that adds device registry support. This allows HA to know the relationship between entities and physical devices attached to HomeKit hubs.

  • Now that config entries is done I’ve also finished polishing the pairing patch which is really the one most people tracking this ticket are interested in. It’s here. With this we should be able to support any HomeKit with a display (i.e. randomised pairing codes) - save for device specific quirks.

My gut feeling is that if you don’t see any tracebacks in the logs with the default config then its probably the accessory rejecting the change, and we aren’t logging it. If you are comfortable editing the code then track down this line of code in your environment and print the output:

https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/homekit_controller/__init__.py#L315