formatBCE / Airbnk-MQTTOpenGateway

Gateway to use Airbnk locks with HA custom integration https://github.com/rospogrigio/airbnk_mqtt
GNU Affero General Public License v3.0
12 stars 1 forks source link

Then device install correctly but not create any entity #8

Closed antonbek89 closed 1 year ago

antonbek89 commented 1 year ago

Hi I do all the steps From ESPHome - airbnk is online

When I go to devices I see the esphome but not entity

formatBCE commented 1 year ago

ESPHome gateway doesn't create entity in HA. It does connect the lock to MQTT. It reads status messages from lock, sends them to MQTT, and waits for commands from HA to transfer them to lock.

You need HA integration (this repository) to create lock entity and operate it.

Please, read documentation.

antonbek89 commented 1 year ago

ESPHome gateway doesn't create entity in HA. It does connect the lock to MQTT. It reads status messages from lock, sends them to MQTT, and waits for commands from HA to transfer them to lock.

You need HA integration (this repository) to create lock entity and operate it.

Please, read documentation.

OK so I'm install the integration ](https://github.com/rospogrigio/airbnk_mqtt)

When I'm try open/close nothing happend

this my log

INFO Reading configuration /config/esphome/airbnktest.yaml...
INFO Starting log output from airbnktest.local using esphome API
INFO Successfully connected to airbnktest.local
[02:28:37][I][app:102]: ESPHome version 2022.12.8 compiled on Jan 31 2023, 02:13:40
[02:28:37][C][wifi:504]: WiFi:
[02:28:37][C][wifi:362]:   Local MAC: EC:62:60:99:C9:24
[02:28:37][C][wifi:363]:   SSID: [redacted]
[02:28:37][C][wifi:364]:   IP Address: 192.168.1.174
[02:28:37][C][wifi:366]:   BSSID: [redacted]
[02:28:37][C][wifi:367]:   Hostname: 'airbnktest'
[02:28:37][C][wifi:369]:   Signal strength: -52 dB ▂▄▆█
[02:28:37][C][wifi:373]:   Channel: 10
[02:28:37][C][wifi:374]:   Subnet: 255.255.255.0
[02:28:37][C][wifi:375]:   Gateway: 192.168.1.1
[02:28:37][C][wifi:376]:   DNS1: 8.8.8.8
[02:28:37][C][wifi:377]:   DNS2: 8.8.4.4
[02:28:37][C][logger:293]: Logger:
[02:28:37][C][logger:294]:   Level: DEBUG
[02:28:37][C][logger:295]:   Log Baud Rate: 115200
[02:28:37][C][logger:296]:   Hardware UART: UART0
[02:28:37][C][captive_portal:088]: Captive Portal:
[02:28:37][C][mdns:103]: mDNS:
[02:28:37][C][mdns:104]:   Hostname: airbnktest
[02:28:37][C][ota:093]: Over-The-Air Updates:
[02:28:37][C][ota:094]:   Address: airbnktest.local:3232
[02:28:37][C][ota:097]:   Using Password.
[02:28:37][W][ota:103]: Last Boot was an unhandled reset, will proceed to safe mode in 2 restarts
[02:28:37][C][api:138]: API Server:
[02:28:37][C][api:139]:   Address: airbnktest.local:6053
[02:28:37][C][api:141]:   Using noise encryption: YES
[02:28:37][C][mqtt:065]: MQTT:
[02:28:37][C][mqtt:067]:   Server Address: 192.168.1.230:1883 (192.168.1.230)
[02:28:37][C][mqtt:068]:   Username: [redacted]
[02:28:37][C][mqtt:069]:   Client ID: [redacted]
[02:28:37][C][mqtt:074]:   Topic Prefix: 'airbnktest'
[02:28:37][C][mqtt:076]:   Log Topic: 'airbnktest/debug'
[02:28:37][C][mqtt:079]:   Availability: 'airbnktest/status'
[02:28:38][D][airbnk_mqtt:105]: BLE scan heartbeat
[02:28:39][D][airbnk_mqtt:123]: Sending adv
[02:28:42][D][airbnk_mqtt:241]: Got command
[02:28:42][D][airbnk_mqtt:169]: Sending to:
[02:28:42][D][airbnk_mqtt:170]: a4:34:f1:**:**:**
[02:28:42][D][airbnk_mqtt:178]: Connected to lock.
[02:28:42][D][airbnk_mqtt:189]: Writing command.
[02:28:43][D][airbnk_mqtt:211]: Successfully sent command.
[02:28:44][D][airbnk_mqtt:211]: Successfully sent command.
[02:28:44][D][airbnk_mqtt:211]: Successfully sent command.
[02:28:44][D][airbnk_mqtt:211]: Successfully sent command.
[02:28:45][D][airbnk_mqtt:211]: Successfully sent command.
[02:28:45][D][airbnk_mqtt:211]: Successfully sent command.
[02:28:45][D][airbnk_mqtt:211]: Successfully sent command.
[02:28:46][D][airbnk_mqtt:211]: Successfully sent command.
[02:28:46][D][airbnk_mqtt:211]: Successfully sent command.
[02:28:46][D][airbnk_mqtt:211]: Successfully sent command.
[02:28:46][D][airbnk_mqtt:225]: Disconnecting from lock.
[02:28:46][D][airbnk_mqtt:234]: Sending operation result.
[02:28:46][D][airbnk_mqtt:146]: Operation successful
[02:28:46][D][airbnk_mqtt:236]: Restarting scanning.
[02:28:46][D][airbnk_mqtt:102]: Start scanning...
[02:28:46][D][airbnk_mqtt:105]: BLE scan heartbeat
[02:28:46][D][airbnk_mqtt:123]: Sending adv
[02:28:49][D][airbnk_mqtt:123]: Sending adv
[02:28:50][D][airbnk_mqtt:123]: Sending adv
[02:28:51][D][airbnk_mqtt:241]: Got command
[02:28:51][D][airbnk_mqtt:169]: Sending to:
[02:28:51][D][airbnk_mqtt:170]: a4:34:f1:**:**:**
[02:28:51][D][airbnk_mqtt:178]: Connected to lock.
[02:28:52][D][airbnk_mqtt:189]: Writing command.
[02:28:53][D][airbnk_mqtt:211]: Successfully sent command.
[02:28:53][D][airbnk_mqtt:211]: Successfully sent command.
[02:28:53][D][airbnk_mqtt:211]: Successfully sent command.
[02:28:54][D][airbnk_mqtt:211]: Successfully sent command.
[02:28:54][D][airbnk_mqtt:211]: Successfully sent command.
[02:28:54][D][airbnk_mqtt:211]: Successfully sent command.
[02:28:54][D][airbnk_mqtt:211]: Successfully sent command.
[02:28:55][D][airbnk_mqtt:211]: Successfully sent command.
[02:28:55][D][airbnk_mqtt:211]: Successfully sent command.
[02:28:55][D][airbnk_mqtt:211]: Successfully sent command.
[02:28:55][D][airbnk_mqtt:225]: Disconnecting from lock.
[02:28:55][D][airbnk_mqtt:234]: Sending operation result.
[02:28:55][D][airbnk_mqtt:146]: Operation successful
[02:28:55][D][airbnk_mqtt:236]: Restarting scanning.
[02:28:55][D][airbnk_mqtt:102]: Start scanning...
[02:28:55][D][airbnk_mqtt:105]: BLE scan heartbeat
[02:28:59][D][airbnk_mqtt:123]: Sending adv
[02:29:00][D][airbnk_mqtt:105]: BLE scan heartbeat
formatBCE commented 1 year ago

