1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-02 19:32:19 +01:00

allow to use MQTT for discovery of IPs if mDNS is no option (#3887)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Markus
2023-05-17 06:29:56 +02:00
committed by GitHub
parent 0de47e2a4e
commit c5a45645a6
9 changed files with 353 additions and 21 deletions

View File

@@ -10,6 +10,12 @@ from esphome import const
from esphome.core import CORE
from esphome.helpers import write_file_if_changed
from esphome.const import (
CONF_MDNS,
CONF_DISABLED,
)
from esphome.types import CoreType
_LOGGER = logging.getLogger(__name__)
@@ -46,6 +52,7 @@ class StorageJSON:
build_path,
firmware_bin_path,
loaded_integrations,
no_mdns,
):
# Version of the storage JSON schema
assert storage_version is None or isinstance(storage_version, int)
@@ -75,6 +82,8 @@ class StorageJSON:
# A list of strings of names of loaded integrations
self.loaded_integrations: list[str] = loaded_integrations
self.loaded_integrations.sort()
# Is mDNS disabled
self.no_mdns = no_mdns
def as_dict(self):
return {
@@ -90,6 +99,7 @@ class StorageJSON:
"build_path": self.build_path,
"firmware_bin_path": self.firmware_bin_path,
"loaded_integrations": self.loaded_integrations,
"no_mdns": self.no_mdns,
}
def to_json(self):
@@ -120,6 +130,11 @@ class StorageJSON:
build_path=esph.build_path,
firmware_bin_path=esph.firmware_bin,
loaded_integrations=list(esph.loaded_integrations),
no_mdns=(
CONF_MDNS in esph.config
and CONF_DISABLED in esph.config[CONF_MDNS]
and esph.config[CONF_MDNS][CONF_DISABLED] is True
),
)
@staticmethod
@@ -139,6 +154,7 @@ class StorageJSON:
build_path=None,
firmware_bin_path=None,
loaded_integrations=[],
no_mdns=False,
)
@staticmethod
@@ -159,6 +175,7 @@ class StorageJSON:
build_path = storage.get("build_path")
firmware_bin_path = storage.get("firmware_bin_path")
loaded_integrations = storage.get("loaded_integrations", [])
no_mdns = storage.get("no_mdns", False)
return StorageJSON(
storage_version,
name,
@@ -172,6 +189,7 @@ class StorageJSON:
build_path,
firmware_bin_path,
loaded_integrations,
no_mdns,
)
@staticmethod