ratgdo / esphome-ratgdo

ratgdo for ESPHome
GNU General Public License v2.0
358 stars 108 forks source link

How do you disable web_server? #82

Open shred86 opened 1 year ago

shred86 commented 1 year ago

Apologize for probably a basic question but I'm new to ESPHome and after a couple hours of trying to figure this out, I'm hoping to get some help.

I purchased a ratgdo v2.0 and flashed it via the Web Installer, integrated it with HA and everything works great. However, I would like to disable web_server. I assumed I would need to be able to customize the config for the ratgdo so I installed ESPHome on my computer (Mac mini) using brew so I have access to the ESPHome dashboard. I can see my ratgdo device was automatically discovered so I clicked adopt and now it's adopted to the ESPHome dashboard.

However, looking at the config file it created, it looks like it's just pulling in the default config from this repo:

packages:
  ratgdo.esphome: github://ratgdo/esphome-ratgdo/v2board_esp8266_d1_mini_lite.yaml@main

My question is, how would I go about disabling web_server: which is enabled by default in the config it's pulling from?

Appreciate any pointers!

shred86 commented 1 year ago

So I couldn't find a way to ignore the web_sever entry in the v2board_esp8266_d1_mini_lite.yaml file, so what I did was copy the contents of that file into my .yaml file for ratgdo from the ESPHome dashboard, made a few modifications and installed that.

Long explanation for anyone that runs into this:

When you adopt the ratgdo device from the ESPHome dashboard, it will create a .yaml file that looks something like this:

substitutions:
  name: ratgdov2-c84eae
  friendly_name: ratgdov2 c84eae
packages:
  ratgdo.esphome: github://ratgdo/esphome-ratgdo/v2board_esp8266_d1_mini_lite.yaml@main
esphome:
  name: ${name}
  name_add_mac_suffix: false
  friendly_name: ${friendly_name}
api:
  encryption:
    key: # redacted

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

As you can see, it's importing the v2board_esp8266_d1_mini_lite.yaml file (which is the one that has web_server: enabled) and I believe overriding any settings you have set in this .yaml file created for your ratgdo in the ESPHome dashboard (the .yaml above).

I just copied the contents of the v2board_esp8266_d1_mini_lite.yaml into the .yaml file created in the ESPHome dashboard, and made the following changes:

---
substitutions:
  id_prefix: ratgdov2
  friendly_name: ratgdov2
  uart_tx_pin: D4
  uart_rx_pin: D2
  input_obst_pin: D7
  status_door_pin: D0
  status_obstruction_pin: D8
  dry_contact_open_pin: D5
  dry_contact_close_pin: D6
  dry_contact_light_pin: D3

esphome:
  name: ${id_prefix}
  friendly_name: ${friendly_name}
  name_add_mac_suffix: true

esp8266:
  board: d1_mini_lite
  restore_from_flash: true

packages:
  remote_package:
    url: https://github.com/ratgdo/esphome-ratgdo
    files: [base.yaml]
    refresh: 1s

# Sync time with Home Assistant.
time:
  - platform: homeassistant
    id: homeassistant_time

api:
  encryption:
    key: # redacted

ota:

improv_serial:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

logger:

You will have to reconfigure the device from Home Assistant to use the new API key. Otherwise, everything should still work like before from HA.

If there's an easier way to do this, I'm all ears. The only thing I want to change from the default config is disabling web_server. 😄

crkochan commented 1 year ago

FYI, there is an open feature request on esphome to be able to support being able to remove a packaged defined component, which covers what you're trying to do.

In my case, I decided to add an auth block in the config so that it wasn't just an open interface on the network, and disabled the ota feature.

web_server:
  ota: false
  auth:
    username: !secret esp_ratgdo_web_user
    password: !secret esp_ratgdo_web_password
corbanmailloux commented 10 months ago

As @crkochan noted, this was a feature request on ESPHome. It's now been released: https://github.com/esphome/esphome/pull/5821

So you can simply add this to your config:

web_server: !remove

I've tested this with my own devices because I was hitting an issue where the OTA process would fail due to the size of the binary. Removing the webserver reduces the binary size enough to allow the OTA to work.