Log looks completely normal - except of part, where you're sending 10 commands in a row.

What behavior do you see?

antonbek89 commented 1 year ago

Log looks completely normal - except of part, where you're sending 10 commands in a row.

What behavior do you see?

I actually send only once open/close command

formatBCE commented 1 year ago

Then something is very wrong. 10 cmands are sent, according to logs.

But even then, it should have operated. Please, check that lock MAC address is correct, re-install integration (use PR code), reboot HA after each step.

Then I'd suggest using nRfConnect to read lock parameters. This way you will determine, if commands reaching the lock, and if it at least reacts with error.

antonbek89 commented 1 year ago

Then something is very wrong. 10 cmands are sent, according to logs.

But even then, it should have operated. Please, check that lock MAC address is correct, re-install integration (use PR code), reboot HA after each step.

Then I'd suggest using nRfConnect to read lock parameters. This way you will determine, if commands reaching the lock, and if it at least reacts with error.

Steps

Hardware M531 + D1 mini ESP32 ESP-32 WiFi+Bluetooth What the hell is wrong with the process?

1) Remove Airbnk from HACS 2) Restart 3) Install Airbnk from HACS 3a) use custom option - put M531 mac address + topic mqtt ("maindoor") 4) ESPHome - create ESP32 project lets call him "airbnktest" 5) Copy https://github.com/formatBCE/Airbnk-MQTTOpenGateway/blob/main/src/esphome/airbnk-gateway.h to config/esphome 6) config the ESPHome airbnktest.yaml

esphome:
  name: airbnktest
# ADD THIS - SECTION 1:
  includes:
    - airbnk-gateway.h
  libraries:
    - "h2zero/NimBLE-Arduino"
# END OF SECTION 1
esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:
# Enable Home Assistant API
api:
  encryption:
    key: "/HtrI8SA83jAqsDXaBKIQHP/3HD84eVqIjuDxEkfNqw="

