Esphome dynamic wifi

Is there a way to change the ssid and pass dynamically via input_text?

something like:

wifi:
  ssid: id(wifi_ssid)
  password: id(wifi_pass)
  - platform: homeassistant
    name: "WIFI SSID"
    id: wifi_ssid
    entity_id: input_text.wifi_ssid
    
  - platform: homeassistant
    name: "WIFI PASS"
    id: wifi_pass
    entity_id: input_text.wifi_pass

Chicken, meet egg.

  1. The homeassistant sensor will not work unless wifi is already up. Go to 2

  2. The wifi will not work without the ssid and password. Go to 1.

2 Likes

No.

You can however:

  • Specify multiple wifi networks - it will connect to the strongest one. This is handy if you have a portable item that you move between different locations, it will connect to the “strongest” one. i.e. the one it can see.

  • Turn on captive portal. Then if it can’t connect to wifi you will be able to connect to the device in AP mode and set the credentials. Note however these credentials are not saved between reboots.

I specified multiple wifi and it did not work in my other house. Do both houses need to have a hassio server?

If you want to control your device from HA then yes. If you only have the one HA instance you can:

  • connect your device and HA to an external MQTT server - not recommended as it poses security risks
  • configure your device so that it can be controlled locally using the ESPHome web server (ESP32 recommended)

Note that if you aren’t connecting to a HA instance or a MQTT server you will need to set reboot_timeout to zero on either MQTT or API settings.

Oh i like the webserver option, will have to look into that.

For version 2, where is the folder located if I want to include my own?
“CSS and JS URL’s are set to empty value, so no internet access is needed for this device to show it’s web interface. V2 embeds the css within the js file so is not required, however you could include your own CSS.”

web_server:
  js_include: "./v2/www.js"
  js_url: ""
  version: 2

You can change things I believe - this is the docs:

At the bottom you can see stuff about including your own stylesheets etc for v1, or modifying the .js file for v2. I’m not enough of a web programmer to know what can be modified.