ESPHome  2023.5.5
ethernet_info_text_sensor.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 #ifdef USE_ESP32_FRAMEWORK_ARDUINO
8 
9 namespace esphome {
10 namespace ethernet_info {
11 
13  public:
14  void update() override {
16  if (ip != this->last_ip_) {
17  this->last_ip_ = ip;
18  this->publish_state(network::IPAddress(ip).str());
19  }
20  }
21 
22  float get_setup_priority() const override { return setup_priority::ETHERNET; }
23  std::string unique_id() override { return get_mac_address() + "-ethernetinfo"; }
24  void dump_config() override;
25 
26  protected:
28 };
29 
30 } // namespace ethernet_info
31 } // namespace esphome
32 
33 #endif // USE_ESP32_FRAMEWORK_ARDUINO
This class simplifies creating components that periodically check a state.
Definition: component.h:282
void publish_state(const std::string &state)
Definition: text_sensor.cpp:9
EthernetComponent * global_eth_component
std::string get_mac_address()
Get the device MAC address as a string, in lowercase hex notation.
Definition: helpers.cpp:480
Definition: a4988.cpp:4