esphome / esphome-core

🚨 No longer used 🚨 - The C++ framework behind ESPHome
https://esphome.io/
GNU General Public License v3.0
545 stars 113 forks source link

Cannot connect to hidden SSIDs #369

Closed jjlawren closed 5 years ago

jjlawren commented 5 years ago

Operating environment/Installation (Hass.io/Docker/pip/etc.):

pip

ESP (ESP32/ESP8266/Board/Sonoff):

esp8266 (nodemcu)

Affected component:

wifi (https://esphomelib.com/esphomeyaml/components/wifi.html)

Description of problem: After upgrading from a quite old version to 1.10, I can no longer connect to hidden SSIDs. The wifi component repeatedly scans the available wifi networks and fails with "No matching network found!".

Problem-relevant YAML-configuration entries:

wifi:
  ssid: 'hidden_ssid'
  password: 'mypassword'

Traceback (if applicable):

[20:46:30][W][wifi:304]: No matching network found!
[20:46:35][D][wifi:247]: Starting scan...
[20:46:41][D][wifi:262]: Found networks:
[20:46:41][D][wifi:299]: - '' (46:D9:E7:91:1B:CC) ▂▄▆█
[20:46:41][D][wifi:299]: - 'myssid' (44:D9:E7:91:1B:CC) ▂▄▆█
[20:46:41][D][wifi:299]: - '' (56:D9:E7:91:1B:CC) ▂▄▆█
[20:46:41][D][wifi:299]: - '' (02:9F:C2:74:EF:55) ▂▄▆█
[20:46:41][D][wifi:299]: - '' (F2:9F:C2:74:EF:55) ▂▄▆█
[20:46:41][D][wifi:299]: - 'myssid' (F0:9F:C2:74:EF:55) ▂▄▆█
[20:46:41][W][wifi:304]: No matching network found!
[20:46:46][D][wifi:247]: Starting scan...

Note that 'myssid' above is a broadcasted SSID, and not the hidden one I'm trying to connect to.

Additional information:

jjlawren commented 5 years ago

I can confirm one of the listed BSSIDs with an empty listed SSID is the network I'd like to connect to.

jjlawren commented 5 years ago

Enabling SSID broadcast on the AP allows the device to connect. However I don’t think this should be a requirement to work.

psbaltar commented 5 years ago

Coincidentally, I just sat down to report the same issue.

It won't connect if the SSID is hidden. Telling my AP to unhide it allows it to connect (no other changes). ESPEasy is able to connect to the same AP while the SSID is hidden. So I'm pretty sure there's a bug in esphomelib.

psbaltar commented 5 years ago

I haven't been able to figure out how the entire wifi stack works, but I was poking around in WiFiScanResult::matches(). I printed out this->ssid_ and it looks like hidden SSIDs are empty strings. So, ap.getssid() would never equal this->ssid if the SSID is hidden.

OttoWinter commented 5 years ago

I think the way I'll solve it is by adding a new hidden configuration option.

Workaround is: use BSSID

wifi:
  networks:
  - bssid: 46:D9:E7:91:1B:CC  # replace
    password: ...
subzero79 commented 5 years ago

Using bssid doesn’t work. The log on the ap doesn’t even show an attempt of connection. I am trying with a sonoff pow. I’ll try later on with a wemos to see if I can get more logging through the serial.

Btw fantastic project. Thanks for your work.

Misak commented 5 years ago

Same here, I can't connect to hidden ssid with d1mini. When I switch my ssid to be visible it can connect without problems. I am using latest docker image ottowinter/esphomeyaml. I agree with subzero79, great work. Thanks

quazzie commented 5 years ago

Yeah, BSSID does not work for me either. "Wifi Connecting to ''..." then "Timeout while connecting to wifi"

meijerwynand commented 5 years ago

Greetings,

Just upgraded to 1.10.0. Also experiencing the same issue, currently testing on NodeMCU.

Unable to connect to hidden wifi network, bssid option also not working and I am running multiple AP's on same SSID name, so no luck on that option either.

oscar-b commented 5 years ago

Would it be possible to specify multiple BSSID so that the closest AP is used?

OttoWinter commented 5 years ago

@oscar-b https://esphomelib.com/esphomeyaml/components/wifi.html#connecting-to-multiple-networks - but as said here using bssid also doesn't work.

oscar-b commented 5 years ago

@OttoWinter I want it to connect to the same hidden SSID though, using the closest BSSID (APs), not different networks. I would have to specify the same network and password multiple times with the current implementation, as far as I can tell?

subzero79 commented 5 years ago

it works now. :+1:

meijerwynand commented 5 years ago

Confirmed working to connect to hidden WiFi (NodeMCU)

For the sake of easy access, clarity, and those who just google to copy paste the correct configs...

To connect to hidden on 1.10.1

...
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  domain: !secret wifi_domain
  fast_connect: true
...