lucavb / homebridge-esphome-ts

This plugin integrates your esphome devices into HomeKit!
GNU General Public License v3.0
45 stars 16 forks source link

The device under the host [...].local could not be reached. #236

Open Staubgeborener opened 2 years ago

Staubgeborener commented 2 years ago

So I flashed my xiaomi bedside lamp 2 with ESPHome, and it's working great and as expected. This is my yaml file for the device. So yeah, currently no api password. I'll do this later. After that, I started ESPHome with this docker-compose file:

version: '3'
services:
  esphome:
    container_name: esphome
    network_mode: host
    restart: always
    image: esphome/esphome:dev
    ports:
      - 6052:6052
    volumes:
      - ./esphome-docker:/config:rw
      - /etc/localtime:/etc/localtime:ro
    command: config/ dashboard
    environment:
      - PASSWORD=nope

I can flash the device over OTA and see the logfiles, so it's definitly connected with ESPHome:

esphome

After that, I installed homebridge-esphome-ts (v1.5.1) in homebridge. But all I get is this error in my log file:

[1/13/2022, 7:29:34 AM] [esphome] The device under the host bedside-lamp-bedroom.local could not be reached.
[...]

[1/13/2022, 7:31:24 AM] [esphome] Trying to reconnect now to device bedside-lamp-bedroom.local

This is my config file:

{
"platform": "esphome",
"devices": [
{
"host": "bedside-lamp-bedroom.local",
"port": 9001,
"retryAfter": 120000
}
],
"retryAfter": 60000
},

So ESPHome is telling me, that my bedside lamp has the name bedside-lamp-bedroom.local. Port 9001 is not working, same with 6053 (default api port) and 6052 (my docker container). The readme file is telling me

[...] and the default port number 6053 is also wired into the plugin.

which is the default api port for ESPHome. But like I said, I already tried this. Also tried completely without the port-section. Still the same error in my log file.

After adding the debug and discover flag to my config (both true) the content of my log file is now like this:

[1/13/2022, 2:23:23 PM] [esphome] {} []
[...]
wakeUntilAPIReady: try 10

homebridge-esphome-ts log file:

/homebridge # cat /tmp/esphome-log-1642080203610-192.168.178.49.json 
{"type":2,"payload":"CAEQBhosYmVkc2lkZS1sYW1wLWJlZHJvb20gKGVzcGhvbWUgdjIwMjIuMS4wLWRldik=","time":1642080203737}
{"type":4,"payload":"","time":1642080203756}
{"type":10,"payload":"EhRiZWRzaWRlLWxhbXAtYmVkcm9vbRoRNDA6MzE6M0M6M0I6RDM6QUQiDDIwMjIuMS4wLWRldioVSmFuIDEyIDIwMjIsIDIxOjM0OjQzMhNlc3AzMmRvaXQtZGV2a2l0LXYx","time":1642080203779}
{"type":1,"payload":"DAokYmVkc2lkZV9sYW1wX2JlZHJvb21fcHJlc2VuY2Vfc2Vuc29yFThQTBsaJEJlZHNpZGUgTGFtcCBCZWRyb29tIFByZXNlbmNlIFNlbnNvciJFYmVkc2lkZS1sYW1wLWJlZHJvb21iaW5hcnlfc2Vuc29yYmVkc2lkZV9sYW1wX2JlZHJvb21fcHJlc2VuY2Vfc2Vuc28=","time":1642080203834}
{"type":1,"payload":"DwogYmVkc2lkZV9sYW1wX2JlZHJvb21fcmdid3dfbGlnaHQVYhr+6xogQmVkc2lkZSBMYW1wIEJlZHJvb20gUkdCV1cgTGlnaHQiOWJlZHNpZGUtbGFtcC1iZWRyb29tbGlnaHRiZWRzaWRlX2xhbXBfYmVkcm9vbV9yZ2J3d19saWdodGALYCMoATABQAFNAAAZQ1UAABNEWgROb25lWgtTbG93IFJhbmRvbVoLRmFzdCBSYW5kbw==","time":1642080203850}
{"type":21,"payload":"DThQTBs=","time":1642080203868}
{"type":1,"payload":"EgofYmVkc2lkZV9sYW1wX2JlZHJvb21fbGlnaHRfbW9kZRWiApcFGh9CZWRzaWRlIExhbXAgQmVkcm9vbSBMaWdodCBNb2RlIj5iZWRzaWRlLWxhbXAtYmVkcm9vbXRleHRfc2Vuc29yYmVkc2lkZV9sYW1wX2JlZHJvb21fbGlnaHRfbW9k","time":1642080203886}
{"type":24,"payload":"DWIa/usd5IHdPlgLVQAAgD8lAACAPy0AAIA/NQAAgD89AACAP0UAAMhDZQAAgD9tAACAP0oETm9uZQ==","time":1642080203889}
{"type":19,"payload":"","time":1642080203915}
{"type":27,"payload":"DaIClwUSA29mZg==","time":1642080203922}
{"type":7,"payload":"","time":1642080263935}
{"type":7,"payload":"","time":1642080323968}
{"type":7,"payload":"","time":1642080384006}
{"type":7,"payload":"","time":1642080444033}

What am I missing here to get the plugin to work?

Staubgeborener commented 2 years ago

I could fix this by removing the .local in my config:

{
"platform": "esphome",
"devices": [
{
"host": "bedside-lamp-bedroom",
}
],
},

[16:50:58][D][api:098]: Accepted 192.168.178.34 [16:50:58][D][api.connection:771]: esphome-ts (192.168.178.34): Connected successfully

Maybe because ESPHome is running in docker? I don't know. Logfile still looks like a mess. But my lamp is still not recognized in Homebridge. Does a flag or something like that have to be set in the yaml file?

lucavb commented 2 years ago

So this sounds a bit like a DNS issue? To be honest I did not fully understand your setup, but you can try running either

nslookup bedside-lamp-bedroom.local
OR
dig A bedside-lamp-bedroom.local +short

on the machine where you run the homebridge instance (you might have to install these tools).

ledhed2222 commented 1 year ago

I also have an issue with this. Using nslookup confirmed the hostname. Running esphome via docker.

Logs from the plugin:

$ cat /tmp/esphome-log-1679541787428-everything-presence-one-6e6f84.json

{"type":2,"payload":"CAEQBxoyZXZlcnl0aGluZy1wcmVzZW5jZS1vbmUtNmU2Zjg0IChlc3Bob21lIHYyMDIzLjMuMSkiHmV2ZXJ5dGhpbmctcHJlc2VuY2Utb25lLTZlNmY4NA==","time":1679541787847}
{"type":4,"payload":"","time":1679541788058}
{"type":1,"payload":"ChIeZXZlcnl0aGluZy1wcmVzZW5jZS1vbmUtNmU2Zjg0GhFDMDo0OTpFRjo2RTo2Rjo5NCIIMjAyMy4zLjEqFU1hciAyMiAyMDIzLCAyMjozNzozNDIIZXNwMzJkZXZCM0V2ZXJ5dGhpbmdfU21hcnRfVGVjaG5vbG9neS5FdmVyeXRoaW5nX1ByZXNlbmNlX09uZUoFMS4xLjNiCUVzcHJlc3Np","time":1679541788086}
{"type":7,"payload":"","time":1679541848090}
{"type":7,"payload":"","time":1679541908198}

Logs from esphome, note the connection is made in the first line!

[23:23:07][D][api:102]: Accepted 192.168.50.27
[23:23:08][D][api.connection:920]: esphome-ts (192.168.50.27): Connected successfully
[23:23:36][D][bh1750.sensor:159]: 'living-room Illuminance': Got illuminance=5.4lx
[23:23:36][D][sensor:127]: 'living-room Illuminance': Sending state 5.43307 lx with 1 decimals of accuracy
[23:23:41][D][shtcx:100]: Got temperature=28.20°C humidity=31.87%
[23:23:41][D][sensor:127]: 'living-room Temperature': Sending state 25.19794 °C with 1 decimals of accuracy
[23:23:41][D][sensor:127]: 'living-room Humidity': Sending state 36.87408 % with 1 decimals of accuracy
[23:24:06][D][bh1750.sensor:159]: 'living-room Illuminance': Got illuminance=5.3lx
[23:24:06][D][sensor:127]: 'living-room Illuminance': Sending state 5.31988 lx with 1 decimals of accuracy
[23:24:36][D][bh1750.sensor:159]: 'living-room Illuminance': Got illuminance=5.5lx
[23:24:36][D][sensor:127]: 'living-room Illuminance': Sending state 5.54626 lx with 1 decimals of accuracy
[23:24:41][D][shtcx:100]: Got temperature=28.24°C humidity=31.79%
[23:24:41][D][sensor:127]: 'living-room Temperature': Sending state 25.24066 °C with 1 decimals of accuracy
[23:24:41][D][sensor:127]: 'living-room Humidity': Sending state 36.79016 % with 1 decimals of accuracy
[23:24:54][D][binary_sensor:036]: 'living-room PIR': Sending state OFF
[23:24:57][D][binary_sensor:036]: 'living-room PIR': Sending state ON
[23:25:06][D][bh1750.sensor:159]: 'living-room Illuminance': Got illuminance=5.5lx
[23:25:06][D][sensor:127]: 'living-room Illuminance': Sending state 5.54626 lx with 1 decimals of accuracy
[23:25:36][D][bh1750.sensor:159]: 'living-room Illuminance': Got illuminance=5.5lx
[23:25:36][D][sensor:127]: 'living-room Illuminance': Sending state 5.54626 lx with 1 decimals of accuracy
[23:25:41][D][shtcx:100]: Got temperature=28.35°C humidity=31.54%
[23:25:41][D][sensor:127]: 'living-room Temperature': Sending state 25.35014 °C with 1 decimals of accuracy
[23:25:41][D][sensor:127]: 'living-room Humidity': Sending state 36.53992 % with 1 decimals of accuracy
[23:25:54][D][binary_sensor:036]: 'living-room PIR': Sending state OFF
[23:25:55][D][binary_sensor:036]: 'living-room PIR': Sending state ON
[23:26:06][D][bh1750.sensor:159]: 'living-room Illuminance': Got illuminance=5.5lx
[23:26:06][D][sensor:127]: 'living-room Illuminance': Sending state 5.54626 lx with 1 decimals of accuracy
[23:26:08][D][binary_sensor:036]: 'living-room PIR': Sending state OFF
[23:26:21][D][binary_sensor:036]: 'living-room PIR': Sending state ON
[23:26:35][D][binary_sensor:036]: 'living-room mmWave': Sending state OFF
[23:26:36][D][bh1750.sensor:159]: 'living-room Illuminance': Got illuminance=5.5lx
[23:26:36][D][sensor:127]: 'living-room Illuminance': Sending state 5.54626 lx with 1 decimals of accuracy
[23:26:36][D][binary_sensor:036]: 'living-room PIR': Sending state OFF