ota:
  password: "0508d3aa8b1a3ffcfdf8227b78ef2b45"

wifi:
  ssid: Test
  password: ***

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Airbnktest Fallback Hotspot"
    password: "***"

captive_portal:

# ADD THIS - SECTION 2
mqtt:
  broker: 192.168.1.230 # TODO replace with your MQTT server IP
  username: mqttuser # TODO replace with your MQTT user or remove
  password: **** # TODO replace with your MQTT password or remove
  discovery: false

custom_component:
- lambda: |- # TODO replace parameters with your lock mac and HA integration topic
    auto my_node = new AirbnkGatewayNodeComponent("A4:34:F1:**:**:**", "maindoor");
    return {my_node};
# END OF SECTION 2

7) Connect the physical D1 mini ESP32 ESP-32 WiFi+Bluetooth to AC 8) All work great 9) Restart 10) logs from ESPHome

INFO Reading configuration /config/esphome/airbnktest.yaml...
INFO Starting log output from airbnktest.local using esphome API
INFO Successfully connected to airbnktest.local
[11:32:46][I][app:102]: ESPHome version 2022.12.8 compiled on Jan 31 2023, 03:44:11
[11:32:46][C][wifi:504]: WiFi:
[11:32:46][C][wifi:362]:   Local MAC: EC:62:60:99:C9:24
[11:32:46][C][wifi:363]:   SSID: [redacted]
[11:32:46][C][wifi:364]:   IP Address: 192.168.1.174
[11:32:46][C][wifi:366]:   BSSID: [redacted]
[11:32:46][C][wifi:367]:   Hostname: 'airbnktest'
[11:32:46][C][wifi:369]:   Signal strength: -35 dB ▂▄▆█
[11:32:46][C][wifi:373]:   Channel: 8
[11:32:46][C][wifi:374]:   Subnet: 255.255.255.0
[11:32:46][C][wifi:375]:   Gateway: 192.168.1.1
[11:32:46][C][wifi:376]:   DNS1: 8.8.8.8
[11:32:46][C][wifi:377]:   DNS2: 8.8.4.4
[11:32:46][C][logger:293]: Logger:
[11:32:46][C][logger:294]:   Level: DEBUG
[11:32:46][C][logger:295]:   Log Baud Rate: 115200
[11:32:46][C][logger:296]:   Hardware UART: UART0
[11:32:46][C][captive_portal:088]: Captive Portal:
[11:32:46][C][mdns:103]: mDNS:
[11:32:46][C][mdns:104]:   Hostname: airbnktest
[11:32:46][C][ota:093]: Over-The-Air Updates:
[11:32:46][C][ota:094]:   Address: airbnktest.local:3232
[11:32:46][C][ota:097]:   Using Password.
[11:32:46][C][api:138]: API Server:
[11:32:46][C][api:139]:   Address: airbnktest.local:6053
[11:32:46][C][api:141]:   Using noise encryption: YES
[11:32:46][C][mqtt:065]: MQTT:
[11:32:46][C][mqtt:067]:   Server Address: 192.168.1.230:1883 (192.168.1.230)
[11:32:46][C][mqtt:068]:   Username: [redacted]
[11:32:46][C][mqtt:069]:   Client ID: [redacted]
[11:32:46][C][mqtt:074]:   Topic Prefix: 'airbnktest'
[11:32:46][C][mqtt:076]:   Log Topic: 'airbnktest/debug'
[11:32:46][C][mqtt:079]:   Availability: 'airbnktest/status'
[11:32:47][D][airbnk_mqtt:123]: Sending adv
[11:32:49][D][airbnk_mqtt:123]: Sending adv
[11:32:49][D][airbnk_mqtt:123]: Sending adv
[11:32:50][D][airbnk_mqtt:105]: BLE scan heartbeat
[11:32:50][D][airbnk_mqtt:123]: Sending adv

11) Send command from HA to open the lock - esp log - (failed)

