ESPHome
2026.3.0-dev
Loading...
Searching...
No Matches
esphome
components
ethernet_info
ethernet_info_text_sensor.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/core/component.h
"
4
#include "
esphome/components/text_sensor/text_sensor.h
"
5
#include "
esphome/components/ethernet/ethernet_component.h
"
6
7
#ifdef USE_ESP32
8
9
namespace
esphome::ethernet_info
{
10
11
#ifdef USE_ETHERNET_IP_STATE_LISTENERS
12
class
IPAddressEthernetInfo
final :
public
Component
,
13
public
text_sensor::TextSensor
,
14
public
ethernet::EthernetIPStateListener
{
15
public
:
16
void
setup
()
override
;
17
void
dump_config
()
override
;
18
void
add_ip_sensors
(uint8_t index,
text_sensor::TextSensor
*s) { this->
ip_sensors_
[index] = s; }
19
20
// EthernetIPStateListener interface
21
void
on_ip_state
(
const
network::IPAddresses
&ips,
const
network::IPAddress
&dns1,
22
const
network::IPAddress
&dns2)
override
;
23
24
protected
:
25
std::array<text_sensor::TextSensor *, 5>
ip_sensors_
{};
26
};
27
28
class
DNSAddressEthernetInfo
final :
public
Component
,
29
public
text_sensor::TextSensor
,
30
public
ethernet::EthernetIPStateListener
{
31
public
:
32
void
setup
()
override
;
33
void
dump_config
()
override
;
34
35
// EthernetIPStateListener interface
36
void
on_ip_state
(
const
network::IPAddresses
&ips,
const
network::IPAddress
&dns1,
37
const
network::IPAddress
&dns2)
override
;
38
};
39
#endif
// USE_ETHERNET_IP_STATE_LISTENERS
40
41
class
MACAddressEthernetInfo
final :
public
Component
,
public
text_sensor::TextSensor
{
42
public
:
43
void
setup
()
override
{
44
char
buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
45
this->
publish_state
(
ethernet::global_eth_component
->get_eth_mac_address_pretty_into_buffer(buf));
46
}
47
float
get_setup_priority
()
const override
{
return
setup_priority::ETHERNET
; }
48
void
dump_config
()
override
;
49
};
50
51
}
// namespace esphome::ethernet_info
52
53
#endif
// USE_ESP32
esphome::Component
Definition
component.h:87
esphome::ethernet::EthernetIPStateListener
Listener interface for Ethernet IP state changes.
Definition
ethernet_component.h:29
esphome::ethernet_info::DNSAddressEthernetInfo
Definition
ethernet_info_text_sensor.h:30
esphome::ethernet_info::DNSAddressEthernetInfo::on_ip_state
void on_ip_state(const network::IPAddresses &ips, const network::IPAddress &dns1, const network::IPAddress &dns2) override
Definition
ethernet_info_text_sensor.cpp:36
esphome::ethernet_info::DNSAddressEthernetInfo::setup
void setup() override
Definition
ethernet_info_text_sensor.cpp:32
esphome::ethernet_info::DNSAddressEthernetInfo::dump_config
void dump_config() override
Definition
ethernet_info_text_sensor.cpp:34
esphome::ethernet_info::IPAddressEthernetInfo
Definition
ethernet_info_text_sensor.h:14
esphome::ethernet_info::IPAddressEthernetInfo::dump_config
void dump_config() override
Definition
ethernet_info_text_sensor.cpp:13
esphome::ethernet_info::IPAddressEthernetInfo::on_ip_state
void on_ip_state(const network::IPAddresses &ips, const network::IPAddress &dns1, const network::IPAddress &dns2) override
Definition
ethernet_info_text_sensor.cpp:15
esphome::ethernet_info::IPAddressEthernetInfo::ip_sensors_
std::array< text_sensor::TextSensor *, 5 > ip_sensors_
Definition
ethernet_info_text_sensor.h:25
esphome::ethernet_info::IPAddressEthernetInfo::setup
void setup() override
Definition
ethernet_info_text_sensor.cpp:11
esphome::ethernet_info::IPAddressEthernetInfo::add_ip_sensors
void add_ip_sensors(uint8_t index, text_sensor::TextSensor *s)
Definition
ethernet_info_text_sensor.h:18
esphome::ethernet_info::MACAddressEthernetInfo
Definition
ethernet_info_text_sensor.h:41
esphome::ethernet_info::MACAddressEthernetInfo::get_setup_priority
float get_setup_priority() const override
Definition
ethernet_info_text_sensor.h:47
esphome::ethernet_info::MACAddressEthernetInfo::setup
void setup() override
Definition
ethernet_info_text_sensor.h:43
esphome::ethernet_info::MACAddressEthernetInfo::dump_config
void dump_config() override
Definition
ethernet_info_text_sensor.cpp:48
esphome::text_sensor::TextSensor
Definition
text_sensor.h:28
esphome::text_sensor::TextSensor::publish_state
void publish_state(const std::string &state)
Definition
text_sensor.cpp:21
component.h
ethernet_component.h
esphome::ethernet_info
Definition
ethernet_info_text_sensor.cpp:6
esphome::ethernet::global_eth_component
EthernetComponent * global_eth_component
Definition
ethernet_component.cpp:45
esphome::network::IPAddresses
std::array< IPAddress, 5 > IPAddresses
Definition
ip_address.h:187
esphome::setup_priority::ETHERNET
constexpr float ETHERNET
Definition
component.h:37
esphome::network::IPAddress
Definition
ip_address.h:53
text_sensor.h
Generated by
1.12.0