mirror of
https://github.com/esphome/esphome.git
synced 2026-11-16 18:16:04 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb736033c5 | ||
|
|
5a0094aece |
No files matched your search
@@ -358,6 +358,8 @@ class EthernetComponent final : public Component {
|
||||
// to be called at runtime after enable_on_boot:false without re-allocating, and
|
||||
// ensures setup() skips the heavy init when enable_on_boot_ is false.
|
||||
bool ethernet_initialized_{false};
|
||||
// PHY link state from ETHERNET_EVENT_CONNECTED/DISCONNECTED; the connect timeout retries only with a link.
|
||||
bool link_up_{false};
|
||||
#endif
|
||||
#if LWIP_IPV6
|
||||
uint8_t ipv6_count_{0};
|
||||
|
||||
@@ -160,8 +160,15 @@ void EthernetComponent::loop() {
|
||||
this->connect_trigger_.trigger();
|
||||
#endif
|
||||
} else if (now - this->connect_begin_ > 15000) {
|
||||
ESP_LOGW(TAG, "Connecting failed; reconnecting");
|
||||
this->start_connect_();
|
||||
if (this->link_up_) {
|
||||
ESP_LOGW(TAG, "Connecting failed; reconnecting");
|
||||
this->start_connect_();
|
||||
} else {
|
||||
// Restarting DHCP without a link only empties lwIP's DNS servers (espressif/esp-idf#19082);
|
||||
// the DHCP client already running resumes when the link comes up.
|
||||
ESP_LOGW(TAG, "Connecting failed: no link");
|
||||
this->connect_begin_ = now;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EthernetComponentState::CONNECTED:
|
||||
@@ -765,10 +772,12 @@ void EthernetComponent::eth_event_handler(void *arg, esp_event_base_t event_base
|
||||
event_name = "ETH stopped";
|
||||
global_eth_component->started_ = false;
|
||||
global_eth_component->connected_ = false;
|
||||
global_eth_component->link_up_ = false;
|
||||
global_eth_component->enable_loop_soon_any_context(); // Enable loop when connection state changes
|
||||
break;
|
||||
case ETHERNET_EVENT_CONNECTED:
|
||||
event_name = "ETH connected";
|
||||
global_eth_component->link_up_ = true;
|
||||
// For static IP configurations, GOT_IP event may not fire, so notify IP listeners here
|
||||
#if defined(USE_ETHERNET_IP_STATE_LISTENERS) && defined(USE_ETHERNET_MANUAL_IP)
|
||||
global_eth_component->ip_state_pending_.store(1, std::memory_order_release);
|
||||
@@ -785,6 +794,7 @@ void EthernetComponent::eth_event_handler(void *arg, esp_event_base_t event_base
|
||||
case ETHERNET_EVENT_DISCONNECTED:
|
||||
event_name = "ETH disconnected";
|
||||
global_eth_component->connected_ = false;
|
||||
global_eth_component->link_up_ = false;
|
||||
global_eth_component->enable_loop_soon_any_context(); // Enable loop when connection state changes
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import logging
|
||||
|
||||
from esphome import pins
|
||||
import esphome.codegen as cg
|
||||
from esphome.components import light
|
||||
@@ -35,6 +37,8 @@ from ._methods import (
|
||||
)
|
||||
from .const import CHIP_TYPES, CONF_ASYNC, CONF_BUS, ONE_WIRE_CHIPS
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
neopixelbus_ns = cg.esphome_ns.namespace("neopixelbus")
|
||||
NeoPixelBusLightOutputBase = neopixelbus_ns.class_(
|
||||
"NeoPixelBusLightOutputBase", light.AddressableLight
|
||||
@@ -135,12 +139,13 @@ def _validate(config):
|
||||
return config
|
||||
|
||||
|
||||
def _reject_esp32(config: ConfigType) -> ConfigType:
|
||||
def _warn_esp32_deprecated(config: ConfigType) -> ConfigType:
|
||||
if CORE.is_esp32:
|
||||
raise cv.Invalid(
|
||||
"'neopixelbus' is no longer supported on ESP32. Use the "
|
||||
"'esp32_rmt_led_strip' light platform instead: "
|
||||
"https://esphome.io/components/light/esp32_rmt_led_strip/"
|
||||
_LOGGER.warning(
|
||||
"'neopixelbus' on ESP32 is deprecated. The upstream library "
|
||||
"(makuna/NeoPixelBus) is no longer actively maintained. Migrate "
|
||||
"to 'esp32_rmt_led_strip'. Removal is targeted for 2027.1 but "
|
||||
"may happen sooner once ESPHome moves to ESP-IDF 6."
|
||||
)
|
||||
return config
|
||||
|
||||
@@ -178,10 +183,18 @@ def _validate_method(value):
|
||||
|
||||
|
||||
CONFIG_SCHEMA = cv.All(
|
||||
_reject_esp32,
|
||||
cv.only_with_framework(frameworks=Framework.ARDUINO),
|
||||
cv.only_with_framework(
|
||||
frameworks=Framework.ARDUINO,
|
||||
suggestions={
|
||||
Framework.ESP_IDF: (
|
||||
"esp32_rmt_led_strip",
|
||||
"light/esp32_rmt_led_strip",
|
||||
)
|
||||
},
|
||||
),
|
||||
cv.require_framework_version(
|
||||
esp8266_arduino=cv.Version(2, 4, 0),
|
||||
esp32_arduino=cv.Version(0, 0, 0),
|
||||
),
|
||||
light.ADDRESSABLE_LIGHT_SCHEMA.extend(
|
||||
{
|
||||
@@ -198,6 +211,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
).extend(cv.COMPONENT_SCHEMA),
|
||||
_choose_default_method,
|
||||
_validate,
|
||||
_warn_esp32_deprecated,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
#include "esphome/core/application.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esp_netif_net_stack.h"
|
||||
#include "lwip/dns.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "ip_address.h"
|
||||
#ifdef USE_ETHERNET
|
||||
#include "esphome/components/ethernet/ethernet_component.h"
|
||||
#endif
|
||||
@@ -72,6 +74,18 @@ static esp_netif_t *connected_ethernet_netif() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// True when lwIP's global DNS table holds the netif's own servers. Call with the lwIP core lock held.
|
||||
static bool dns_is_netifs(esp_netif_t *netif) {
|
||||
for (auto type : {ESP_NETIF_DNS_MAIN, ESP_NETIF_DNS_BACKUP}) {
|
||||
esp_netif_dns_info_t own{};
|
||||
if (esp_netif_get_dns_info(netif, type, &own) != ESP_OK)
|
||||
return true;
|
||||
if (IPAddress(&own.ip) != IPAddress(dns_getserver(type)))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void NetworkComponent::loop() {
|
||||
// Pin the default route to the first connected interface in the user's priority
|
||||
// order; ESP-IDF's own route_prio selection would always favor WiFi.
|
||||
@@ -114,12 +128,14 @@ void NetworkComponent::loop() {
|
||||
if (now - this->last_route_check_ < ROUTE_CHECK_INTERVAL_MS)
|
||||
return;
|
||||
this->last_route_check_ = now;
|
||||
bool route_is_ours;
|
||||
bool still_ours;
|
||||
{
|
||||
LwIPLock lock;
|
||||
route_is_ours = static_cast<void *>(netif_default) == esp_netif_get_netif_impl(best);
|
||||
// DHCP starting on another netif empties lwIP's DNS table, and the manual default
|
||||
// stops ESP-IDF from refilling it (espressif/esp-idf#19082); re-asserting copies it back.
|
||||
still_ours = static_cast<void *>(netif_default) == esp_netif_get_netif_impl(best) && dns_is_netifs(best);
|
||||
}
|
||||
if (route_is_ours)
|
||||
if (still_ours)
|
||||
return;
|
||||
}
|
||||
esp_err_t err = esp_netif_set_default_netif(best);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
light:
|
||||
- platform: neopixelbus
|
||||
id: addr3
|
||||
name: Neopixelbus Light
|
||||
gamma_correct: 2.8
|
||||
color_correct: [0.0, 0.0, 0.0, 0.0]
|
||||
default_transition_length: 10s
|
||||
effects:
|
||||
- addressable_flicker:
|
||||
name: Flicker Effect With Custom Values
|
||||
update_interval: 16ms
|
||||
intensity: 5%
|
||||
type: GRBW
|
||||
variant: SK6812
|
||||
method: ESP32_I2S_0
|
||||
num_leds: 5
|
||||
pin: 4
|
||||
Reference in new issue
Block a user