Merge branch 'uponor-smatrix-target-temp-sensor' of https://github.com/janschroeter/esphome into uponor-smatrix-target-temp-sensor

This commit is contained in:
janschroeter 2024-11-11 13:02:27 +01:00
commit a02c3f0a4c
4 changed files with 12 additions and 11 deletions

View file

@ -32,9 +32,9 @@ RUN \
python3-setuptools=66.1.1-1 \ python3-setuptools=66.1.1-1 \
python3-venv=3.11.2-1+b1 \ python3-venv=3.11.2-1+b1 \
python3-wheel=0.38.4-2 \ python3-wheel=0.38.4-2 \
iputils-ping=3:20221126-1 \ iputils-ping=3:20221126-1+deb12u1 \
git=1:2.39.5-0+deb12u1 \ git=1:2.39.5-0+deb12u1 \
curl=7.88.1-10+deb12u7 \ curl=7.88.1-10+deb12u8 \
openssh-client=1:9.2p1-2+deb12u3 \ openssh-client=1:9.2p1-2+deb12u3 \
python3-cffi=1.15.1-5 \ python3-cffi=1.15.1-5 \
libcairo2=1.16.0-7 \ libcairo2=1.16.0-7 \
@ -97,7 +97,7 @@ BUILD_DEPS="
zlib1g-dev=1:1.2.13.dfsg-1 zlib1g-dev=1:1.2.13.dfsg-1
libjpeg-dev=1:2.1.5-2 libjpeg-dev=1:2.1.5-2
libfreetype-dev=2.12.1+dfsg-5+deb12u3 libfreetype-dev=2.12.1+dfsg-5+deb12u3
libssl-dev=3.0.14-1~deb12u2 libssl-dev=3.0.15-1~deb12u1
libffi-dev=3.4.4-1 libffi-dev=3.4.4-1
libopenjp2-7=2.5.0-2 libopenjp2-7=2.5.0-2
libtiff6=4.5.0-6+deb12u1 libtiff6=4.5.0-6+deb12u1

View file

@ -26,7 +26,7 @@ class MDNSStatus:
self.host_mdns_state: dict[str, bool | None] = {} self.host_mdns_state: dict[str, bool | None] = {}
self._loop = asyncio.get_running_loop() self._loop = asyncio.get_running_loop()
async def async_resolve_host(self, host_name: str) -> str | None: async def async_resolve_host(self, host_name: str) -> list[str] | None:
"""Resolve a host name to an address in a thread-safe manner.""" """Resolve a host name to an address in a thread-safe manner."""
if aiozc := self.aiozc: if aiozc := self.aiozc:
return await aiozc.async_resolve_host(host_name) return await aiozc.async_resolve_host(host_name)
@ -50,13 +50,12 @@ class MDNSStatus:
poll_names.setdefault(entry.name, set()).add(entry) poll_names.setdefault(entry.name, set()).add(entry)
elif (online := host_mdns_state.get(entry.name, SENTINEL)) != SENTINEL: elif (online := host_mdns_state.get(entry.name, SENTINEL)) != SENTINEL:
entries.async_set_state(entry, bool_to_entry_state(online)) entries.async_set_state(entry, bool_to_entry_state(online))
if poll_names and self.aiozc: if poll_names and self.aiozc:
results = await asyncio.gather( results = await asyncio.gather(
*(self.aiozc.async_resolve_host(name) for name in poll_names) *(self.aiozc.async_resolve_host(name) for name in poll_names)
) )
for name, address in zip(poll_names, results): for name, address_list in zip(poll_names, results):
result = bool(address) result = bool(address_list)
host_mdns_state[name] = result host_mdns_state[name] = result
for entry in poll_names[name]: for entry in poll_names[name]:
entries.async_set_state(entry, bool_to_entry_state(result)) entries.async_set_state(entry, bool_to_entry_state(result))

View file

@ -320,12 +320,12 @@ class EsphomePortCommandWebSocket(EsphomeCommandWebSocket):
and "api" in entry.loaded_integrations and "api" in entry.loaded_integrations
): ):
if (mdns := dashboard.mdns_status) and ( if (mdns := dashboard.mdns_status) and (
address := await mdns.async_resolve_host(entry.name) address_list := await mdns.async_resolve_host(entry.name)
): ):
# Use the IP address if available but only # Use the IP address if available but only
# if the API is loaded and the device is online # if the API is loaded and the device is online
# since MQTT logging will not work otherwise # since MQTT logging will not work otherwise
port = address port = address_list[0]
elif ( elif (
entry.address entry.address
and ( and (

View file

@ -176,7 +176,7 @@ def _make_host_resolver(host: str) -> HostResolver:
class EsphomeZeroconf(Zeroconf): class EsphomeZeroconf(Zeroconf):
def resolve_host(self, host: str, timeout: float = 3.0) -> str | None: def resolve_host(self, host: str, timeout: float = 3.0) -> list[str] | None:
"""Resolve a host name to an IP address.""" """Resolve a host name to an IP address."""
info = _make_host_resolver(host) info = _make_host_resolver(host)
if ( if (
@ -188,7 +188,9 @@ class EsphomeZeroconf(Zeroconf):
class AsyncEsphomeZeroconf(AsyncZeroconf): class AsyncEsphomeZeroconf(AsyncZeroconf):
async def async_resolve_host(self, host: str, timeout: float = 3.0) -> str | None: async def async_resolve_host(
self, host: str, timeout: float = 3.0
) -> list[str] | None:
"""Resolve a host name to an IP address.""" """Resolve a host name to an IP address."""
info = _make_host_resolver(host) info = _make_host_resolver(host)
if ( if (