Wifi multiple networks specific SSID

Hi All,

I’m using ESPHome for years and loving it. Have for about 15 devices in my home. Latest development is using them outside. Most of the time ESP32 with several sensors connected. My latest is a motion detection (HC-RS501) for garden lights. In my experiance with that sensor low power Wifi is neccesary and using my non 5ghz Wifi setup. I’m using a setup with two possible SSID’s. But i have 4 different SSID’s in my environment.

To use multi wifi networks i’m using this setup:

wifi:
  networks:
    - ssid: !secret 2_wifi_ssid
    - password: !secret 2_wifi_password
    - ssid: !secret 3_wifi_ssid
    - password: !secret 3_wifi_password
  output_power: 8.5dB
  power_save_mode: HIGH

In my secrets.yaml:

# Your Wi-Fi SSID and password
1_wifi_ssid: "wwwmdfotonlmesh"
1_wifi_password: "xxxxxx"

2_wifi_ssid: "wwwmdfotonl"
2_wifi_password: "xxxxxx"

3_wifi_ssid: "wwwmdfotonliot"
3_wifi_password: "xxxxxx"

So i’m trying to connect to a specific wifi network 2_wifi / 3_wifi using secrets.
But…
The device is connecting to all possible wifi ap’s listed in the secret.yaml file as shown here:

[07:23:39][C][wifi:504]: WiFi:
[07:23:39][C][wifi:362]:   Local MAC: xx:B8:15:C1:xx:xx
[07:23:39][C][wifi:363]:   SSID: **[wwwmdfotonlmesh]**
[07:23:39][C][wifi:364]:   IP Address: 192.168.254.115
[07:23:39][C][wifi:366]:   BSSID: [redacted]
[07:23:39][C][wifi:367]:   Hostname: 'bewbuiten1'

Didn’t i understand the way this should be working? Or did i make a config fault?

Yes.

doesn’t fit with the docs:

# Example configuration entry
wifi:
  networks:
  - ssid: FirstNetworkToConnectTo
    password: VerySafePassword
  - ssid: SecondNetworkToConnectTo
    password: VerySafePassword
  # Other options
  # ...
3 Likes

Thanks for your reply.
So bassicly what you (or the documentation) descripes that we Can’t use SECRET in multiple networks?

It says dat you shouldn’t use the dash - in front of the password. Only in front of the ssid

Yes you can. Here’s mine:

# Multiple networks with DHCP
wifi:
  networks:
  - ssid: Kaywinnet
    password: !secret wifi_password
  - ssid: Serenity
    password: !secret serenity_password
  - ssid: Naboo
    password: !secret naboo_password

But your secrets.yaml has a problem. (Note, I am YAML-challenged and not an expert).
The secrets file is a list of substitutions using the format:
key: "data"
and you are using the same keywords more than once. I don’t think it will throw an error, but only the first key will be used.

1 Like

No he’s not. How is 1_wifi_password: the same as 2_wifi_password:

You are correct. I had brain fog and missed the 1_, 2_, etc. I would recommend that the OP use more descriptive keywords, however.

No. :no_entry:

That instead :point_up_2:

thanks all!

Got it working.

Nice. Feel free to mark your topic as :white_check_mark: solved