Closed ve1koz111 closed 3 months ago
substitutions:
name: esphome-web-eb5520
friendly_name: homekey
esphome:
name: homekey-test
friendly_name: ${friendly_name}
min_version: 2024.6.0
name_add_mac_suffix: false
project:
name: esphome.web
version: dev
# Enable Home Assistant API
api:
# Allow Over-The-Air updates
ota:
- platform: esphome
# Allow provisioning Wi-Fi via serial
improv_serial:
# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:
dashboard_import:
package_import_url: github://esphome/example-configs/esphome-web/esp32.yaml@main
import_full_config: true
# Sets up Bluetooth LE (Only on ESP32) to allow the user
# to provision wifi credentials to the device.
esp32_improv:
authorizer: none
# To have a "next url" for improv serial
web_server:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
lock:
- platform: template
id: "this_lock"
name: "Main Lock"
optimistic: True
on_lock:
- logger.log: "Door Locked!"
on_unlock:
- logger.log: "Door Unlocked!"
external_components:
source: github://rednblkx/HAP-ESPHome@main
spi:
clk_pin: 18
miso_pin: 19
mosi_pin: 23
pn532_spi:
id: nfc_spi_module
cs_pin: 5
update_interval: 100ms
esp32:
board: esp32dev
flash_size: 2MB
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
homekit_base:
setup_code: '159-35-728'
homekit:
lock:
- id: this_lock
nfc_id: nfc_spi_module
on_hk_success:
lambda: |-
ESP_LOGI("HEREHERE", "IssuerID: %s", x.c_str());
ESP_LOGI("HEREHERE", "EndpointID: %s", y.c_str());
on_hk_fail:
lambda: |-
ESP_LOGI("GSDGSGS", "IT FAILED :(");
hk_hw_finish: "SILVER"
logger:
level: DEBUG
Bluetooth is taking a lot of space in RAM and cannot be used along with this implementation at this time for this reason.
I've update the README to reflect this.
remove the following and try again
esp32_improv:
authorizer: none
Also, for future references, please enclose the config in triple backticks ```
, single backtick `
is for one line, optionally you can throw in yaml
at the start ```yaml
for the colors(syntax highlighting)
Thanks for that feedback @rednblkx run2.txt
I've removed it, and it's still giving me an error. Is there anything else I should remove?
Logs attached
Just noticed, you have set the flash_size
to 2MB and to my knowledge there is no ESP32 package with a 2MB Flash chip, only 4MB.
This project takes up about 80% of the flash space.
Try setting it to 4MB and see how it goes.
That's odd, I did that because I was getting this error:
Warning! Flash memory size mismatch detected. Expected 4MB, found 2MB!
Will try compile now and let you know.
logs_esphome-web-eb5520_run (2).txt Sorry not sure what's going on now.
The way ESPHome does things sometimes confuses PlatformIO, which handles the whole thing with libraries, compilation, etc.
Based on the log, i assume you use the HASS addon, try the "Clean Build Files" option, or if you have access to folders delete the .esphome
folder.
Flash error I think. Changed to 8mb and trying again. logs_esphome-web-eb5520_run (3).txt
Have you made any other modifications to the config?
I literally used the config you attached at the beginning, just modified 2MB to 4MB and it only occupies 89% of Flash not 109% like in your log
Changed to 8mb and trying again.
Do you have a board with 8MB?
My board is 4mb but I think it's failing because of a software limit so i tried to bump it up to 8mb to see if that changes things? Here's the current config Nevermind I had alot of irrelevant things in the config. Removed everything, using this setup and recompiling now:
substitutions:
name: esphome-web-eb5520
friendly_name: ESPHome Web eb5520
# Allow Over-The-Air updates
ota:
- platform: esphome
# Allow provisioning Wi-Fi via serial
improv_serial:
# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:
esphome:
name: homekey-test
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
lock:
- platform: template
id: "this_lock"
name: "Main Lock"
optimistic: True
on_lock:
- logger.log: "Door Locked!"
on_unlock:
- logger.log: "Door Unlocked!"
external_components:
source: github://rednblkx/HAP-ESPHome@main
spi:
clk_pin: 18
miso_pin: 19
mosi_pin: 23
pn532_spi:
id: nfc_spi_module
cs_pin: 5
update_interval: 100ms
esp32:
board: esp32dev
flash_size: 4MB
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
homekit_base:
setup_code: '159-35-728'
homekit:
lock:
- id: this_lock
nfc_id: nfc_spi_module
on_hk_success:
lambda: |-
ESP_LOGI("HEREHERE", "IssuerID: %s", x.c_str());
ESP_LOGI("HEREHERE", "EndpointID: %s", y.c_str());
on_hk_fail:
lambda: |-
ESP_LOGI("GSDGSGS", "IT FAILED :(");
hk_hw_finish: "SILVER"
logger:
level: DEBUG
changing to 8MB won't help with anything, that only helps determining the partitions sizes, and the partition for the firmware is already maxed out by esphome for each flash size.
Looking good: It says it's compiled but the ESPHome web hasn't changed and it looks like it's not connecting to the network.
RAM: [= ] 13.1% (used 43012 bytes from 327680 bytes)
Flash: [========= ] 85.9% (used 1577045 bytes from 1835008 bytes)
Building .pioenvs/homekey-test/firmware.bin
Creating esp32 image...
Successfully created esp32 image.
esp32_create_combined_bin([".pioenvs/homekey-test/firmware.bin"], [".pioenvs/homekey-test/firmware.elf"])
Wrote 0x1911c0 bytes to file /data/build/homekey-test/.pioenvs/homekey-test/firmware.factory.bin, ready to flash to offset 0x0
esp32_copy_ota_bin([".pioenvs/homekey-test/firmware.bin"], [".pioenvs/homekey-test/firmware.elf"])
======================== [SUCCESS] Took 581.39 seconds ========================
INFO Successfully compiled program.
INFO Resolving IP address of homekey-test.local
ERROR Error resolving IP address of homekey-test.local. Is it connected to WiFi?
ERROR (If this error persists, please set a static IP address: https://esphome.io/components/wifi.html#manual-ips)
ERROR Error resolving IP address: Error resolving address with mDNS: Did not respond. Maybe the device is offline., [Errno -5] No address associated with hostname
Okay so it's compiled - had to do manual OTA update - added to apple home and apple homekey.
Weird though
- It disappeared from ESPHome
Not sure about this, might have something to do with HomeKit overtaking the mDNS component
I can't access it over LAN (I believe there's meant to be a small web UI?)
If you've used the same config as above then there's nothing to access, for the esphome web ui you have to add web_server:
the chip is not accepting apple home key transmission (like putting it close does nothing, even when done manually with Face ID)
Could you share the log?
Also, note that it might be slow to process so you have to wait a second
Okay so I've got things working (mostly).
It's now accessible on ESPHome, was an issue with my config. I still can't access the local web page on port 80 though. EDIT: Realised i set it to port 8080. Working fine!
Also, my PN532 was not accepting anything SPI because it had to be put into SPI mode (which I had no idea, - maybe a good idea to add in the setup info for newbies like myself).
I am still working on the binary sensor to be able to delay 5s and then turn off after a successful homekit authentication.
This is my current working configuration:
substitutions:
name: esphome-web-eb5520
friendly_name: ESPHome Web eb5520
# Allow provisioning Wi-Fi via serial
improv_serial:
# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:
esphome:
name: homekit_device
platformio_options:
board_build.flash_mode: dio
ota:
- platform: esphome
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
api:
reboot_timeout: 0s
web_server:
port: 8080
lock:
- platform: template
id: "this_lock"
name: "Main Lock"
optimistic: True
on_lock:
- logger.log: "Door Locked!"
on_unlock:
- logger.log: "Door Unlocked!"
external_components:
source: github://rednblkx/HAP-ESPHome@main
spi:
clk_pin: GPIO18
miso_pin: GPIO19
mosi_pin: GPIO23
pn532_spi:
id: nfc_spi_module
cs_pin: GPIO5
update_interval: 100ms
esp32:
board: esp32dev
flash_size: 4MB
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
homekit_base:
setup_code: '159-35-728'
globals:
- id: homekit_read_success_state
type: bool
restore_value: no
initial_value: 'false'
homekit:
lock:
- id: this_lock
nfc_id: nfc_spi_module
on_hk_success:
lambda: |-
ESP_LOGI("HEREHERE", "IssuerID: %s", x.c_str());
ESP_LOGI("HEREHERE", "EndpointID: %s", y.c_str());
id(this_lock).unlock();
id(homekit_read_success_state) = true;
on_hk_fail:
lambda: |-
ESP_LOGI("GSDGSGS", "IT FAILED :(");
id(homekit_read_success_state) = false;
hk_hw_finish: "SILVER"
binary_sensor:
- platform: template
name: "HomeKit Read Success"
id: homekit_read_success
device_class: connectivity
lambda: |-
return id(homekit_read_success_state);
# light:
# - id: test_light
# - id: desk_light
# sensor:
# - id: my_sensor
# - id: my_sensor_second
# switch:
# - id: some_switch
button:
- platform: homekit_base
factory_reset:
name: "Reset Homekit pairings"
#light:
# - platform: esp32_rmt_led_strip
# id: test_light
# rgb_order: GRB
# pin: GPIO8
# num_leds: 1
# rmt_channel: 0
# chipset: ws2812
# name: "My Light"
# restore_mode: RESTORE_DEFAULT_OFF
# - platform: binary
# id: desk_light
# name: "Desk Lamp"
# output: simple_led
# restore_mode: RESTORE_DEFAULT_OFF
#output:
# - platform: gpio
# pin: GPIO3
# id: simple_led
#sensor:
# - platform: template
# id: "my_sensor"
# name: "Template Sensor"
# unit_of_measurement: "°C"
# icon: "mdi:water-percent"
# device_class: "temperature"
# state_class: "measurement"
# lambda: |-
# return id(number_sensor).state;
# update_interval: 10s
# - platform: template
# id: "my_sensor_second"
# name: "Template Sensor 1"
# unit_of_measurement: "°C"
# icon: "mdi:water-percent"
# device_class: "temperature"
# state_class: "measurement"
# lambda: |-
# return id(number_sensor).state;
# update_interval: 10s
#number:
# - platform: template
# name: "Sensor Value"
# min_value: 10
# max_value: 30
# step: 1
# optimistic: True
# id: "number_sensor"
#switch:
# - platform: template
# id: some_switch
# name: "Template Switch"
# restore_mode: RESTORE_DEFAULT_OFF
# lambda: |-
# if (id(test_light).current_values.get_state()) {
# return true;
# } else {
# return false;
# }
# turn_on_action:
# - light.turn_on: test_light
# turn_off_action:
# - light.turn_off: test_light
logger:
# hardware_uart: UART0
level: DEBUG
Also, one other thing, it seems like I get this error after every successful compile, and I need to delete all the data, restart ESPHome and then it's hit or miss whether it compiles. Not sure if this is an ESPHome issue or? logs_esphome-web-eb5520_run (4).txt
Also, my PN532 was not accepting anything SPI because it had to be put into SPI mode (which I had no idea, - maybe a good idea to add in the setup info for newbies like myself).
fair, i'll see to add it on the page
Also, one other thing, it seems like I get this error after every successful compile, and I need to delete all the data, restart ESPHome and then it's hit or miss whether it compiles. Not sure if this is an ESPHome issue or?
that's strange, not sure about it, haven't had that issue but i did a change and checked with the esphome hass addon and no issue.
After compiling for a long time, gives out an error, attached are the logs
logs_esphome-web-eb5520_run.txt