mirror of
https://github.com/esphome/esphome.git
synced 2024-11-23 23:48:11 +01:00
Merge branch 'esphome:dev' into dev
This commit is contained in:
commit
d90a51507b
19 changed files with 147 additions and 43 deletions
|
@ -167,7 +167,8 @@ esphome/components/homeassistant/* @OttoWinter
|
|||
esphome/components/honeywell_hih_i2c/* @Benichou34
|
||||
esphome/components/honeywellabp/* @RubyBailey
|
||||
esphome/components/honeywellabp2_i2c/* @jpfaff
|
||||
esphome/components/host/* @esphome/core
|
||||
esphome/components/host/* @clydebarrow @esphome/core
|
||||
esphome/components/host/time/* @clydebarrow
|
||||
esphome/components/hrxl_maxsonar_wr/* @netmikey
|
||||
esphome/components/hte501/* @Stock-M
|
||||
esphome/components/htu31d/* @betterengineering
|
||||
|
|
|
@ -100,6 +100,9 @@ RUN --mount=type=tmpfs,target=/root/.cargo if [ "$TARGETARCH$TARGETVARIANT" = "a
|
|||
--break-system-packages --no-cache-dir -r /requirements.txt -r /requirements_optional.txt \
|
||||
&& /platformio_install_deps.py /platformio.ini --libraries
|
||||
|
||||
# Avoid unsafe git error when container user and file config volume permissions don't match
|
||||
RUN git config --system --add safe.directory '/config/*'
|
||||
|
||||
|
||||
# ======================= docker-type image =======================
|
||||
FROM base AS docker
|
||||
|
|
|
@ -28,6 +28,13 @@ EthernetComponent *global_eth_component; // NOLINT(cppcoreguidelines-avoid-non-
|
|||
return; \
|
||||
}
|
||||
|
||||
#define ESPHL_ERROR_CHECK_RET(err, message, ret) \
|
||||
if ((err) != ESP_OK) { \
|
||||
ESP_LOGE(TAG, message ": (%d) %s", err, esp_err_to_name(err)); \
|
||||
this->mark_failed(); \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
EthernetComponent::EthernetComponent() { global_eth_component = this; }
|
||||
|
||||
void EthernetComponent::setup() {
|
||||
|
@ -498,22 +505,9 @@ void EthernetComponent::dump_connect_params_() {
|
|||
}
|
||||
#endif /* USE_NETWORK_IPV6 */
|
||||
|
||||
esp_err_t err;
|
||||
|
||||
uint8_t mac[6];
|
||||
err = esp_eth_ioctl(this->eth_handle_, ETH_CMD_G_MAC_ADDR, &mac);
|
||||
ESPHL_ERROR_CHECK(err, "ETH_CMD_G_MAC error");
|
||||
ESP_LOGCONFIG(TAG, " MAC Address: %02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
|
||||
eth_duplex_t duplex_mode;
|
||||
err = esp_eth_ioctl(this->eth_handle_, ETH_CMD_G_DUPLEX_MODE, &duplex_mode);
|
||||
ESPHL_ERROR_CHECK(err, "ETH_CMD_G_DUPLEX_MODE error");
|
||||
ESP_LOGCONFIG(TAG, " Is Full Duplex: %s", YESNO(duplex_mode == ETH_DUPLEX_FULL));
|
||||
|
||||
eth_speed_t speed;
|
||||
err = esp_eth_ioctl(this->eth_handle_, ETH_CMD_G_SPEED, &speed);
|
||||
ESPHL_ERROR_CHECK(err, "ETH_CMD_G_SPEED error");
|
||||
ESP_LOGCONFIG(TAG, " Link Speed: %u", speed == ETH_SPEED_100M ? 100 : 10);
|
||||
ESP_LOGCONFIG(TAG, " MAC Address: %s", this->get_eth_mac_address_pretty().c_str());
|
||||
ESP_LOGCONFIG(TAG, " Is Full Duplex: %s", YESNO(this->get_duplex_mode() == ETH_DUPLEX_FULL));
|
||||
ESP_LOGCONFIG(TAG, " Link Speed: %u", this->get_link_speed() == ETH_SPEED_100M ? 100 : 10);
|
||||
}
|
||||
|
||||
#ifdef USE_ETHERNET_SPI
|
||||
|
@ -546,6 +540,34 @@ std::string EthernetComponent::get_use_address() const {
|
|||
|
||||
void EthernetComponent::set_use_address(const std::string &use_address) { this->use_address_ = use_address; }
|
||||
|
||||
void EthernetComponent::get_eth_mac_address_raw(uint8_t *mac) {
|
||||
esp_err_t err;
|
||||
err = esp_eth_ioctl(this->eth_handle_, ETH_CMD_G_MAC_ADDR, mac);
|
||||
ESPHL_ERROR_CHECK(err, "ETH_CMD_G_MAC error");
|
||||
}
|
||||
|
||||
std::string EthernetComponent::get_eth_mac_address_pretty() {
|
||||
uint8_t mac[6];
|
||||
get_mac_address_raw(mac);
|
||||
return str_snprintf("%02X:%02X:%02X:%02X:%02X:%02X", 17, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
}
|
||||
|
||||
eth_duplex_t EthernetComponent::get_duplex_mode() {
|
||||
esp_err_t err;
|
||||
eth_duplex_t duplex_mode;
|
||||
err = esp_eth_ioctl(this->eth_handle_, ETH_CMD_G_DUPLEX_MODE, &duplex_mode);
|
||||
ESPHL_ERROR_CHECK_RET(err, "ETH_CMD_G_DUPLEX_MODE error", ETH_DUPLEX_HALF);
|
||||
return duplex_mode;
|
||||
}
|
||||
|
||||
eth_speed_t EthernetComponent::get_link_speed() {
|
||||
esp_err_t err;
|
||||
eth_speed_t speed;
|
||||
err = esp_eth_ioctl(this->eth_handle_, ETH_CMD_G_SPEED, &speed);
|
||||
ESPHL_ERROR_CHECK_RET(err, "ETH_CMD_G_SPEED error", ETH_SPEED_10M);
|
||||
return speed;
|
||||
}
|
||||
|
||||
bool EthernetComponent::powerdown() {
|
||||
ESP_LOGI(TAG, "Powering down ethernet PHY");
|
||||
if (this->phy_ == nullptr) {
|
||||
|
|
|
@ -74,6 +74,10 @@ class EthernetComponent : public Component {
|
|||
network::IPAddress get_dns_address(uint8_t num);
|
||||
std::string get_use_address() const;
|
||||
void set_use_address(const std::string &use_address);
|
||||
void get_eth_mac_address_raw(uint8_t *mac);
|
||||
std::string get_eth_mac_address_pretty();
|
||||
eth_duplex_t get_duplex_mode();
|
||||
eth_speed_t get_link_speed();
|
||||
bool powerdown();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -10,6 +10,7 @@ static const char *const TAG = "ethernet_info";
|
|||
|
||||
void IPAddressEthernetInfo::dump_config() { LOG_TEXT_SENSOR("", "EthernetInfo IPAddress", this); }
|
||||
void DNSAddressEthernetInfo::dump_config() { LOG_TEXT_SENSOR("", "EthernetInfo DNS Address", this); }
|
||||
void MACAddressEthernetInfo::dump_config() { LOG_TEXT_SENSOR("", "EthernetInfo MAC Address", this); }
|
||||
|
||||
} // namespace ethernet_info
|
||||
} // namespace esphome
|
||||
|
|
|
@ -59,6 +59,13 @@ class DNSAddressEthernetInfo : public PollingComponent, public text_sensor::Text
|
|||
std::string last_results_;
|
||||
};
|
||||
|
||||
class MACAddressEthernetInfo : public Component, public text_sensor::TextSensor {
|
||||
public:
|
||||
void setup() override { this->publish_state(ethernet::global_eth_component->get_eth_mac_address_pretty()); }
|
||||
std::string unique_id() override { return get_mac_address() + "-ethernetinfo-mac"; }
|
||||
void dump_config() override;
|
||||
};
|
||||
|
||||
} // namespace ethernet_info
|
||||
} // namespace esphome
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ from esphome.components import text_sensor
|
|||
from esphome.const import (
|
||||
CONF_IP_ADDRESS,
|
||||
CONF_DNS_ADDRESS,
|
||||
CONF_MAC_ADDRESS,
|
||||
ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
)
|
||||
|
||||
|
@ -19,6 +20,10 @@ DNSAddressEthernetInfo = ethernet_info_ns.class_(
|
|||
"DNSAddressEthernetInfo", text_sensor.TextSensor, cg.PollingComponent
|
||||
)
|
||||
|
||||
MACAddressEthernetInfo = ethernet_info_ns.class_(
|
||||
"MACAddressEthernetInfo", text_sensor.TextSensor, cg.PollingComponent
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.Optional(CONF_IP_ADDRESS): text_sensor.text_sensor_schema(
|
||||
|
@ -36,6 +41,9 @@ CONFIG_SCHEMA = cv.Schema(
|
|||
cv.Optional(CONF_DNS_ADDRESS): text_sensor.text_sensor_schema(
|
||||
DNSAddressEthernetInfo, entity_category=ENTITY_CATEGORY_DIAGNOSTIC
|
||||
).extend(cv.polling_component_schema("1s")),
|
||||
cv.Optional(CONF_MAC_ADDRESS): text_sensor.text_sensor_schema(
|
||||
MACAddressEthernetInfo, entity_category=ENTITY_CATEGORY_DIAGNOSTIC
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -51,3 +59,6 @@ async def to_code(config):
|
|||
if conf := config.get(CONF_DNS_ADDRESS):
|
||||
dns_info = await text_sensor.new_text_sensor(config[CONF_DNS_ADDRESS])
|
||||
await cg.register_component(dns_info, config[CONF_DNS_ADDRESS])
|
||||
if conf := config.get(CONF_MAC_ADDRESS):
|
||||
mac_info = await text_sensor.new_text_sensor(config[CONF_MAC_ADDRESS])
|
||||
await cg.register_component(mac_info, config[CONF_MAC_ADDRESS])
|
||||
|
|
|
@ -16,7 +16,7 @@ from .const import KEY_HOST
|
|||
# force import gpio to register pin schema
|
||||
from .gpio import host_pin_to_code # noqa
|
||||
|
||||
CODEOWNERS = ["@esphome/core"]
|
||||
CODEOWNERS = ["@esphome/core", "@clydebarrow"]
|
||||
AUTO_LOAD = ["network"]
|
||||
|
||||
|
||||
|
|
20
esphome/components/host/time/__init__.py
Normal file
20
esphome/components/host/time/__init__.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
import esphome.codegen as cg
|
||||
from esphome.const import CONF_ID
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import time as time_
|
||||
|
||||
CODEOWNERS = ["@clydebarrow"]
|
||||
|
||||
time_ns = cg.esphome_ns.namespace("host")
|
||||
HostTime = time_ns.class_("HostTime", time_.RealTimeClock)
|
||||
CONFIG_SCHEMA = time_.TIME_SCHEMA.extend(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(HostTime),
|
||||
}
|
||||
).extend(cv.COMPONENT_SCHEMA)
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
await cg.register_component(var, config)
|
||||
await time_.register_time(var, config)
|
15
esphome/components/host/time/host_time.h
Normal file
15
esphome/components/host/time/host_time.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/time/real_time_clock.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace host {
|
||||
|
||||
class HostTime : public time::RealTimeClock {
|
||||
public:
|
||||
void update() override {}
|
||||
};
|
||||
|
||||
} // namespace host
|
||||
} // namespace esphome
|
|
@ -109,6 +109,7 @@ void ImprovSerialComponent::write_data_(std::vector<uint8_t> &data) {
|
|||
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
case logger::UART_SELECTION_USB_SERIAL_JTAG:
|
||||
usb_serial_jtag_write_bytes((char *) data.data(), data.size(), 20 / portTICK_PERIOD_MS);
|
||||
usb_serial_jtag_ll_txfifo_flush(); // fixes for issue in IDF 4.4.7
|
||||
break;
|
||||
#endif // USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32S3
|
||||
default:
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32S3) || \
|
||||
defined(USE_ESP32_VARIANT_ESP32H2)
|
||||
#include <driver/usb_serial_jtag.h>
|
||||
#include <hal/usb_serial_jtag_ll.h>
|
||||
#endif
|
||||
#if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
#include <esp_private/usb_console.h>
|
||||
|
|
|
@ -20,7 +20,6 @@ namespace sntp {
|
|||
static const char *const TAG = "sntp";
|
||||
|
||||
void SNTPComponent::setup() {
|
||||
#ifndef USE_HOST
|
||||
ESP_LOGCONFIG(TAG, "Setting up SNTP...");
|
||||
#if defined(USE_ESP_IDF)
|
||||
if (esp_sntp_enabled()) {
|
||||
|
@ -44,7 +43,6 @@ void SNTPComponent::setup() {
|
|||
#endif
|
||||
|
||||
sntp_init();
|
||||
#endif
|
||||
}
|
||||
void SNTPComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "SNTP Time:");
|
||||
|
@ -54,7 +52,7 @@ void SNTPComponent::dump_config() {
|
|||
ESP_LOGCONFIG(TAG, " Timezone: '%s'", this->timezone_.c_str());
|
||||
}
|
||||
void SNTPComponent::update() {
|
||||
#if !defined(USE_ESP_IDF) && !defined(USE_HOST)
|
||||
#if !defined(USE_ESP_IDF)
|
||||
// force resync
|
||||
if (sntp_enabled()) {
|
||||
sntp_stop();
|
||||
|
|
|
@ -2,24 +2,41 @@ from esphome.components import time as time_
|
|||
import esphome.config_validation as cv
|
||||
import esphome.codegen as cg
|
||||
from esphome.core import CORE
|
||||
from esphome.const import CONF_ID, CONF_SERVERS
|
||||
|
||||
from esphome.const import (
|
||||
CONF_ID,
|
||||
CONF_SERVERS,
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_RP2040,
|
||||
PLATFORM_RTL87XX,
|
||||
PLATFORM_BK72XX,
|
||||
)
|
||||
|
||||
DEPENDENCIES = ["network"]
|
||||
sntp_ns = cg.esphome_ns.namespace("sntp")
|
||||
SNTPComponent = sntp_ns.class_("SNTPComponent", time_.RealTimeClock)
|
||||
|
||||
|
||||
DEFAULT_SERVERS = ["0.pool.ntp.org", "1.pool.ntp.org", "2.pool.ntp.org"]
|
||||
|
||||
CONFIG_SCHEMA = time_.TIME_SCHEMA.extend(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(SNTPComponent),
|
||||
cv.Optional(CONF_SERVERS, default=DEFAULT_SERVERS): cv.All(
|
||||
cv.ensure_list(cv.Any(cv.domain, cv.hostname)), cv.Length(min=1, max=3)
|
||||
),
|
||||
}
|
||||
).extend(cv.COMPONENT_SCHEMA)
|
||||
CONFIG_SCHEMA = cv.All(
|
||||
time_.TIME_SCHEMA.extend(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(SNTPComponent),
|
||||
cv.Optional(CONF_SERVERS, default=DEFAULT_SERVERS): cv.All(
|
||||
cv.ensure_list(cv.Any(cv.domain, cv.hostname)), cv.Length(min=1, max=3)
|
||||
),
|
||||
}
|
||||
).extend(cv.COMPONENT_SCHEMA),
|
||||
cv.only_on(
|
||||
[
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_RP2040,
|
||||
PLATFORM_BK72XX,
|
||||
PLATFORM_RTL87XX,
|
||||
]
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
|
|
|
@ -7,7 +7,10 @@ from esphome.const import (
|
|||
CONF_TIME_ID,
|
||||
CONF_ADDRESS,
|
||||
CONF_REBOOT_TIMEOUT,
|
||||
KEY_CORE,
|
||||
KEY_FRAMEWORK_VERSION,
|
||||
)
|
||||
from esphome.components.esp32 import CORE, add_idf_sdkconfig_option
|
||||
from esphome.components import time
|
||||
from esphome.core import TimePeriod
|
||||
from esphome import automation
|
||||
|
@ -117,6 +120,13 @@ async def to_code(config):
|
|||
if config[CONF_REQUIRE_CONNECTION_TO_PROCEED]:
|
||||
cg.add(var.disable_auto_proceed())
|
||||
|
||||
# Workaround for crash on IDF 5+
|
||||
# See https://github.com/trombik/esp_wireguard/issues/33#issuecomment-1568503651
|
||||
if CORE.using_esp_idf and CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] >= cv.Version(
|
||||
5, 0, 0
|
||||
):
|
||||
add_idf_sdkconfig_option("CONFIG_LWIP_PPP_SUPPORT", True)
|
||||
|
||||
# This flag is added here because the esp_wireguard library statically
|
||||
# set the size of its allowed_ips list at compile time using this value;
|
||||
# the '+1' modifier is relative to the device's own address that will
|
||||
|
|
|
@ -13,11 +13,6 @@ if [ ! -n "$DEVCONTAINER" ] && [ ! -n "$VIRTUAL_ENV" ] && [ ! "$ESPHOME_NO_VENV"
|
|||
source $location
|
||||
fi
|
||||
|
||||
# Avoid unsafe git error when running inside devcontainer
|
||||
if [ -n "$DEVCONTAINER" ]; then
|
||||
git config --global --add safe.directory "$PWD"
|
||||
fi
|
||||
|
||||
pip3 install -r requirements.txt -r requirements_optional.txt -r requirements_test.txt -r requirements_dev.txt
|
||||
pip3 install setuptools wheel
|
||||
pip3 install -e ".[dev,test,displays]" --config-settings editable_mode=compat
|
||||
|
|
|
@ -17,3 +17,5 @@ text_sensor:
|
|||
name: IP Address
|
||||
dns_address:
|
||||
name: DNS Address
|
||||
mac_address:
|
||||
name: MAC Address
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
time:
|
||||
- platform: sntp
|
||||
- platform: host
|
||||
id: esptime
|
||||
timezone: Australia/Sydney
|
||||
|
||||
logger:
|
||||
level: VERBOSE
|
||||
logs:
|
||||
lvgl: INFO
|
||||
display: DEBUG
|
||||
sensor: INFO
|
||||
vnc: DEBUG
|
||||
|
||||
host:
|
||||
mac_address: "62:23:45:AF:B3:DD"
|
||||
|
|
1
tests/components/sntp/test.bk72xx.yaml
Normal file
1
tests/components/sntp/test.bk72xx.yaml
Normal file
|
@ -0,0 +1 @@
|
|||
<<: !include common.yaml
|
Loading…
Reference in a new issue