mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 23:18:10 +01:00
Revert "Fix MQTT dashboard discovery (Exception in MqttStatusThread)." (#6782)
This commit is contained in:
parent
81ef67cfbb
commit
25ee24299a
1 changed files with 4 additions and 4 deletions
|
@ -18,7 +18,7 @@ class MqttStatusThread(threading.Thread):
|
||||||
"""Run the status thread."""
|
"""Run the status thread."""
|
||||||
dashboard = DASHBOARD
|
dashboard = DASHBOARD
|
||||||
entries = dashboard.entries
|
entries = dashboard.entries
|
||||||
current_entries = entries.async_all()
|
current_entries = entries.all()
|
||||||
|
|
||||||
config = mqtt.config_from_env()
|
config = mqtt.config_from_env()
|
||||||
topic = "esphome/discover/#"
|
topic = "esphome/discover/#"
|
||||||
|
@ -33,7 +33,7 @@ class MqttStatusThread(threading.Thread):
|
||||||
return
|
return
|
||||||
for entry in current_entries:
|
for entry in current_entries:
|
||||||
if entry.name == data["name"]:
|
if entry.name == data["name"]:
|
||||||
entries.async_set_state(entry, EntryState.ONLINE)
|
entries.set_state(entry, EntryState.ONLINE)
|
||||||
return
|
return
|
||||||
|
|
||||||
def on_connect(client, userdata, flags, return_code):
|
def on_connect(client, userdata, flags, return_code):
|
||||||
|
@ -53,11 +53,11 @@ class MqttStatusThread(threading.Thread):
|
||||||
client.loop_start()
|
client.loop_start()
|
||||||
|
|
||||||
while not dashboard.stop_event.wait(2):
|
while not dashboard.stop_event.wait(2):
|
||||||
current_entries = entries.async_all()
|
current_entries = entries.all()
|
||||||
# will be set to true on on_message
|
# will be set to true on on_message
|
||||||
for entry in current_entries:
|
for entry in current_entries:
|
||||||
if entry.no_mdns:
|
if entry.no_mdns:
|
||||||
entries.async_set_state(entry, EntryState.OFFLINE)
|
entries.set_state(entry, EntryState.OFFLINE)
|
||||||
|
|
||||||
client.publish("esphome/discover", None, retain=False)
|
client.publish("esphome/discover", None, retain=False)
|
||||||
dashboard.mqtt_ping_request.wait()
|
dashboard.mqtt_ping_request.wait()
|
||||||
|
|
Loading…
Reference in a new issue