rednblkx / HAP-ESPHome

Apple HomeKit for ESPHome
85 stars 7 forks source link

Device not found in the Apple Home App #11

Closed the-smart-home-maker closed 2 months ago

the-smart-home-maker commented 2 months ago

Hi there,

I think I have configured everything correctly. I can also see from the logs that everything seems OK. But still, the device won't show up in the Apple Home App when trying to add it. When clicking on "Add device via setup code" and entering the setup code defined in the homekit_base section, nothing happens. Also, there is no possibility to access the web page for configuring the device as one knows from the ESP32 implementation. When opening the device page in Home Assistant, I don't even see the factory reset button for the homekit_base.

What am I missing?

Here is my YAML code:

esphome:
  name: smart-lock
  friendly_name: smart-lock

esp32:
  board: esp32dev
  framework:
    type: esp-idf
    version: 5.2.1
    platform_version: 6.7.0
    sdkconfig_options: 
      CONFIG_COMPILER_OPTIMIZATION_SIZE: y 
      CONFIG_LWIP_MAX_SOCKETS: "16"
      CONFIG_MBEDTLS_HKDF_C: y 

# Enable logging
logger:

external_components:
  - source: github://rednblkx/HAP-ESPHome@main

# Enable Home Assistant API
api:

ota:
  - platform: esphome
    password: "MY_OTA_PASSWORD"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Smart-Lock"
    password: "MY_AP_PASSWORD"

captive_portal:

spi:
  clk_pin: GPIO18
  miso_pin: GPIO19
  mosi_pin: GPIO23

pn532_spi:
  id: nfc_spi_module
  cs_pin: GPIO5
  update_interval: 100ms

homekit_base:
  setup_code: '466-37-726'

homekit:
  lock:
    - id: my_lock
      nfc_id: nfc_spi_module
      on_hk_success:
        lambda: |-
          ESP_LOGI("TEST", "IssuerID: %s", x.c_str());
          ESP_LOGI("TEST", "EndpointID: %s", y.c_str());
      on_hk_fail:
        lambda: |-
          ESP_LOGI("TEST", "IT FAILED :(");
      hk_hw_finish: "SILVER"

button:
- platform: homekit_base
  factory_reset:
    name: "Reset Homekit pairings"

lock:
  - platform: template
    id: my_lock
    name: "My Lock"
    optimistic: True
    on_lock:
    - logger.log: "Door Locked!"
    on_unlock:
    - logger.log: "Door Unlocked!"

And here is an example log output:

