Open iqubik opened 2 months ago
I have a similar problem. I disabled Wi-Fi on boot for a battery operated device. My understanding is that mDNS will fail to init if there's no network (Wi-Fi or Ethernet). The work around I have is to re-setup mDNS after enabling Wi-Fi:
mdns:
id: mdns_id
wifi:
id: wifi_id
enable_on_boot: false
binary_sensor:
- id: my_sensor
on_release:
then:
- wifi.enable:
- lambda: id(mdns_id).setup();
Sounds to work for now
I have a similar problem. I disabled Wi-Fi on boot for a battery operated device. My understanding is that mDNS will fail to init if there's no network (Wi-Fi or Ethernet). The work around I have is to re-setup mDNS after enabling Wi-Fi:
mdns: id: mdns_id wifi: id: wifi_id enable_on_boot: false binary_sensor: - id: my_sensor on_release: then: - wifi.enable: - lambda: id(mdns_id).setup();
Sounds to work for now
23:48:06 | [W] | [api.connection:078] | : Network unavailable, disconnecting 23:48:27 | [W] | [mdns:047] | Failed to register mDNS service _esphomelib: ESP_ERR_INVALID_ARG 23:48:27 | [W] | [mdns:047] | Failed to register mDNS service _http: ESP_ERR_INVALID_ARG 23:48:27 | [W] | [api.connection:078] | : Network unavailable, disconnecting
why this closed? Please add mdns.restart in main esphome code and all be good
The problem
Problem Description
When I use the following configuration in my ESPHome YAML:
YAML
wifi: enable_on_boot: False
And then manually connect to the network in STA mode using the code:
WiFi.disconnect(); WiFi.mode(WIFI_STA); WiFi.begin("$staNameSTR", "$staPassSTR");
The device name, instead of being the one specified in the esphome section:
YAML
esphome: name: electrowaterpool
changes to esp32-54391C.local. This causes an ESPHome API error and a connection error to the smart home system. I believe this issue is due to mDNS and related services not being configured correctly.
Steps to Reproduce
YAML
C++
Expected Behavior
The device should retain the name specified in the esphome section (electrowaterpool.local).
Additional Information
It seems that mDNS and related services are not being configured correctly when manually connecting to Wi-Fi in STA mode. How can this be fixed?
Which version of ESPHome has the issue?
2024.6.1
What type of installation are you using?
Home Assistant Add-on
Which version of Home Assistant has the issue?
all versions
What platform are you using?
ESP32
Board
esp32dev
Component causing the issue
mdns
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
No response