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

API disconnects every second (approx. since V 0.0.4) #66

Open
Pe-MaKer opened this issue Dec 16, 2024 · 9 comments
Open

API disconnects every second (approx. since V 0.0.4) #66

Pe-MaKer opened this issue Dec 16, 2024 · 9 comments

Comments

@Pe-MaKer
Copy link

Every few days, my ESPHome-Nuki-Lock enters a state where the api conntection to HA becomes unstable.
This never occured on older versions of this outstanding integration.

See below the HA Core Logs and a screenshot of the ESP32 Log.

Logger: aioesphomeapi.connection
Quelle: runner.py:154
Erstmals aufgetreten: 10:09:34 (2015 Vorkommnisse)
Zuletzt protokolliert: 10:45:58

haustuer @ 10.0.2.3: Connection error occurred: Invalid protobuf message: type=HomeassistantServiceResponse data=b'\n\x0cesphome.nuki\x12\x14\n\x06action\x12\nDoorClosed\x12\x1d\n\x0fauthorizationId\x12\n4294967295\x12;\n\x11authorizationName\x12&\xfd\xdb${\xaa\xc8\xe4DN\xec@\n\xc4A\xe5&\x0f\xca%&\xf8a\xd8\xf09?\xd1\xc3,\x96\x06\xfe\xc2\xf2_+\x01\xc4\x12\x0e\n\x05index\x12\x0528210\x12\r\n\x07timeDay\x12\x0215\x12\x0e\n\x08timeHour\x12\x0211\x12\x0f\n\ntimeMinute\x12\x016\x12\x0f\n\ttimeMonth\x12\x0212\x12\x10\n\ntimeSecond\x12\x0243\x12\x10\n\x08timeYear\x12\x042024\x12\x12\n\x04type\x12\nDoorSensor(\x01': Error parsing message with type 'HomeassistantServiceResponse'
haustuer @ 10.0.2.3: Connection error occurred: Invalid protobuf message: type=TextSensorStateResponse data=b'\rF\x13j^\x12&\xfd\xdb${\xaa\xc8\xe4DN\xec@\n\xc4A\xe5&\x0f\xca%&\xf8a\xd8\xf09?\xd1\xc3,\x96\x06\xfe\xc2\xf2_+\x01\xc4': Error parsing message with type 'TextSensorStateResponse'
haustuer @ 10.0.2.3: Connection error occurred: Invalid protobuf message: type=HomeassistantServiceResponse data=b'\n\x0cesphome.nuki\x12\x14\n\x06action\x12\nDoorClosed\x12\x1d\n\x0fauthorizationId\x12\n4294967295\x123\n\x11authorizationName\x12\x1e\xfd\xdb${\xaa\xc8\xe4DN\xec@\n\xc4A\xe5&\x0f\xca%&\xf8a\xd8\xf09?\xd1\xc3=k\x12\x0e\n\x05index\x12\x0528210\x12\r\n\x07timeDay\x12\x0215\x12\x0e\n\x08timeHour\x12\x0211\x12\x0f\n\ntimeMinute\x12\x016\x12\x0f\n\ttimeMonth\x12\x0212\x12\x10\n\ntimeSecond\x12\x0243\x12\x10\n\x08timeYear\x12\x042024\x12\x12\n\x04type\x12\nDoorSensor(\x01': Error parsing message with type 'HomeassistantServiceResponse'
haustuer @ 10.0.2.3: Connection error occurred: Invalid protobuf message: type=TextSensorStateResponse data=b'\rF\x13j^\x12\x1e\xfd\xdb${\xaa\xc8\xe4DN\xec@\n\xc4A\xe5&\x0f\xca%&\xf8a\xd8\xf09?\xd1\xc3=k': Error parsing message with type 'TextSensorStateResponse'

2024-12-16 10_23_25-Haustür

@Pe-MaKer Pe-MaKer changed the title API diconnects every second (approx. since V 0.0.4) API disconnects every second (approx. since V 0.0.4) Dec 16, 2024
@AzonInc
Copy link
Collaborator

AzonInc commented Dec 17, 2024

Hi,

Could you please try version 0.0.4 and confirm whether the issue starts with this version? There are no significant changes between 0.0.3 and 0.0.4, so it would be helpful to verify this.