:34:33][C][mqtt:076]:   Log Topic: 'airbnktest/debug'
[11:34:33][C][mqtt:079]:   Availability: 'airbnktest/status'
[11:34:34][D][airbnk_mqtt:123]: Sending adv
[11:34:34][D][airbnk_mqtt:105]: BLE scan heartbeat
[11:34:35][D][airbnk_mqtt:123]: Sending adv
[11:34:36][D][airbnk_mqtt:123]: Sending adv
[11:34:38][D][airbnk_mqtt:123]: Sending adv
[11:34:39][D][airbnk_mqtt:105]: BLE scan heartbeat
[11:34:40][D][airbnk_mqtt:123]: Sending adv
[11:34:41][D][airbnk_mqtt:123]: Sending adv
[11:34:42][D][airbnk_mqtt:241]: Got command
[11:34:42][D][airbnk_mqtt:169]: Sending to:
[11:34:42][D][airbnk_mqtt:170]: a4:34:f1:**:**:**
[11:34:42][D][airbnk_mqtt:178]: Connected to lock.
[11:34:43][D][airbnk_mqtt:189]: Writing command.
[11:34:44][D][airbnk_mqtt:211]: Successfully sent command.
[11:34:44][D][airbnk_mqtt:211]: Successfully sent command.
[11:34:44][D][airbnk_mqtt:211]: Successfully sent command.
[11:34:45][D][airbnk_mqtt:211]: Successfully sent command.
[11:34:45][D][airbnk_mqtt:211]: Successfully sent command.
[11:34:45][D][airbnk_mqtt:211]: Successfully sent command.
[11:34:46][D][airbnk_mqtt:211]: Successfully sent command.
[11:34:46][D][airbnk_mqtt:211]: Successfully sent command.
[11:34:46][D][airbnk_mqtt:211]: Successfully sent command.
[11:34:46][D][airbnk_mqtt:211]: Successfully sent command.
[11:34:46][D][airbnk_mqtt:225]: Disconnecting from lock.
[11:34:46][D][airbnk_mqtt:234]: Sending operation result.
[11:34:46][D][airbnk_mqtt:146]: Operation successful
[11:34:46][D][airbnk_mqtt:236]: Restarting scanning.
[11:34:46][D][airbnk_mqtt:102]: Start scanning...
[11:34:46][D][airbnk_mqtt:105]: BLE scan heartbeat
[11:34:47][D][airbnk_mqtt:123]: Sending adv
[11:34:48][D][airbnk_mqtt:123]: Sending adv
[11:34:49][D][airbnk_mqtt:123]: Sending adv
[11:34:50][D][airbnk_mqtt:123]: Sending adv

12) Restart 13) check again - open door - same log 14 )nRfConnect to read lock parameters - I saw some green parameters not really know what is important to process

antonbek89 commented 1 year ago

@formatBCE Regarding the PR I success to install it correctly - everything work ok The problem sometimes i got "connection reset by peer" from ESPHome logs

13:42:18][C][mqtt:065]: MQTT:
[13:42:18][C][mqtt:067]:   Server Address: 192.168.1.230:1883 (192.168.1.230)
[13:42:18][C][mqtt:068]:   Username: [redacted]
[13:42:18][C][mqtt:069]:   Client ID: [redacted]
[13:42:18][C][mqtt:074]:   Topic Prefix: 'airbnktest'
[13:42:18][C][mqtt:076]:   Log Topic: 'airbnktest/debug'
[13:42:18][C][mqtt:079]:   Availability: 'airbnktest/status'
[13:42:19][D][airbnk_mqtt:123]: Sending adv
[13:42:19][D][airbnk_mqtt:105]: BLE scan heartbeat
[13:42:21][D][airbnk_mqtt:123]: Sending adv
[13:42:22][D][airbnk_mqtt:241]: Got command
[13:42:22][D][airbnk_mqtt:169]: Sending to:
[13:42:22][D][airbnk_mqtt:170]: a4:34:f1:**:**:**
[13:42:24][D][airbnk_mqtt:178]: Connected to lock.
[13:42:25][D][airbnk_mqtt:189]: Writing command.
[13:42:26][D][airbnk_mqtt:211]: Successfully sent command.
[13:42:26][D][airbnk_mqtt:211]: Successfully sent command.
[13:42:26][D][airbnk_mqtt:211]: Successfully sent command.
[13:42:26][D][airbnk_mqtt:211]: Successfully sent command.
[13:42:27][D][airbnk_mqtt:211]: Successfully sent command.
[13:42:27][D][airbnk_mqtt:211]: Successfully sent command.
**INFO airbnktest.local: Error while reading incoming messages: Error while reading data: [Errno 104] Connection reset by peer
INFO airbnktest.local: Ping Failed: Error while reading data: [Errno 104] Connection reset by peer
INFO Disconnected from ESPHome API for airbnktest.local
WARNING Disconnected from API
INFO Successfully connected to airbnktest.local**
[13:42:35][D][airbnk_mqtt:123]: Sending adv
[13:42:37][D][airbnk_mqtt:123]: Sending adv
[13:42:38][D][airbnk_mqtt:105]: BLE scan heartbeat
[13:42:38][D][airbnk_mqtt:123]: Sending adv
[13:42:39][D][api:102]: Accepted ::FFFF:192.168.1.230
formatBCE commented 1 year ago

Yes, this indicates WiFi disconnection. It's bad thing in general. Gateway can't transmit FFF3 characteristic value to HA in this case. For myself, it works without disconnections. And I still want to insist, that there's something wrong with your ESP32. It shows command sending 10 times in a row. I can't reproduce it. And this is exactly the reason of disconnections.