ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
wifi_info_text_sensor.h
Go to the documentation of this file.
1#pragma once
2
8#ifdef USE_WIFI
9#include <array>
10#include <span>
11
12namespace esphome::wifi_info {
13
14#ifdef USE_WIFI_IP_STATE_LISTENERS
16 public:
17 void setup() override;
18 void dump_config() override;
19#ifdef WIFI_INFO_IP_SENSOR_COUNT
20 void add_ip_sensors(uint8_t index, text_sensor::TextSensor *s) { this->ip_sensors_[index] = s; }
21#endif
22
23 // WiFiIPStateListener interface
24 void on_ip_state(const network::IPAddresses &ips, const network::IPAddress &dns1,
25 const network::IPAddress &dns2) override;
26
27 protected:
28#ifdef WIFI_INFO_IP_SENSOR_COUNT
29 // Sized to the highest configured address_N
30 std::array<text_sensor::TextSensor *, WIFI_INFO_IP_SENSOR_COUNT> ip_sensors_{};
31#endif
32};
33
35 public:
36 void setup() override;
37 void dump_config() override;
38
39 // WiFiIPStateListener interface
40 void on_ip_state(const network::IPAddresses &ips, const network::IPAddress &dns1,
41 const network::IPAddress &dns2) override;
42};
43#endif // USE_WIFI_IP_STATE_LISTENERS
44
45#ifdef USE_WIFI_SCAN_RESULTS_LISTENERS
46class ScanResultsWiFiInfo final : public Component,
49 public:
50 void setup() override;
51 float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
52 void dump_config() override;
53
54 // WiFiScanResultsListener interface
56};
57#endif // USE_WIFI_SCAN_RESULTS_LISTENERS
58
59#ifdef USE_WIFI_CONNECT_STATE_LISTENERS
61 public:
62 void setup() override;
63 void dump_config() override;
64
65 // WiFiConnectStateListener interface
66 void on_wifi_connect_state(StringRef ssid, std::span<const uint8_t, 6> bssid) override;
67};
68
70 public:
71 void setup() override;
72 void dump_config() override;
73
74 // WiFiConnectStateListener interface
75 void on_wifi_connect_state(StringRef ssid, std::span<const uint8_t, 6> bssid) override;
76};
77#endif // USE_WIFI_CONNECT_STATE_LISTENERS
78
79#ifdef USE_WIFI_POWER_SAVE_LISTENERS
80class PowerSaveModeWiFiInfo final : public Component,
83 public:
84 void setup() override;
85 void dump_config() override;
86
87 // WiFiPowerSaveListener interface
89};
90#endif // USE_WIFI_POWER_SAVE_LISTENERS
91
93 public:
94 void setup() override {
95 char mac_s[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
97 }
98 void dump_config() override;
99};
100
101} // namespace esphome::wifi_info
102#endif
BedjetMode mode
BedJet operating mode.
StringRef is a reference to a string owned by something else.
Definition string_ref.h:31
void publish_state(const std::string &state)
Definition text_sensor.h:42
Listener interface for WiFi connection state changes.
Listener interface for WiFi IP state changes.
Listener interface for WiFi power save mode changes.
Listener interface for WiFi scan results.
void on_wifi_connect_state(StringRef ssid, std::span< const uint8_t, 6 > bssid) override
void on_ip_state(const network::IPAddresses &ips, const network::IPAddress &dns1, const network::IPAddress &dns2) override
void on_ip_state(const network::IPAddresses &ips, const network::IPAddress &dns1, const network::IPAddress &dns2) override
std::array< text_sensor::TextSensor *, WIFI_INFO_IP_SENSOR_COUNT > ip_sensors_
void add_ip_sensors(uint8_t index, text_sensor::TextSensor *s)
void on_wifi_power_save(wifi::WiFiPowerSaveMode mode) override
void on_wifi_connect_state(StringRef ssid, std::span< const uint8_t, 6 > bssid) override
void on_wifi_scan_results(const wifi::wifi_scan_vector_t< wifi::WiFiScanResult > &results) override
std::array< IPAddress, 5 > IPAddresses
Definition ip_address.h:368
constexpr float AFTER_WIFI
For components that should be initialized after WiFi is connected.
Definition component.h:55
std::vector< T > wifi_scan_vector_t
const char * get_mac_address_pretty_into_buffer(std::span< char, MAC_ADDRESS_PRETTY_BUFFER_SIZE > buf)
Get the device MAC address into the given buffer, in colon-separated uppercase hex notation.
Definition helpers.cpp:854