I could understand if it was 0.0.5 but 0.0.4 should still run fine.

Thanks

@Pe-MaKer
Copy link
Author

@AzonInc I have no clue on how to use a specific version.
I need to clear the built files, I assume. But how can I compile using a previous version?

@uriyacovy
Copy link
Owner

Use the following:

external_components:
  - source: github://uriyacovy/[email protected]

@Pe-MaKer
Copy link
Author

Use the following:

external_components:
  - source: github://uriyacovy/[email protected]

It's throwing a fatal error - even after commenting out the recent added sensor like nightmode and last_unlock_user:

Compiling .pioenvs/haustuer/src/esphome/components/nuki_lock/nuki_lock.cpp.o
In file included from src/esphome/components/nuki_lock/nuki_lock.cpp:3:
src/esphome/components/nuki_lock/nuki_lock.h:12:10: fatal error: NukiLock.h: No such file or directory

******************************************************************
* Looking for NukiLock.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:NukiLock.h"
* Web  > https://registry.platformio.org/search?q=header:NukiLock.h
*
******************************************************************

 #include "NukiLock.h"
          ^~~~~~~~~~~~
compilation terminated.
*** [.pioenvs/haustuer/src/esphome/components/nuki_lock/nuki_lock.cpp.o] Error 1
========================= [FAILED] Took 25.96 seconds =========================```

@AzonInc
Copy link
Collaborator

AzonInc commented Dec 28, 2024

Did u add the libraries block? It's still needed for versions < 0.0.5

esphome:
  libraries:
  - Preferences
  - https://github.com/vinmenn/Crc16.git
  - https://github.com/uriyacovy/NukiBleEsp32

@Pe-MaKer
Copy link
Author

Pe-MaKer commented Jan 7, 2025

Thanks @AzonInc
But I still get this.
image

Here is my code:

substitutions:
  display_name: haustuer

  wifi_ssid: !secret wifi_ssid
  wifi_password: !secret wifi_password

# ------------------------------
# ------------------------------
esphome:
  name: ${display_name}
  friendly_name: Haustür


  libraries:
  - Preferences
  - https://github.com/vinmenn/Crc16.git
  - https://github.com/uriyacovy/NukiBleEsp32


external_components:
  - source: github://uriyacovy/[email protected]
  #- source: github://Pe-MaKer/ESPHome_nuki_lock@dev

esp32:
  board: "wemos_d1_mini32"
  framework:
    type: arduino
    version: 2.0.16
    platform_version: 6.7.0

wifi:
  networks:
  - ssid: ${wifi_ssid}
    password: ${wifi_password}
  - ssid: ${wifi_ssid2}
    password: ${wifi_password2}
  # Optional manual IP
  manual_ip:
    static_ip: 10.0.X.XX
    gateway: 10.0.0.1
    subnet: 255.0.0.0

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: ${display_name}_AP
    password: ${wifi_password}
    ap_timeout: 1min

captive_portal:

#bluetooth_proxy:
#  active: true

logger:
  level: DEBUG
api:

#ota:
#  password: "notwhatyouthink"
ota:
  - platform: esphome    
    password: !secret ota_password
    id: my_ota
safe_mode:


web_server:
  port: 80
  include_internal: true


number:
  - platform: template
    name: "Türöffner Delay"
    id: turoffner_delay
    optimistic: true
    min_value: 0      # Minimale Dauer des Delay in Sekunden
    max_value: 10000     # Maximale Dauer des Delay in Sekunden
    step: 250
    initial_value: 2000  # Default-Wert für den Delay beim Start
  - platform: template
    name: "Durchgangslicht Delay"
    id: durchgangslicht_delay
    optimistic: true
    min_value: 1      # Minimale Dauer des Delay in Sekunden
    max_value: 600     # Maximale Dauer des Delay in Sekunden
    step: 1
    initial_value: 120  # Default-Wert für den Delay beim Start


button:
  - platform: template
    name: "Türöffner"
    id: turoffner
    icon: "mdi:door-open"
    on_press:
      - if:
          condition: 
            lock.is_locked: nuki
          then:
            - lock.unlock: nuki
            - delay: 5s
            - switch.turn_on: oeffner
            - delay: !lambda "return id(turoffner_delay).state;"
            - switch.turn_off: oeffner

          else:
            - switch.turn_on: oeffner
            - delay: !lambda "return id(turoffner_delay).state;"
            #- delay: 2000ms
            - switch.turn_off: oeffner
  - platform: template
    name: "Durchgangslicht"
    id: durchgangslicht
    icon: "mdi:wall-sconce-flat"
    on_press:
      - output.turn_on: licht
      #- delay: 120000ms
      - delay: !lambda "return 1000 * id(durchgangslicht_delay).state;"
      - output.turn_off: licht

  - platform: restart
    name: "Restart haustuer"
  
switch:
  - platform: gpio
    id: oeffner
    pin: 16
    restore_mode: ALWAYS_OFF
    name: "Schnapper"
    icon: "mdi:gate"


output:
  - platform: gpio
    id: licht
    pin: 17    

    
light:
  - platform: binary
    name: "Licht"
    output: licht


lock:
  # Required:
  - platform: nuki_lock
    name: Nuki ESP
    id: nuki
    is_connected: 
      name: "Nuki ESP verbunden"
    is_paired: 
      name: "Nuki ESP gekoppelt"      

    battery_critical:
      name: "Nuki ESP Batterie kritisch"
    battery_level:
      name: "Nuki ESP Batteriestand"
    door_sensor:
      name: "Nuki ESP Türsensor"
    door_sensor_state:
      name: "Nuki ESP Türkontakt Zustand"
    unpair:
      name: "Nuki Unpair"
    pairing_mode:
      name: "Nuki Pairing Mode"



    on_pairing_mode_on_action:
      - lambda: ESP_LOGI("nuki_lock", "Pairing Mode aktiviert");
    on_pairing_mode_off_action:
      - lambda: ESP_LOGI("nuki_lock", "Pairing Mode deaktiviert");
    on_paired_action:
      - lambda: ESP_LOGI("nuki_lock", "Pairing erfolgreich");

@AzonInc
Copy link
Collaborator

AzonInc commented Jan 7, 2025

Did u also clean the build files?

@Pe-MaKer
Copy link
Author

Pe-MaKer commented Jan 7, 2025

Did u also clean the build files?

Yes, I did.
Here is the full log to the code above after cleaning the build files:

INFO ESPHome 2024.12.2
INFO Reading configuration /config/esphome/tuer.yaml...
WARNING The selected Arduino framework version is not the recommended one. If there are connectivity or build issues please remove the manual version.
WARNING The selected Arduino framework version is not the recommended one. If there are connectivity or build issues please remove the manual version.
INFO Generating C++ source...
INFO Compiling app...
Processing haustuer (board: wemos_d1_mini32; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
Library Manager: Installing esphome/AsyncTCP-esphome @ 2.1.4
INFO Installing esphome/AsyncTCP-esphome @ 2.1.4
Unpacking  [####################################]  100%
Library Manager: [email protected] has been installed!
INFO [email protected] has been installed!
Library Manager: Installing git+https://github.com/vinmenn/Crc16.git
INFO Installing git+https://github.com/vinmenn/Crc16.git
git version 2.39.5
Cloning into '/data/cache/platformio/cache/tmp/pkg-installing-je_dbp2c'...
Library Manager: [email protected]+sha.719a7a1 has been installed!
INFO [email protected]+sha.719a7a1 has been installed!
Library Manager: Installing git+https://github.com/uriyacovy/NukiBleEsp32
INFO Installing git+https://github.com/uriyacovy/NukiBleEsp32
git version 2.39.5
Cloning into '/data/cache/platformio/cache/tmp/pkg-installing-6pth0h0n'...
Library Manager: [email protected]+sha.93e7da9 has been installed!
INFO [email protected]+sha.93e7da9 has been installed!
Library Manager: Resolving dependencies...
INFO Resolving dependencies...
Library Manager: Installing h2zero/NimBLE-Arduino @ ^1.4.0
INFO Installing h2zero/NimBLE-Arduino @ ^1.4.0
Unpacking  [####################################]  100%
Library Manager: [email protected] has been installed!
INFO [email protected] has been installed!
Library Manager: Installing git+https://github.com/vinmenn/Crc16
INFO Installing git+https://github.com/vinmenn/Crc16
git version 2.39.5
Cloning into '/data/cache/platformio/cache/tmp/pkg-installing-kbz7cnaq'...
Library Manager: [email protected]+sha.719a7a1 has been installed!
INFO [email protected]+sha.719a7a1 has been installed!
Library Manager: Installing git+https://github.com/I-Connect/BleScanner
INFO Installing git+https://github.com/I-Connect/BleScanner
git version 2.39.5
Cloning into '/data/cache/platformio/cache/tmp/pkg-installing-_8lsvacy'...
Library Manager: [email protected]+sha.2b6c045 has been installed!
INFO [email protected]+sha.2b6c045 has been installed!
Library Manager: Resolving dependencies...
INFO Resolving dependencies...
Library Manager: Installing esphome/ESPAsyncWebServer-esphome @ 3.2.2
INFO Installing esphome/ESPAsyncWebServer-esphome @ 3.2.2
Unpacking  [####################################]  100%
Library Manager: [email protected] has been installed!
INFO [email protected] has been installed!
Library Manager: Resolving dependencies...
INFO Resolving dependencies...
Library Manager: Installing bblanchon/ArduinoJson @ 6.18.5
INFO Installing bblanchon/ArduinoJson @ 6.18.5
Unpacking  [####################################]  100%
Library Manager: [email protected] has been installed!
INFO [email protected] has been installed!
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Dependency Graph
|-- AsyncTCP-esphome @ 2.1.4
|-- Preferences @ 2.0.0
|-- Crc16 @ 0.1.2+sha.719a7a1
|-- NukiBleEsp @ 2.0.0+sha.93e7da9
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.2.2
|-- DNSServer @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- ArduinoJson @ 6.18.5
Compiling .pioenvs/haustuer/src/esphome/components/api/api_connection.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/api/api_frame_helper.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/api/api_pb2.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/api/api_pb2_service.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/api/api_server.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/api/list_entities.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/api/proto.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/api/subscribe_state.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/api/user_services.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/binary_sensor/automation.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/binary_sensor/binary_sensor.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/binary_sensor/filter.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/button/button.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/captive_portal/captive_portal.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/esp32/core.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/esp32/gpio.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/esp32/preferences.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/esphome/ota/ota_esphome.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/gpio/output/gpio_binary_output.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/gpio/switch/gpio_switch.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/json/json_util.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/light/addressable_light.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/light/automation.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/light/esp_color_correction.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/light/esp_hsv_color.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/light/esp_range_view.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/light/light_call.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/light/light_json_schema.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/light/light_output.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/light/light_state.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/lock/lock.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/logger/logger.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/logger/logger_esp32.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/logger/logger_esp8266.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/logger/logger_host.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/logger/logger_libretiny.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/logger/logger_rp2040.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/md5/md5.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/mdns/mdns_component.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/mdns/mdns_esp32.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/mdns/mdns_esp8266.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/mdns/mdns_host.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/mdns/mdns_libretiny.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/mdns/mdns_rp2040.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/network/util.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/nuki_lock/nuki_lock.cpp.o
Compiling .pioenvs/haustuer/src/esphome/components/number/automation.cpp.o
In file included from .piolibdeps/haustuer/NukiBleEsp/src/NukiLock.h:3,
                 from src/esphome/components/nuki_lock/nuki_lock.h:12,
                 from src/esphome/components/nuki_lock/nuki_lock.cpp:3:
.piolibdeps/haustuer/NukiBleEsp/src/NukiBle.h:14:10: fatal error: NimBLEDevice.h: No such file or directory

**********************************************************************
* Looking for NimBLEDevice.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:NimBLEDevice.h"
* Web  > https://registry.platformio.org/search?q=header:NimBLEDevice.h
*
**********************************************************************

 #include "NimBLEDevice.h"
          ^~~~~~~~~~~~~~~~
compilation terminated.
*** [.pioenvs/haustuer/src/esphome/components/nuki_lock/nuki_lock.cpp.o] Error 1
========================= [FAILED] Took 30.49 seconds =========================

@AzonInc
Copy link
Collaborator

AzonInc commented Jan 7, 2025

Oh sorry, I forgot something.

Try this:

esphome:
  libraries:
  - Preferences
  - https://github.com/h2zero/NimBLE-Arduino#1.4.0
  - Crc16
  - https://github.com/uriyacovy/NukiBleEsp32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants