imagegenius / docker-esphome

Minimal ESPHome Alpine Docker Container
GNU General Public License v3.0
7 stars 1 forks source link

showing offline in reverse proxy #1

Closed tamimology closed 2 years ago

tamimology commented 2 years ago

In the original image from ESPhome, there is an env variable called _ESPHOME_DASHBOARD_USEPING="true", it is needed in case ESPhome is behind a reverse proxy. if not set to true, then all esp devices will show offline in the dashboard, which is the case here.

I like this because it is half size the original :)

### This is the image from your hub image

### This is the original with the env set to true image

hydazz commented 2 years ago

I was having problems resolving the IPs of the ESPs which is similar to the ping issue. I don't see a need to set ESPHOME_DASHBOARD_USE_PING to true by default, easy to add it to the docker run args

other ways of getting around the offline ping issue:

_Use --network host in your container. Or set ESPHOME_DASHBOARD_USE_PING environment variable to True in your container. Or set wifi/use_address in your YAML._

Originally posted by @Anonym-tsk in https://github.com/esphome/issues/issues/603#issuecomment-525255587

personally, I've found that using wifi/use_address is the neatest fix for the failed pings and cross-vlan DNS lookups (if you dont want to set a static ip)

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  use_address: 192.168.2.10
  domain: .iot

edit: Looks like you're saying that this image doesn't have ESPHOME_DASHBOARD_USE_PING? I have just tested ESPHOME_DASHBOARD_USE_PING using this image and it works as expected...

tamimology commented 2 years ago

I did try it as environmental variable and did not work

Can you paste your docker-compose file.

I have shared the screenshot showing offline in your image with this env set to true

And the second one is using esphome/esphome image with the same env set to true

hydazz commented 2 years ago

im using unraid (docker cli):

docker run -d \
    --name=ESPHome \
    --net=bridge \
    -e DEBUG=true \
    -e CLEANUP=false \
    -e ESPHOME_DASHBOARD_USE_PING=true \
    -e PUID=99 \
    -e PGID=100 \
    -p 6052:6052/tcp \
    -v /mnt/user/appdata/esphome:/config:rw \
    vcxpz/esphome

I cant see why they are showing as offline, can you install ota updates? have you tried telling esphome the ip of the esp?

wifi:
  use_address: 192.168.2.xxx
  ...
tamimology commented 2 years ago

Yes I can install ota updates but bit slow, but still showing offline which is annoying actually as a visual to distinguish between online/offline devices

hydazz commented 2 years ago

ESPhome is behind a reverse proxy do devices show as online when you directly access esphome? 192.168.1.x:6052

tamimology commented 2 years ago

Same for both behind a reverse proxy or via local ip

Just tried it now and no change yet

tamimology commented 2 years ago

any updates on this issue? were you able to figure out what is wrong and resolve?

hydazz commented 2 years ago

nope, ESPHOME_DASHBOARD_USE_PING works as expected on my unraid machine. can you share your docker-compose or docker run command?

tamimology commented 2 years ago
  esphome:
    container_name: esphome
    restart: $RESTART_POLICY
    privileged: true
    environment:
      - DEBUG=true
      - CLEANUP=false
      - PUID=$PUID
      - PGID=$PGID
      - TZ=$TZ
      - ESPHOME_DASHBOARD_USE_PING=true
    ports:
      - 6052:6052/tcp
      - 6123:6123/tcp
    volumes:
      - $PERSIST/esphome/:/config:rw
    working_dir: /config
    image: 'vcxpz/esphome:latest'
hydazz commented 2 years ago

Is the container on a different subnet? if the official esphome image works then this one should.

try network_mode: host ?

esphome:
    image: vcxpz/esphome:latest
    container_name: esphome
    network_mode: host
    environment:
      - PUID=$PUID
      - PGID=$PGID
      - TZ=$TZ
      - ESPHOME_DASHBOARD_USE_PING=true
    volumes:
      - $PERSIST/esphome/:/config:rw
    ports:
      - 6052:6052/tcp
    restart: $RESTART_POLICY

privileged: true is almost never needed on a container

tamimology commented 2 years ago

Still the same thing actually. I also tried a bridge network, same thing

image

  esphome:
    container_name: esphome
    restart: $RESTART_POLICY
    network_mode: host
    # privileged: true
    environment:
      - DEBUG=true
      - CLEANUP=false
      - PUID=$PUID
      - PGID=$PGID
      - TZ=$TZ
      - ESPHOME_DASHBOARD_USE_PING=true
    ports:
      - 6052:6052/tcp
      - 6123:6123/tcp
    volumes:
      - $PERSIST/esphome/:/config:rw
    image: 'vcxpz/esphome:latest'
hydazz commented 2 years ago

😑 post the yaml of that device

tamimology commented 2 years ago
esphome:
  name: tv-back-leds
  platform: ESP8266
  board: esp01_1m
  comment: "Relay to turn on/off the LEDs at the back of the TV"

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

wifi:
  #use_address: 192.168.1.21
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.1.21
    gateway: 192.168.1.10
    subnet: 255.255.255.0

switch:
  - platform: gpio
    pin:
      number: GPIO12
    id: relay
    name: "TV Back LEDs"
    icon: mdi:led-strip
    restore_mode: RESTORE_DEFAULT_OFF

status_led:
  pin:
    number: GPIO13

binary_sensor:
  - platform: gpio
    pin: GPIO00
    name: Toggle TV Back LEDs
    id: tv_back_leds_button
    on_press:
      then:
        - switch.toggle: relay
hydazz commented 2 years ago

your gateway is at 192.168.1.10? when manual_ip is set esphome should default to ping in the first place. try click the 3 dots and clean build files then install and see if the device becomes online...

tamimology commented 2 years ago

oh no, my gateway is 192.168.1.1

I changed it in the device yaml, cleaned the build files and reinstall, same :(

the thing is when I use the official esphome/esphome:latest container it works fine, even without the host network, but when I use yours, it does not!

hydazz commented 2 years ago

the thing is when I use the official esphome/esphome:latest container it works fine, even without the host network, but when I use yours, it does not!

try vcxpz/esphome:dev. I have added iputils 🤞

tamimology commented 2 years ago

Finally, it worked now. let me know when you push it to the vcxpz/esphome:latest so I change my compose accordingly

image

Thanks Alex for being so patient with me this long :)

hydazz commented 2 years ago

ahah! the built-in busybox ping utility is not supported by esphome. ping in iputils must be complied with differently. what a fiasco

hydazz commented 2 years ago

fixed in https://github.com/hydazz/docker-esphome/commit/c49a3028ce441d55a36965571be26223444e9c5f you can pull the :latest tag if https://github.com/hydazz/docker-esphome/actions/runs/2919140082 finishes 🙂