mirror of
https://github.com/esphome/esphome.git
synced 2025-11-08 02:51:49 +00:00
Compare commits
236 Commits
ina226-ext
...
2023.11.0b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e2b83acb0 | ||
|
|
c1eb5bd675 | ||
|
|
a9772ebf3f | ||
|
|
a9a17ee89d | ||
|
|
f094702a16 | ||
|
|
908f56ff46 | ||
|
|
bd5905c59a | ||
|
|
91299f05f7 | ||
|
|
30e5ff9fff | ||
|
|
163b38e153 | ||
|
|
3b486084c8 | ||
|
|
9d453f0ba2 | ||
|
|
799851a83a | ||
|
|
7a9866f1b6 | ||
|
|
3d30f1f733 | ||
|
|
1e55764d52 | ||
|
|
020da89b6a | ||
|
|
6932422104 | ||
|
|
29aa15b253 | ||
|
|
c40519ec6f | ||
|
|
6c62c00963 | ||
|
|
1bd2e558d6 | ||
|
|
dbb1263a36 | ||
|
|
966c6a4531 | ||
|
|
fff2d01420 | ||
|
|
bf217ce252 | ||
|
|
a7ad4482f0 | ||
|
|
aa17661002 | ||
|
|
4e65aac7ae | ||
|
|
229ba18e6c | ||
|
|
b99be250a0 | ||
|
|
b9d4e2e501 | ||
|
|
ef2531edf3 | ||
|
|
eae3089201 | ||
|
|
0ea4de5f4c | ||
|
|
1e0daefa16 | ||
|
|
6d991a1fc8 | ||
|
|
a1845e1e72 | ||
|
|
f96a839bcf | ||
|
|
1282a15b14 | ||
|
|
35039b45e4 | ||
|
|
390766eb67 | ||
|
|
899d280ac7 | ||
|
|
96dc7f0259 | ||
|
|
0104bf3fc8 | ||
|
|
9b1e1bf56c | ||
|
|
33e0f16b3b | ||
|
|
0807d60c6a | ||
|
|
f018fde369 | ||
|
|
c47f8fc02c | ||
|
|
76ab923780 | ||
|
|
11dba3147d | ||
|
|
8c2d9101d5 | ||
|
|
61b8004536 | ||
|
|
db02c4ea21 | ||
|
|
f077a5962d | ||
|
|
fa4ba43eb9 | ||
|
|
9579423b24 | ||
|
|
02449f24c9 | ||
|
|
b973238323 | ||
|
|
582b8383d2 | ||
|
|
e1c9418aee | ||
|
|
2aa787f5f0 | ||
|
|
2189a40a39 | ||
|
|
51688d4078 | ||
|
|
cc4c0e3e0b | ||
|
|
1a44c6487e | ||
|
|
5e7ce610a0 | ||
|
|
1f02096edb | ||
|
|
fd7d3c4332 | ||
|
|
61cf566560 | ||
|
|
97d624114d | ||
|
|
52e8a2e9e4 | ||
|
|
261c271d60 | ||
|
|
cb6e314336 | ||
|
|
90315b3c40 | ||
|
|
5d7c3d1622 | ||
|
|
8c1ad1e9a6 | ||
|
|
969f6dbe13 | ||
|
|
6cce6d4c36 | ||
|
|
d27e5e9c97 | ||
|
|
af3b22f8b7 | ||
|
|
cbc1b29f3e | ||
|
|
54363f1246 | ||
|
|
d500531c04 | ||
|
|
0d800958aa | ||
|
|
471533d041 | ||
|
|
7dfc4c74da | ||
|
|
f709350b04 | ||
|
|
85c5928baa | ||
|
|
f5dfbaff4b | ||
|
|
689c2f11a3 | ||
|
|
f73fd97525 | ||
|
|
40523e6823 | ||
|
|
5e1472185c | ||
|
|
af005a6554 | ||
|
|
efd31be21c | ||
|
|
e9bda2810f | ||
|
|
ec4777b8d0 | ||
|
|
9b75121337 | ||
|
|
d262548d2e | ||
|
|
b5b654e054 | ||
|
|
dae8ab563c | ||
|
|
5751e9ec59 | ||
|
|
cc1b7a7a56 | ||
|
|
29249cdc1b | ||
|
|
e5bae8187f | ||
|
|
69adebfefa | ||
|
|
7dabbb65d0 | ||
|
|
b30bab8c1b | ||
|
|
0a1ed58454 | ||
|
|
5f5ee9c920 | ||
|
|
0aeebdd289 | ||
|
|
33e2aa341e | ||
|
|
a42788812e | ||
|
|
b07a038bc8 | ||
|
|
55e36ab982 | ||
|
|
90835ab917 | ||
|
|
5b46088ae4 | ||
|
|
d7e267eca5 | ||
|
|
807c47a076 | ||
|
|
7ebe6a5894 | ||
|
|
41c829fa32 | ||
|
|
8f1ce8c7f7 | ||
|
|
e55636ed52 | ||
|
|
e886262055 | ||
|
|
2fa7f8c511 | ||
|
|
4622ef770d | ||
|
|
d76f18b4f2 | ||
|
|
ec20778d83 | ||
|
|
b3ca71c6fb | ||
|
|
2d53dd05d8 | ||
|
|
68a2c45edf | ||
|
|
d2616cd6c6 | ||
|
|
01ec414873 | ||
|
|
150c9b5fa3 | ||
|
|
55df88d7ae | ||
|
|
619787e6d2 | ||
|
|
3f8bad3ed1 | ||
|
|
c146712b16 | ||
|
|
2cabe59c22 | ||
|
|
a67b92a04c | ||
|
|
9fb8e9edef | ||
|
|
d2bccbe8ac | ||
|
|
e44a60e814 | ||
|
|
02a71cb6a7 | ||
|
|
e600784ebf | ||
|
|
5e19a3b892 | ||
|
|
8bf112669f | ||
|
|
4278664208 | ||
|
|
0789657fd5 | ||
|
|
b566c78f00 | ||
|
|
a35122231c | ||
|
|
7e4ee32b54 | ||
|
|
7df80eadcf | ||
|
|
2aaba1d2b8 | ||
|
|
7c129a4018 | ||
|
|
cb66ce069e | ||
|
|
a27e72362a | ||
|
|
f44e5d3142 | ||
|
|
532163738e | ||
|
|
63fa922547 | ||
|
|
48e4cb5ae2 | ||
|
|
ff8a73c2d1 | ||
|
|
afd26c6f1a | ||
|
|
67b06a88b2 | ||
|
|
265e019381 | ||
|
|
560e36a65c | ||
|
|
b05a3fbb55 | ||
|
|
3a899e28dc | ||
|
|
f26238e824 | ||
|
|
3717e34bba | ||
|
|
be6f95d43e | ||
|
|
99a765dc06 | ||
|
|
351e7ea16b | ||
|
|
2fa79a2e2f | ||
|
|
44a917929d | ||
|
|
21ebc7f95b | ||
|
|
72e72d7d4b | ||
|
|
02ed2c0ebe | ||
|
|
0f506ea8eb | ||
|
|
b914d6e305 | ||
|
|
956e19be7d | ||
|
|
b3d5a4dfdb | ||
|
|
c63cdae84f | ||
|
|
dec044ad8b | ||
|
|
2a12ec09fb | ||
|
|
91e920c498 | ||
|
|
9b19c45735 | ||
|
|
3843d21dbf | ||
|
|
73db164fb1 | ||
|
|
ab32dd7420 | ||
|
|
2a7aa2fc0d | ||
|
|
f5e98eb86f | ||
|
|
362a19c2e1 | ||
|
|
f4a4956dd4 | ||
|
|
746488cabf | ||
|
|
4449248c6f | ||
|
|
036e14ab7f | ||
|
|
f840eee1b7 | ||
|
|
553132443f | ||
|
|
d20242f589 | ||
|
|
68affce274 | ||
|
|
c4b9065749 | ||
|
|
d57a5d1793 | ||
|
|
74e062fdb3 | ||
|
|
6bdc0c92fe | ||
|
|
d7945de001 | ||
|
|
3ba2a29e54 | ||
|
|
76b438f79c | ||
|
|
bc14f06a07 | ||
|
|
feee075122 | ||
|
|
a77cf1beec | ||
|
|
d7bfdd0efc | ||
|
|
62aee36f82 | ||
|
|
0709367587 | ||
|
|
98277f6ceb | ||
|
|
8dd509ba53 | ||
|
|
8df455f55b | ||
|
|
36782f13bf | ||
|
|
e823067a6b | ||
|
|
c3ef12d580 | ||
|
|
321155eb40 | ||
|
|
d34c074b92 | ||
|
|
abc8e903c1 | ||
|
|
832ba38f1b | ||
|
|
70de2f5278 | ||
|
|
604d4eec79 | ||
|
|
b806eb6a61 | ||
|
|
39948db59a | ||
|
|
fbfb4e2a73 | ||
|
|
595ac84779 | ||
|
|
746f72a279 | ||
|
|
dec6f04499 | ||
|
|
a90d266017 | ||
|
|
df9fcf9850 |
@@ -246,6 +246,7 @@ esphome/components/radon_eye_rd200/* @jeffeb3
|
|||||||
esphome/components/rc522/* @glmnet
|
esphome/components/rc522/* @glmnet
|
||||||
esphome/components/rc522_i2c/* @glmnet
|
esphome/components/rc522_i2c/* @glmnet
|
||||||
esphome/components/rc522_spi/* @glmnet
|
esphome/components/rc522_spi/* @glmnet
|
||||||
|
esphome/components/resistance_sampler/* @jesserockz
|
||||||
esphome/components/restart/* @esphome/core
|
esphome/components/restart/* @esphome/core
|
||||||
esphome/components/rf_bridge/* @jesserockz
|
esphome/components/rf_bridge/* @jesserockz
|
||||||
esphome/components/rgbct/* @jesserockz
|
esphome/components/rgbct/* @jesserockz
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
# One of "docker", "hassio"
|
# One of "docker", "hassio"
|
||||||
ARG BASEIMGTYPE=docker
|
ARG BASEIMGTYPE=docker
|
||||||
|
|
||||||
|
|
||||||
# https://github.com/hassio-addons/addon-debian-base/releases
|
# https://github.com/hassio-addons/addon-debian-base/releases
|
||||||
FROM ghcr.io/hassio-addons/debian-base:7.2.0 AS base-hassio
|
FROM ghcr.io/hassio-addons/debian-base:7.2.0 AS base-hassio
|
||||||
# https://hub.docker.com/_/debian?tab=tags&page=1&name=bookworm
|
# https://hub.docker.com/_/debian?tab=tags&page=1&name=bookworm
|
||||||
@@ -12,9 +13,11 @@ FROM debian:12.2-slim AS base-docker
|
|||||||
|
|
||||||
FROM base-${BASEIMGTYPE} AS base
|
FROM base-${BASEIMGTYPE} AS base
|
||||||
|
|
||||||
|
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
ARG TARGETVARIANT
|
ARG TARGETVARIANT
|
||||||
|
|
||||||
|
|
||||||
# Note that --break-system-packages is used below because
|
# Note that --break-system-packages is used below because
|
||||||
# https://peps.python.org/pep-0668/ added a safety check that prevents
|
# https://peps.python.org/pep-0668/ added a safety check that prevents
|
||||||
# installing packages with the same name as a system package. This is
|
# installing packages with the same name as a system package. This is
|
||||||
@@ -46,7 +49,7 @@ RUN \
|
|||||||
libssl-dev=3.0.11-1~deb12u2 \
|
libssl-dev=3.0.11-1~deb12u2 \
|
||||||
libffi-dev=3.4.4-1 \
|
libffi-dev=3.4.4-1 \
|
||||||
cargo=0.66.0+ds1-1 \
|
cargo=0.66.0+ds1-1 \
|
||||||
pkg-config=1.8.1-1; \
|
pkg-config=1.8.1-1 \
|
||||||
gcc-arm-linux-gnueabihf=4:12.2.0-3; \
|
gcc-arm-linux-gnueabihf=4:12.2.0-3; \
|
||||||
fi; \
|
fi; \
|
||||||
rm -rf \
|
rm -rf \
|
||||||
@@ -60,7 +63,6 @@ ENV \
|
|||||||
# Store globally installed pio libs in /piolibs
|
# Store globally installed pio libs in /piolibs
|
||||||
PLATFORMIO_GLOBALLIB_DIR=/piolibs
|
PLATFORMIO_GLOBALLIB_DIR=/piolibs
|
||||||
|
|
||||||
|
|
||||||
# Support legacy binaries on Debian multiarch system. There is no "correct" way
|
# Support legacy binaries on Debian multiarch system. There is no "correct" way
|
||||||
# to do this, other than using properly built toolchains...
|
# to do this, other than using properly built toolchains...
|
||||||
# See: https://unix.stackexchange.com/questions/553743/correct-way-to-add-lib-ld-linux-so-3-in-debian
|
# See: https://unix.stackexchange.com/questions/553743/correct-way-to-add-lib-ld-linux-so-3-in-debian
|
||||||
@@ -71,8 +73,12 @@ RUN \
|
|||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
# Ubuntu python3-pip is missing wheel
|
# Ubuntu python3-pip is missing wheel
|
||||||
pip3 install --break-system-packages --no-cache-dir \
|
if [ "$TARGETARCH$TARGETVARIANT" = "armv7" ]; then \
|
||||||
platformio==6.1.11 \
|
export PIP_EXTRA_INDEX_URL="https://www.piwheels.org/simple"; \
|
||||||
|
fi; \
|
||||||
|
pip3 install \
|
||||||
|
--break-system-packages --no-cache-dir \
|
||||||
|
platformio==6.1.11 \
|
||||||
# Change some platformio settings
|
# Change some platformio settings
|
||||||
&& platformio settings set enable_telemetry No \
|
&& platformio settings set enable_telemetry No \
|
||||||
&& platformio settings set check_platformio_interval 1000000 \
|
&& platformio settings set check_platformio_interval 1000000 \
|
||||||
@@ -83,8 +89,12 @@ RUN \
|
|||||||
# tmpfs is for https://github.com/rust-lang/cargo/issues/8719
|
# tmpfs is for https://github.com/rust-lang/cargo/issues/8719
|
||||||
|
|
||||||
COPY requirements.txt requirements_optional.txt script/platformio_install_deps.py platformio.ini /
|
COPY requirements.txt requirements_optional.txt script/platformio_install_deps.py platformio.ini /
|
||||||
RUN --mount=type=tmpfs,target=/root/.cargo CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse CARGO_HOME=/root/.cargo \
|
RUN --mount=type=tmpfs,target=/root/.cargo if [ "$TARGETARCH$TARGETVARIANT" = "armv7" ]; then \
|
||||||
pip3 install --break-system-packages --no-cache-dir -r /requirements.txt -r /requirements_optional.txt \
|
export PIP_EXTRA_INDEX_URL="https://www.piwheels.org/simple"; \
|
||||||
|
fi; \
|
||||||
|
CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse CARGO_HOME=/root/.cargo \
|
||||||
|
pip3 install \
|
||||||
|
--break-system-packages --no-cache-dir -r /requirements.txt -r /requirements_optional.txt \
|
||||||
&& /platformio_install_deps.py /platformio.ini --libraries
|
&& /platformio_install_deps.py /platformio.ini --libraries
|
||||||
|
|
||||||
|
|
||||||
@@ -93,7 +103,11 @@ FROM base AS docker
|
|||||||
|
|
||||||
# Copy esphome and install
|
# Copy esphome and install
|
||||||
COPY . /esphome
|
COPY . /esphome
|
||||||
RUN pip3 install --break-system-packages --no-cache-dir --no-use-pep517 -e /esphome
|
RUN if [ "$TARGETARCH$TARGETVARIANT" = "armv7" ]; then \
|
||||||
|
export PIP_EXTRA_INDEX_URL="https://www.piwheels.org/simple"; \
|
||||||
|
fi; \
|
||||||
|
pip3 install \
|
||||||
|
--break-system-packages --no-cache-dir --no-use-pep517 -e /esphome
|
||||||
|
|
||||||
# Settings for dashboard
|
# Settings for dashboard
|
||||||
ENV USERNAME="" PASSWORD=""
|
ENV USERNAME="" PASSWORD=""
|
||||||
@@ -139,7 +153,11 @@ COPY docker/ha-addon-rootfs/ /
|
|||||||
|
|
||||||
# Copy esphome and install
|
# Copy esphome and install
|
||||||
COPY . /esphome
|
COPY . /esphome
|
||||||
RUN pip3 install --break-system-packages --no-cache-dir --no-use-pep517 -e /esphome
|
RUN if [ "$TARGETARCH$TARGETVARIANT" = "armv7" ]; then \
|
||||||
|
export PIP_EXTRA_INDEX_URL="https://www.piwheels.org/simple"; \
|
||||||
|
fi; \
|
||||||
|
pip3 install \
|
||||||
|
--break-system-packages --no-cache-dir --no-use-pep517 -e /esphome
|
||||||
|
|
||||||
# Labels
|
# Labels
|
||||||
LABEL \
|
LABEL \
|
||||||
@@ -175,7 +193,11 @@ RUN \
|
|||||||
/var/lib/apt/lists/*
|
/var/lib/apt/lists/*
|
||||||
|
|
||||||
COPY requirements_test.txt /
|
COPY requirements_test.txt /
|
||||||
RUN pip3 install --break-system-packages --no-cache-dir -r /requirements_test.txt
|
RUN if [ "$TARGETARCH$TARGETVARIANT" = "armv7" ]; then \
|
||||||
|
export PIP_EXTRA_INDEX_URL="https://www.piwheels.org/simple"; \
|
||||||
|
fi; \
|
||||||
|
pip3 install \
|
||||||
|
--break-system-packages --no-cache-dir -r /requirements_test.txt
|
||||||
|
|
||||||
VOLUME ["/esphome"]
|
VOLUME ["/esphome"]
|
||||||
WORKDIR /esphome
|
WORKDIR /esphome
|
||||||
|
|||||||
@@ -1,71 +1,65 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Optional
|
from typing import Any
|
||||||
|
|
||||||
from aioesphomeapi import APIClient, ReconnectLogic, APIConnectionError, LogLevel
|
from aioesphomeapi import APIClient
|
||||||
import zeroconf
|
from aioesphomeapi.api_pb2 import SubscribeLogsResponse
|
||||||
|
from aioesphomeapi.log_runner import async_run
|
||||||
|
from zeroconf.asyncio import AsyncZeroconf
|
||||||
|
|
||||||
|
from esphome.const import CONF_KEY, CONF_PASSWORD, CONF_PORT, __version__
|
||||||
|
from esphome.core import CORE
|
||||||
|
|
||||||
from esphome.const import CONF_KEY, CONF_PORT, CONF_PASSWORD, __version__
|
|
||||||
from esphome.util import safe_print
|
|
||||||
from . import CONF_ENCRYPTION
|
from . import CONF_ENCRYPTION
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
async def async_run_logs(config, address):
|
async def async_run_logs(config, address):
|
||||||
|
"""Run the logs command in the event loop."""
|
||||||
conf = config["api"]
|
conf = config["api"]
|
||||||
port: int = int(conf[CONF_PORT])
|
port: int = int(conf[CONF_PORT])
|
||||||
password: str = conf[CONF_PASSWORD]
|
password: str = conf[CONF_PASSWORD]
|
||||||
noise_psk: Optional[str] = None
|
noise_psk: str | None = None
|
||||||
if CONF_ENCRYPTION in conf:
|
if CONF_ENCRYPTION in conf:
|
||||||
noise_psk = conf[CONF_ENCRYPTION][CONF_KEY]
|
noise_psk = conf[CONF_ENCRYPTION][CONF_KEY]
|
||||||
_LOGGER.info("Starting log output from %s using esphome API", address)
|
_LOGGER.info("Starting log output from %s using esphome API", address)
|
||||||
|
aiozc = AsyncZeroconf()
|
||||||
|
|
||||||
cli = APIClient(
|
cli = APIClient(
|
||||||
address,
|
address,
|
||||||
port,
|
port,
|
||||||
password,
|
password,
|
||||||
client_info=f"ESPHome Logs {__version__}",
|
client_info=f"ESPHome Logs {__version__}",
|
||||||
noise_psk=noise_psk,
|
noise_psk=noise_psk,
|
||||||
|
zeroconf_instance=aiozc.zeroconf,
|
||||||
)
|
)
|
||||||
first_connect = True
|
dashboard = CORE.dashboard
|
||||||
|
|
||||||
def on_log(msg):
|
def on_log(msg: SubscribeLogsResponse) -> None:
|
||||||
time_ = datetime.now().time().strftime("[%H:%M:%S]")
|
"""Handle a new log message."""
|
||||||
text = msg.message.decode("utf8", "backslashreplace")
|
time_ = datetime.now()
|
||||||
safe_print(time_ + text)
|
message: bytes = msg.message
|
||||||
|
text = message.decode("utf8", "backslashreplace")
|
||||||
async def on_connect():
|
if dashboard:
|
||||||
nonlocal first_connect
|
text = text.replace("\033", "\\033")
|
||||||
try:
|
print(f"[{time_.hour:02}:{time_.minute:02}:{time_.second:02}]{text}")
|
||||||
await cli.subscribe_logs(
|
|
||||||
on_log,
|
|
||||||
log_level=LogLevel.LOG_LEVEL_VERY_VERBOSE,
|
|
||||||
dump_config=first_connect,
|
|
||||||
)
|
|
||||||
first_connect = False
|
|
||||||
except APIConnectionError:
|
|
||||||
cli.disconnect()
|
|
||||||
|
|
||||||
async def on_disconnect(expected_disconnect: bool) -> None:
|
|
||||||
_LOGGER.warning("Disconnected from API")
|
|
||||||
|
|
||||||
zc = zeroconf.Zeroconf()
|
|
||||||
reconnect = ReconnectLogic(
|
|
||||||
client=cli,
|
|
||||||
on_connect=on_connect,
|
|
||||||
on_disconnect=on_disconnect,
|
|
||||||
zeroconf_instance=zc,
|
|
||||||
)
|
|
||||||
await reconnect.start()
|
|
||||||
|
|
||||||
|
stop = await async_run(cli, on_log, aio_zeroconf_instance=aiozc)
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
await asyncio.sleep(60)
|
await asyncio.sleep(60)
|
||||||
|
finally:
|
||||||
|
await aiozc.async_close()
|
||||||
|
await stop()
|
||||||
|
|
||||||
|
|
||||||
|
def run_logs(config: dict[str, Any], address: str) -> None:
|
||||||
|
"""Run the logs command."""
|
||||||
|
try:
|
||||||
|
asyncio.run(async_run_logs(config, address))
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
await reconnect.stop()
|
pass
|
||||||
zc.close()
|
|
||||||
|
|
||||||
|
|
||||||
def run_logs(config, address):
|
|
||||||
asyncio.run(async_run_logs(config, address))
|
|
||||||
|
|||||||
@@ -20,16 +20,21 @@ static const esp_bt_uuid_t NOTIFY_DESC_UUID = {
|
|||||||
void BLEClientBase::setup() {
|
void BLEClientBase::setup() {
|
||||||
static uint8_t connection_index = 0;
|
static uint8_t connection_index = 0;
|
||||||
this->connection_index_ = connection_index++;
|
this->connection_index_ = connection_index++;
|
||||||
|
|
||||||
auto ret = esp_ble_gattc_app_register(this->app_id);
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "gattc app register failed. app_id=%d code=%d", this->app_id, ret);
|
|
||||||
this->mark_failed();
|
|
||||||
}
|
|
||||||
this->set_state(espbt::ClientState::IDLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BLEClientBase::loop() {
|
void BLEClientBase::loop() {
|
||||||
|
if (!esp32_ble::global_ble->is_active()) {
|
||||||
|
this->set_state(espbt::ClientState::INIT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this->state_ == espbt::ClientState::INIT) {
|
||||||
|
auto ret = esp_ble_gattc_app_register(this->app_id);
|
||||||
|
if (ret) {
|
||||||
|
ESP_LOGE(TAG, "gattc app register failed. app_id=%d code=%d", this->app_id, ret);
|
||||||
|
this->mark_failed();
|
||||||
|
}
|
||||||
|
this->set_state(espbt::ClientState::IDLE);
|
||||||
|
}
|
||||||
// READY_TO_CONNECT means we have discovered the device
|
// READY_TO_CONNECT means we have discovered the device
|
||||||
// and the scanner has been stopped by the tracker.
|
// and the scanner has been stopped by the tracker.
|
||||||
if (this->state_ == espbt::ClientState::READY_TO_CONNECT) {
|
if (this->state_ == espbt::ClientState::READY_TO_CONNECT) {
|
||||||
|
|||||||
@@ -93,19 +93,19 @@ CONFIG_SCHEMA = cv.All(
|
|||||||
cv.Inclusive(
|
cv.Inclusive(
|
||||||
CONF_BIT0_HIGH,
|
CONF_BIT0_HIGH,
|
||||||
"custom",
|
"custom",
|
||||||
): cv.positive_time_period_microseconds,
|
): cv.positive_time_period_nanoseconds,
|
||||||
cv.Inclusive(
|
cv.Inclusive(
|
||||||
CONF_BIT0_LOW,
|
CONF_BIT0_LOW,
|
||||||
"custom",
|
"custom",
|
||||||
): cv.positive_time_period_microseconds,
|
): cv.positive_time_period_nanoseconds,
|
||||||
cv.Inclusive(
|
cv.Inclusive(
|
||||||
CONF_BIT1_HIGH,
|
CONF_BIT1_HIGH,
|
||||||
"custom",
|
"custom",
|
||||||
): cv.positive_time_period_microseconds,
|
): cv.positive_time_period_nanoseconds,
|
||||||
cv.Inclusive(
|
cv.Inclusive(
|
||||||
CONF_BIT1_LOW,
|
CONF_BIT1_LOW,
|
||||||
"custom",
|
"custom",
|
||||||
): cv.positive_time_period_microseconds,
|
): cv.positive_time_period_nanoseconds,
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
cv.has_exactly_one_key(CONF_CHIPSET, CONF_BIT0_HIGH),
|
cv.has_exactly_one_key(CONF_CHIPSET, CONF_BIT0_HIGH),
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ void LD2420Component::dump_config() {
|
|||||||
ESP_LOGCONFIG(TAG, "LD2420:");
|
ESP_LOGCONFIG(TAG, "LD2420:");
|
||||||
ESP_LOGCONFIG(TAG, " Firmware Version : %7s", this->ld2420_firmware_ver_);
|
ESP_LOGCONFIG(TAG, " Firmware Version : %7s", this->ld2420_firmware_ver_);
|
||||||
ESP_LOGCONFIG(TAG, "LD2420 Number:");
|
ESP_LOGCONFIG(TAG, "LD2420 Number:");
|
||||||
|
#ifdef USE_NUMBER
|
||||||
LOG_NUMBER(TAG, " Gate Timeout:", this->gate_timeout_number_);
|
LOG_NUMBER(TAG, " Gate Timeout:", this->gate_timeout_number_);
|
||||||
LOG_NUMBER(TAG, " Gate Max Distance:", this->max_gate_distance_number_);
|
LOG_NUMBER(TAG, " Gate Max Distance:", this->max_gate_distance_number_);
|
||||||
LOG_NUMBER(TAG, " Gate Min Distance:", this->min_gate_distance_number_);
|
LOG_NUMBER(TAG, " Gate Min Distance:", this->min_gate_distance_number_);
|
||||||
@@ -76,10 +77,13 @@ void LD2420Component::dump_config() {
|
|||||||
LOG_NUMBER(TAG, " Gate Move Threshold:", this->gate_move_threshold_numbers_[gate]);
|
LOG_NUMBER(TAG, " Gate Move Threshold:", this->gate_move_threshold_numbers_[gate]);
|
||||||
LOG_NUMBER(TAG, " Gate Still Threshold::", this->gate_still_threshold_numbers_[gate]);
|
LOG_NUMBER(TAG, " Gate Still Threshold::", this->gate_still_threshold_numbers_[gate]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef USE_BUTTON
|
||||||
LOG_BUTTON(TAG, " Apply Config:", this->apply_config_button_);
|
LOG_BUTTON(TAG, " Apply Config:", this->apply_config_button_);
|
||||||
LOG_BUTTON(TAG, " Revert Edits:", this->revert_config_button_);
|
LOG_BUTTON(TAG, " Revert Edits:", this->revert_config_button_);
|
||||||
LOG_BUTTON(TAG, " Factory Reset:", this->factory_reset_button_);
|
LOG_BUTTON(TAG, " Factory Reset:", this->factory_reset_button_);
|
||||||
LOG_BUTTON(TAG, " Restart Module:", this->restart_module_button_);
|
LOG_BUTTON(TAG, " Restart Module:", this->restart_module_button_);
|
||||||
|
#endif
|
||||||
ESP_LOGCONFIG(TAG, "LD2420 Select:");
|
ESP_LOGCONFIG(TAG, "LD2420 Select:");
|
||||||
LOG_SELECT(TAG, " Operating Mode", this->operating_selector_);
|
LOG_SELECT(TAG, " Operating Mode", this->operating_selector_);
|
||||||
if (this->get_firmware_int_(ld2420_firmware_ver_) < CALIBRATE_VERSION_MIN) {
|
if (this->get_firmware_int_(ld2420_firmware_ver_) < CALIBRATE_VERSION_MIN) {
|
||||||
@@ -183,9 +187,11 @@ void LD2420Component::factory_reset_action() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->set_min_max_distances_timeout(FACTORY_MAX_GATE, FACTORY_MIN_GATE, FACTORY_TIMEOUT);
|
this->set_min_max_distances_timeout(FACTORY_MAX_GATE, FACTORY_MIN_GATE, FACTORY_TIMEOUT);
|
||||||
|
#ifdef USE_NUMBER
|
||||||
this->gate_timeout_number_->state = FACTORY_TIMEOUT;
|
this->gate_timeout_number_->state = FACTORY_TIMEOUT;
|
||||||
this->min_gate_distance_number_->state = FACTORY_MIN_GATE;
|
this->min_gate_distance_number_->state = FACTORY_MIN_GATE;
|
||||||
this->max_gate_distance_number_->state = FACTORY_MAX_GATE;
|
this->max_gate_distance_number_->state = FACTORY_MAX_GATE;
|
||||||
|
#endif
|
||||||
for (uint8_t gate = 0; gate < LD2420_TOTAL_GATES; gate++) {
|
for (uint8_t gate = 0; gate < LD2420_TOTAL_GATES; gate++) {
|
||||||
this->new_config.move_thresh[gate] = FACTORY_MOVE_THRESH[gate];
|
this->new_config.move_thresh[gate] = FACTORY_MOVE_THRESH[gate];
|
||||||
this->new_config.still_thresh[gate] = FACTORY_STILL_THRESH[gate];
|
this->new_config.still_thresh[gate] = FACTORY_STILL_THRESH[gate];
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ from math import log
|
|||||||
|
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
from esphome.components import sensor
|
from esphome.components import sensor, resistance_sampler
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
CONF_CALIBRATION,
|
CONF_CALIBRATION,
|
||||||
CONF_REFERENCE_RESISTANCE,
|
CONF_REFERENCE_RESISTANCE,
|
||||||
@@ -15,6 +15,8 @@ from esphome.const import (
|
|||||||
UNIT_CELSIUS,
|
UNIT_CELSIUS,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
AUTO_LOAD = ["resistance_sampler"]
|
||||||
|
|
||||||
ntc_ns = cg.esphome_ns.namespace("ntc")
|
ntc_ns = cg.esphome_ns.namespace("ntc")
|
||||||
NTC = ntc_ns.class_("NTC", cg.Component, sensor.Sensor)
|
NTC = ntc_ns.class_("NTC", cg.Component, sensor.Sensor)
|
||||||
|
|
||||||
@@ -124,7 +126,7 @@ CONFIG_SCHEMA = (
|
|||||||
)
|
)
|
||||||
.extend(
|
.extend(
|
||||||
{
|
{
|
||||||
cv.Required(CONF_SENSOR): cv.use_id(sensor.Sensor),
|
cv.Required(CONF_SENSOR): cv.use_id(resistance_sampler.ResistanceSampler),
|
||||||
cv.Required(CONF_CALIBRATION): process_calibration,
|
cv.Required(CONF_CALIBRATION): process_calibration,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "esphome/core/component.h"
|
#include "esphome/components/resistance_sampler/resistance_sampler.h"
|
||||||
#include "esphome/components/sensor/sensor.h"
|
#include "esphome/components/sensor/sensor.h"
|
||||||
|
#include "esphome/core/component.h"
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace resistance {
|
namespace resistance {
|
||||||
@@ -11,7 +12,7 @@ enum ResistanceConfiguration {
|
|||||||
DOWNSTREAM,
|
DOWNSTREAM,
|
||||||
};
|
};
|
||||||
|
|
||||||
class ResistanceSensor : public Component, public sensor::Sensor {
|
class ResistanceSensor : public Component, public sensor::Sensor, resistance_sampler::ResistanceSampler {
|
||||||
public:
|
public:
|
||||||
void set_sensor(Sensor *sensor) { sensor_ = sensor; }
|
void set_sensor(Sensor *sensor) { sensor_ = sensor; }
|
||||||
void set_configuration(ResistanceConfiguration configuration) { configuration_ = configuration; }
|
void set_configuration(ResistanceConfiguration configuration) { configuration_ = configuration; }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.components import sensor
|
from esphome.components import sensor, resistance_sampler
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
CONF_SENSOR,
|
CONF_SENSOR,
|
||||||
STATE_CLASS_MEASUREMENT,
|
STATE_CLASS_MEASUREMENT,
|
||||||
@@ -8,8 +8,15 @@ from esphome.const import (
|
|||||||
ICON_FLASH,
|
ICON_FLASH,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
AUTO_LOAD = ["resistance_sampler"]
|
||||||
|
|
||||||
resistance_ns = cg.esphome_ns.namespace("resistance")
|
resistance_ns = cg.esphome_ns.namespace("resistance")
|
||||||
ResistanceSensor = resistance_ns.class_("ResistanceSensor", cg.Component, sensor.Sensor)
|
ResistanceSensor = resistance_ns.class_(
|
||||||
|
"ResistanceSensor",
|
||||||
|
cg.Component,
|
||||||
|
sensor.Sensor,
|
||||||
|
resistance_sampler.ResistanceSampler,
|
||||||
|
)
|
||||||
|
|
||||||
CONF_REFERENCE_VOLTAGE = "reference_voltage"
|
CONF_REFERENCE_VOLTAGE = "reference_voltage"
|
||||||
CONF_CONFIGURATION = "configuration"
|
CONF_CONFIGURATION = "configuration"
|
||||||
|
|||||||
6
esphome/components/resistance_sampler/__init__.py
Normal file
6
esphome/components/resistance_sampler/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import esphome.codegen as cg
|
||||||
|
|
||||||
|
resistance_sampler_ns = cg.esphome_ns.namespace("resistance_sampler")
|
||||||
|
ResistanceSampler = resistance_sampler_ns.class_("ResistanceSampler")
|
||||||
|
|
||||||
|
CODEOWNERS = ["@jesserockz"]
|
||||||
10
esphome/components/resistance_sampler/resistance_sampler.h
Normal file
10
esphome/components/resistance_sampler/resistance_sampler.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
namespace resistance_sampler {
|
||||||
|
|
||||||
|
/// Abstract interface to mark components that provide resistance values.
|
||||||
|
class ResistanceSampler {};
|
||||||
|
|
||||||
|
} // namespace resistance_sampler
|
||||||
|
} // namespace esphome
|
||||||
@@ -610,6 +610,11 @@ void VoiceAssistant::on_event(const api::VoiceAssistantEventResponse &msg) {
|
|||||||
if (code == "wake-word-timeout" || code == "wake_word_detection_aborted") {
|
if (code == "wake-word-timeout" || code == "wake_word_detection_aborted") {
|
||||||
// Don't change state here since either the "tts-end" or "run-end" events will do it.
|
// Don't change state here since either the "tts-end" or "run-end" events will do it.
|
||||||
return;
|
return;
|
||||||
|
} else if (code == "wake-provider-missing" || code == "wake-engine-missing") {
|
||||||
|
// Wake word is not set up or not ready on Home Assistant so stop and do not retry until user starts again.
|
||||||
|
this->request_stop();
|
||||||
|
this->error_trigger_->trigger(code, message);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
ESP_LOGE(TAG, "Error: %s - %s", code.c_str(), message.c_str());
|
ESP_LOGE(TAG, "Error: %s - %s", code.c_str(), message.c_str());
|
||||||
if (this->state_ != State::IDLE) {
|
if (this->state_ != State::IDLE) {
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ from esphome.core import (
|
|||||||
TimePeriod,
|
TimePeriod,
|
||||||
TimePeriodMicroseconds,
|
TimePeriodMicroseconds,
|
||||||
TimePeriodMilliseconds,
|
TimePeriodMilliseconds,
|
||||||
|
TimePeriodNanoseconds,
|
||||||
TimePeriodSeconds,
|
TimePeriodSeconds,
|
||||||
TimePeriodMinutes,
|
TimePeriodMinutes,
|
||||||
)
|
)
|
||||||
@@ -718,6 +719,8 @@ def time_period_str_unit(value):
|
|||||||
raise Invalid("Expected string for time period with unit.")
|
raise Invalid("Expected string for time period with unit.")
|
||||||
|
|
||||||
unit_to_kwarg = {
|
unit_to_kwarg = {
|
||||||
|
"ns": "nanoseconds",
|
||||||
|
"nanoseconds": "nanoseconds",
|
||||||
"us": "microseconds",
|
"us": "microseconds",
|
||||||
"microseconds": "microseconds",
|
"microseconds": "microseconds",
|
||||||
"ms": "milliseconds",
|
"ms": "milliseconds",
|
||||||
@@ -739,7 +742,10 @@ def time_period_str_unit(value):
|
|||||||
raise Invalid(f"Expected time period with unit, got {value}")
|
raise Invalid(f"Expected time period with unit, got {value}")
|
||||||
kwarg = unit_to_kwarg[one_of(*unit_to_kwarg)(match.group(2))]
|
kwarg = unit_to_kwarg[one_of(*unit_to_kwarg)(match.group(2))]
|
||||||
|
|
||||||
return TimePeriod(**{kwarg: float(match.group(1))})
|
try:
|
||||||
|
return TimePeriod(**{kwarg: float(match.group(1))})
|
||||||
|
except ValueError as e:
|
||||||
|
raise Invalid(e) from e
|
||||||
|
|
||||||
|
|
||||||
def time_period_in_milliseconds_(value):
|
def time_period_in_milliseconds_(value):
|
||||||
@@ -749,10 +755,18 @@ def time_period_in_milliseconds_(value):
|
|||||||
|
|
||||||
|
|
||||||
def time_period_in_microseconds_(value):
|
def time_period_in_microseconds_(value):
|
||||||
|
if value.nanoseconds is not None and value.nanoseconds != 0:
|
||||||
|
raise Invalid("Maximum precision is microseconds")
|
||||||
return TimePeriodMicroseconds(**value.as_dict())
|
return TimePeriodMicroseconds(**value.as_dict())
|
||||||
|
|
||||||
|
|
||||||
|
def time_period_in_nanoseconds_(value):
|
||||||
|
return TimePeriodNanoseconds(**value.as_dict())
|
||||||
|
|
||||||
|
|
||||||
def time_period_in_seconds_(value):
|
def time_period_in_seconds_(value):
|
||||||
|
if value.nanoseconds is not None and value.nanoseconds != 0:
|
||||||
|
raise Invalid("Maximum precision is seconds")
|
||||||
if value.microseconds is not None and value.microseconds != 0:
|
if value.microseconds is not None and value.microseconds != 0:
|
||||||
raise Invalid("Maximum precision is seconds")
|
raise Invalid("Maximum precision is seconds")
|
||||||
if value.milliseconds is not None and value.milliseconds != 0:
|
if value.milliseconds is not None and value.milliseconds != 0:
|
||||||
@@ -761,6 +775,8 @@ def time_period_in_seconds_(value):
|
|||||||
|
|
||||||
|
|
||||||
def time_period_in_minutes_(value):
|
def time_period_in_minutes_(value):
|
||||||
|
if value.nanoseconds is not None and value.nanoseconds != 0:
|
||||||
|
raise Invalid("Maximum precision is minutes")
|
||||||
if value.microseconds is not None and value.microseconds != 0:
|
if value.microseconds is not None and value.microseconds != 0:
|
||||||
raise Invalid("Maximum precision is minutes")
|
raise Invalid("Maximum precision is minutes")
|
||||||
if value.milliseconds is not None and value.milliseconds != 0:
|
if value.milliseconds is not None and value.milliseconds != 0:
|
||||||
@@ -787,6 +803,9 @@ time_period_microseconds = All(time_period, time_period_in_microseconds_)
|
|||||||
positive_time_period_microseconds = All(
|
positive_time_period_microseconds = All(
|
||||||
positive_time_period, time_period_in_microseconds_
|
positive_time_period, time_period_in_microseconds_
|
||||||
)
|
)
|
||||||
|
positive_time_period_nanoseconds = All(
|
||||||
|
positive_time_period, time_period_in_nanoseconds_
|
||||||
|
)
|
||||||
positive_not_null_time_period = All(
|
positive_not_null_time_period = All(
|
||||||
time_period, Range(min=TimePeriod(), min_included=False)
|
time_period, Range(min=TimePeriod(), min_included=False)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"""Constants used by esphome."""
|
"""Constants used by esphome."""
|
||||||
|
|
||||||
__version__ = "2023.11.0-dev"
|
__version__ = "2023.11.0b5"
|
||||||
|
|
||||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||||
VALID_SUBSTITUTIONS_CHARACTERS = (
|
VALID_SUBSTITUTIONS_CHARACTERS = (
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ def is_approximately_integer(value):
|
|||||||
class TimePeriod:
|
class TimePeriod:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
nanoseconds=None,
|
||||||
microseconds=None,
|
microseconds=None,
|
||||||
milliseconds=None,
|
milliseconds=None,
|
||||||
seconds=None,
|
seconds=None,
|
||||||
@@ -136,13 +137,23 @@ class TimePeriod:
|
|||||||
|
|
||||||
if microseconds is not None:
|
if microseconds is not None:
|
||||||
if not is_approximately_integer(microseconds):
|
if not is_approximately_integer(microseconds):
|
||||||
raise ValueError("Maximum precision is microseconds")
|
frac_microseconds, microseconds = math.modf(microseconds)
|
||||||
|
nanoseconds = (nanoseconds or 0) + frac_microseconds * 1000
|
||||||
self.microseconds = int(round(microseconds))
|
self.microseconds = int(round(microseconds))
|
||||||
else:
|
else:
|
||||||
self.microseconds = None
|
self.microseconds = None
|
||||||
|
|
||||||
|
if nanoseconds is not None:
|
||||||
|
if not is_approximately_integer(nanoseconds):
|
||||||
|
raise ValueError("Maximum precision is nanoseconds")
|
||||||
|
self.nanoseconds = int(round(nanoseconds))
|
||||||
|
else:
|
||||||
|
self.nanoseconds = None
|
||||||
|
|
||||||
def as_dict(self):
|
def as_dict(self):
|
||||||
out = OrderedDict()
|
out = OrderedDict()
|
||||||
|
if self.nanoseconds is not None:
|
||||||
|
out["nanoseconds"] = self.nanoseconds
|
||||||
if self.microseconds is not None:
|
if self.microseconds is not None:
|
||||||
out["microseconds"] = self.microseconds
|
out["microseconds"] = self.microseconds
|
||||||
if self.milliseconds is not None:
|
if self.milliseconds is not None:
|
||||||
@@ -158,6 +169,8 @@ class TimePeriod:
|
|||||||
return out
|
return out
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
if self.nanoseconds is not None:
|
||||||
|
return f"{self.total_nanoseconds}ns"
|
||||||
if self.microseconds is not None:
|
if self.microseconds is not None:
|
||||||
return f"{self.total_microseconds}us"
|
return f"{self.total_microseconds}us"
|
||||||
if self.milliseconds is not None:
|
if self.milliseconds is not None:
|
||||||
@@ -173,7 +186,11 @@ class TimePeriod:
|
|||||||
return "0s"
|
return "0s"
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"TimePeriod<{self.total_microseconds}>"
|
return f"TimePeriod<{self.total_nanoseconds}ns>"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def total_nanoseconds(self):
|
||||||
|
return self.total_microseconds * 1000 + (self.nanoseconds or 0)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def total_microseconds(self):
|
def total_microseconds(self):
|
||||||
@@ -201,35 +218,39 @@ class TimePeriod:
|
|||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if isinstance(other, TimePeriod):
|
if isinstance(other, TimePeriod):
|
||||||
return self.total_microseconds == other.total_microseconds
|
return self.total_nanoseconds == other.total_nanoseconds
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
if isinstance(other, TimePeriod):
|
if isinstance(other, TimePeriod):
|
||||||
return self.total_microseconds != other.total_microseconds
|
return self.total_nanoseconds != other.total_nanoseconds
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
|
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
if isinstance(other, TimePeriod):
|
if isinstance(other, TimePeriod):
|
||||||
return self.total_microseconds < other.total_microseconds
|
return self.total_nanoseconds < other.total_nanoseconds
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
|
|
||||||
def __gt__(self, other):
|
def __gt__(self, other):
|
||||||
if isinstance(other, TimePeriod):
|
if isinstance(other, TimePeriod):
|
||||||
return self.total_microseconds > other.total_microseconds
|
return self.total_nanoseconds > other.total_nanoseconds
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
|
|
||||||
def __le__(self, other):
|
def __le__(self, other):
|
||||||
if isinstance(other, TimePeriod):
|
if isinstance(other, TimePeriod):
|
||||||
return self.total_microseconds <= other.total_microseconds
|
return self.total_nanoseconds <= other.total_nanoseconds
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
|
|
||||||
def __ge__(self, other):
|
def __ge__(self, other):
|
||||||
if isinstance(other, TimePeriod):
|
if isinstance(other, TimePeriod):
|
||||||
return self.total_microseconds >= other.total_microseconds
|
return self.total_nanoseconds >= other.total_nanoseconds
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
|
|
||||||
|
|
||||||
|
class TimePeriodNanoseconds(TimePeriod):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TimePeriodMicroseconds(TimePeriod):
|
class TimePeriodMicroseconds(TimePeriod):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ from esphome.core import (
|
|||||||
TimePeriodMicroseconds,
|
TimePeriodMicroseconds,
|
||||||
TimePeriodMilliseconds,
|
TimePeriodMilliseconds,
|
||||||
TimePeriodMinutes,
|
TimePeriodMinutes,
|
||||||
|
TimePeriodNanoseconds,
|
||||||
TimePeriodSeconds,
|
TimePeriodSeconds,
|
||||||
)
|
)
|
||||||
from esphome.helpers import cpp_string_escape, indent_all_but_first_and_last
|
from esphome.helpers import cpp_string_escape, indent_all_but_first_and_last
|
||||||
@@ -351,6 +352,8 @@ def safe_exp(obj: SafeExpType) -> Expression:
|
|||||||
return IntLiteral(obj)
|
return IntLiteral(obj)
|
||||||
if isinstance(obj, float):
|
if isinstance(obj, float):
|
||||||
return FloatLiteral(obj)
|
return FloatLiteral(obj)
|
||||||
|
if isinstance(obj, TimePeriodNanoseconds):
|
||||||
|
return IntLiteral(int(obj.total_nanoseconds))
|
||||||
if isinstance(obj, TimePeriodMicroseconds):
|
if isinstance(obj, TimePeriodMicroseconds):
|
||||||
return IntLiteral(int(obj.total_microseconds))
|
return IntLiteral(int(obj.total_microseconds))
|
||||||
if isinstance(obj, TimePeriodMilliseconds):
|
if isinstance(obj, TimePeriodMilliseconds):
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import base64
|
|||||||
import binascii
|
import binascii
|
||||||
import codecs
|
import codecs
|
||||||
import collections
|
import collections
|
||||||
|
import datetime
|
||||||
import functools
|
import functools
|
||||||
import gzip
|
import gzip
|
||||||
import hashlib
|
import hashlib
|
||||||
@@ -1406,15 +1407,17 @@ def make_app(debug=get_bool_env(ENV_DEV)):
|
|||||||
)
|
)
|
||||||
|
|
||||||
class StaticFileHandler(tornado.web.StaticFileHandler):
|
class StaticFileHandler(tornado.web.StaticFileHandler):
|
||||||
def set_extra_headers(self, path):
|
def get_cache_time(
|
||||||
if "favicon.ico" in path:
|
self, path: str, modified: datetime.datetime | None, mime_type: str
|
||||||
self.set_header("Cache-Control", "max-age=84600, public")
|
) -> int:
|
||||||
else:
|
"""Override to customize cache control behavior."""
|
||||||
if debug:
|
if debug:
|
||||||
self.set_header(
|
return 0
|
||||||
"Cache-Control",
|
# Assets that are hashed have ?hash= in the URL, all javascript
|
||||||
"no-store, no-cache, must-revalidate, max-age=0",
|
# filenames hashed so we can cache them for a long time
|
||||||
)
|
if "hash" in self.request.arguments or "/javascript" in mime_type:
|
||||||
|
return self.CACHE_MAX_AGE
|
||||||
|
return super().get_cache_time(path, modified, mime_type)
|
||||||
|
|
||||||
app_settings = {
|
app_settings = {
|
||||||
"debug": debug,
|
"debug": debug,
|
||||||
|
|||||||
@@ -147,12 +147,13 @@ class DashboardImportDiscovery:
|
|||||||
|
|
||||||
|
|
||||||
class EsphomeZeroconf(Zeroconf):
|
class EsphomeZeroconf(Zeroconf):
|
||||||
def resolve_host(self, host: str, timeout=3.0):
|
def resolve_host(self, host: str, timeout: float = 3.0) -> str | None:
|
||||||
"""Resolve a host name to an IP address."""
|
"""Resolve a host name to an IP address."""
|
||||||
name = host.partition(".")[0]
|
name = host.partition(".")[0]
|
||||||
info = HostResolver(f"{name}.{ESPHOME_SERVICE_TYPE}", ESPHOME_SERVICE_TYPE)
|
info = HostResolver(ESPHOME_SERVICE_TYPE, f"{name}.{ESPHOME_SERVICE_TYPE}")
|
||||||
if (info.load_from_cache(self) or info.request(self, timeout * 1000)) and (
|
if (
|
||||||
addresses := info.ip_addresses_by_version(IPVersion.V4Only)
|
info.load_from_cache(self)
|
||||||
):
|
or (timeout and info.request(self, timeout * 1000))
|
||||||
|
) and (addresses := info.ip_addresses_by_version(IPVersion.V4Only)):
|
||||||
return str(addresses[0])
|
return str(addresses[0])
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ platformio==6.1.11 # When updating platformio, also update Dockerfile
|
|||||||
esptool==4.6.2
|
esptool==4.6.2
|
||||||
click==8.1.7
|
click==8.1.7
|
||||||
esphome-dashboard==20231107.0
|
esphome-dashboard==20231107.0
|
||||||
aioesphomeapi==18.2.4
|
aioesphomeapi==18.4.0
|
||||||
zeroconf==0.120.0
|
zeroconf==0.123.0
|
||||||
|
|
||||||
# esp-idf requires this, but doesn't bundle it by default
|
# esp-idf requires this, but doesn't bundle it by default
|
||||||
# https://github.com/espressif/esp-idf/blob/220590d599e134d7a5e7f1e683cc4550349ffbf8/requirements.txt#L24
|
# https://github.com/espressif/esp-idf/blob/220590d599e134d7a5e7f1e683cc4550349ffbf8/requirements.txt#L24
|
||||||
|
|||||||
@@ -116,14 +116,16 @@ class TestTimePeriod:
|
|||||||
|
|
||||||
assert actual == expected
|
assert actual == expected
|
||||||
|
|
||||||
def test_init__microseconds_with_fraction(self):
|
def test_init__nanoseconds_with_fraction(self):
|
||||||
with pytest.raises(ValueError, match="Maximum precision is microseconds"):
|
with pytest.raises(ValueError, match="Maximum precision is nanoseconds"):
|
||||||
core.TimePeriod(microseconds=1.1)
|
core.TimePeriod(nanoseconds=1.1)
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"kwargs, expected",
|
"kwargs, expected",
|
||||||
(
|
(
|
||||||
({}, "0s"),
|
({}, "0s"),
|
||||||
|
({"nanoseconds": 1}, "1ns"),
|
||||||
|
({"nanoseconds": 1.0001}, "1ns"),
|
||||||
({"microseconds": 1}, "1us"),
|
({"microseconds": 1}, "1us"),
|
||||||
({"microseconds": 1.0001}, "1us"),
|
({"microseconds": 1.0001}, "1us"),
|
||||||
({"milliseconds": 2}, "2ms"),
|
({"milliseconds": 2}, "2ms"),
|
||||||
|
|||||||
Reference in New Issue
Block a user