[18:45:26]rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
[18:45:26]configsip: 0, SPIWP:0xee
[18:45:26]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
[18:45:26]mode:DIO, clock div:2
[18:45:26]load:0x3fff0030,len:1184
[18:45:26]load:0x40078000,len:13132
[18:45:26]load:0x40080400,len:3036
[18:45:26]entry 0x400805e4
[18:45:26][I][logger:156]: Log initialized
[18:45:26][C][safe_mode:079]: There have been 0 suspected unsuccessful boot attempts
[18:45:26][D][esp32.preferences:114]: Saving 1 preferences to flash...
[18:45:26][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[18:45:26][I][app:029]: Running through setup()...
[18:45:26][C][wifi:047]: Setting up WiFi...
[18:45:26][C][wifi:060]: Starting WiFi...
[18:45:26][C][wifi:061]:   Local MAC: ANONYMIZED
[18:45:27][D][wifi:481]: Starting scan...
[18:45:27][W][component:157]: Component wifi set Warning flag: scanning for networks
[18:45:32][D][wifi:496]: Found networks:
[18:45:32][I][wifi:540]: - 'ANONYMIZED' [redacted]▂▄▆█
[18:45:32][D][wifi:541]:     Channel: 11
[18:45:32][D][wifi:542]:     RSSI: -56 dB
[18:45:32][I][wifi:540]: - 'ANONYMIZED' [redacted]▂▄▆█
[18:45:32][D][wifi:541]:     Channel: 1
[18:45:33][D][wifi:542]:     RSSI: -62 dB
[18:45:33][I][wifi:540]: - 'ANONYMIZED' [redacted]▂▄▆█
[18:45:33][D][wifi:541]:     Channel: 11
[18:45:33][D][wifi:542]:     RSSI: -71 dB
[18:45:33][I][wifi:540]: - 'ANONYMIZED' [redacted]▂▄▆█
[18:45:33][D][wifi:541]:     Channel: 1
[18:45:33][D][wifi:542]:     RSSI: -88 dB
[18:45:33][D][wifi:545]: - [redacted] [redacted]▂▄▆█
[18:45:33][D][wifi:545]: - [redacted] [redacted]▂▄▆█
[18:45:33][D][wifi:545]: - [redacted] [redacted]▂▄▆█
[18:45:33][I][wifi:312]: WiFi Connecting to 'ANONYMIZED'...
[18:45:46][I][wifi:616]: WiFi Connected!
[18:45:46][C][wifi:427]:   Local MAC: ANONYMIZED
[18:45:46][C][wifi:432]:   SSID: [redacted]
[18:45:46][C][wifi:435]:   IP Address: 192.168.178.142
[18:45:46][C][wifi:439]:   BSSID: [redacted]
[18:45:46][C][wifi:440]:   Hostname: 'smart-lock'
[18:45:46][C][wifi:442]:   Signal strength: -54 dB ▂▄▆█
[18:45:46][C][wifi:446]:   Channel: 11
[18:45:46][C][wifi:447]:   Subnet: 255.255.255.0
[18:45:46][C][wifi:448]:   Gateway: 192.168.178.1
[18:45:46][C][wifi:449]:   DNS1: 192.168.178.1
[18:45:46][C][wifi:450]:   DNS2: 0.0.0.0
[18:45:46][D][wifi:625]: Disabling AP...
[18:45:46][C][api:025]: Setting up Home Assistant API server...
[18:45:46][I][app:062]: setup() finished successfully!
[18:45:46][W][component:170]: Component wifi cleared Warning flag
[18:45:46][W][component:157]: Component api set Warning flag: unspecified
[18:45:46][I][app:100]: ESPHome version 2024.7.3 compiled on Aug  5 2024, 06:44:17
[18:45:46][C][wifi:599]: WiFi:
[18:45:46][C][wifi:427]:   Local MAC: 48:E7:29:8B:9B:88
[18:45:46][C][wifi:432]:   SSID: [redacted]
[18:45:46][C][wifi:435]:   IP Address: 192.168.178.142
[18:45:46][C][wifi:439]:   BSSID: [redacted]
[18:45:46][C][wifi:440]:   Hostname: 'smart-lock'
[18:45:46][C][wifi:442]:   Signal strength: -54 dB ▂▄▆█
[18:45:46][C][wifi:446]:   Channel: 11
[18:45:46][C][wifi:447]:   Subnet: 255.255.255.0
[18:45:46][C][wifi:448]:   Gateway: 192.168.178.1
[18:45:46][C][wifi:449]:   DNS1: 192.168.178.1
[18:45:46][C][wifi:450]:   DNS2: 0.0.0.0
[18:45:46][C][logger:185]: Logger:
[18:45:46][C][logger:186]:   Level: DEBUG
[18:45:46][C][logger:188]:   Log Baud Rate: 115200
[18:45:46][C][logger:189]:   Hardware UART: UART0
[18:45:46][C][captive_portal:088]: Captive Portal:
[18:45:46][C][mdns:116]: mDNS:
[18:45:46][C][mdns:117]:   Hostname: smart-lock
[18:45:46][C][esphome.ota:073]: Over-The-Air updates:
[18:45:46][C][esphome.ota:074]:   Address: smart-lock.local:3232
[18:45:46][C][esphome.ota:075]:   Version: 2
[18:45:46][C][esphome.ota:078]:   Password configured
[18:45:46][C][safe_mode:018]: Safe Mode:
[18:45:46][C][safe_mode:020]:   Boot considered successful after 60 seconds
[18:45:46][C][safe_mode:021]:   Invoke after 10 boot attempts
[18:45:46][C][safe_mode:023]:   Remain in safe mode for 300 seconds
[18:45:46][C][api:139]: API Server:
[18:45:46][C][api:140]:   Address: smart-lock.local:6053
[18:45:46][C][api:142]:   Using noise encryption: YES
[18:45:47][D][api:102]: Accepted 192.168.178.192
[18:45:47][W][component:170]: Component api cleared Warning flag
[18:45:47][W][component:237]: Component api took a long time for an operation (72 ms).
[18:45:47][W][component:238]: Components should block for at most 30 ms.
[18:45:47][D][api.connection:1375]: Home Assistant 2024.7.4 (192.168.178.192): Connected successfully

Thanks for your help!

rednblkx commented 2 months ago

Looking at the log, you seem to be missing components, it only has the basic stuff(wifi, api, ota, etc.) that you would get at start from the esphome addon, suggest double-checking what config you've flashed

the-smart-home-maker commented 2 months ago

Thank you - you are right. Don't know why but just pressing "install" and "wireless" in the Home Assistant ESPHome Add-On seemed to NOT compile the latest YAML code even though it appeared to do so. Tried it multiple times. Never happened to me before - I have dozens of ESPHome devices. But then I decided the "Plug into this computer" with compile & download the bin file and then upload it via ESPHome web. Now it works :) Thank you! We can close this one.