[wifi_info] Fix compilation error when using only mac_address sensor, add tests (#12222)
CI / Create common environment (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.13) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.11) (push) Has been cancelled
CI / Determine which jobs to run (push) Has been cancelled
CI / Run integration tests (push) Has been cancelled
CI / Run C++ unit tests (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / Run script/clang-tidy for ZEPHYR (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Test components batch (${{ matrix.components }}) (push) Has been cancelled
CI / pre-commit.ci lite (push) Has been cancelled
CI / Build target branch for memory impact (push) Has been cancelled
CI / Build PR branch for memory impact (push) Has been cancelled
CI / Comment memory impact (push) Has been cancelled
CI / CI Status (push) Has been cancelled

This commit is contained in:
Keith Burzinski
2025-12-01 02:48:47 -06:00
committed by GitHub
parent 161a18b326
commit dbc16ce468
7 changed files with 27 additions and 1 deletions
@@ -6,6 +6,8 @@ namespace esphome::wifi_info {
static const char *const TAG = "wifi_info";
#ifdef USE_WIFI_LISTENERS
static constexpr size_t MAX_STATE_LENGTH = 255;
/********************
@@ -98,6 +100,8 @@ void BSSIDWiFiInfo::on_wifi_connect_state(const std::string &ssid, const wifi::b
this->publish_state(buf);
}
#endif
/*********************
* MacAddressWifiInfo
********************/
@@ -9,6 +9,7 @@
namespace esphome::wifi_info {
#ifdef USE_WIFI_LISTENERS
class IPAddressWiFiInfo final : public Component, public text_sensor::TextSensor, public wifi::WiFiIPStateListener {
public:
void setup() override;
@@ -62,6 +63,7 @@ class BSSIDWiFiInfo final : public Component, public text_sensor::TextSensor, pu
// WiFiConnectStateListener interface
void on_wifi_connect_state(const std::string &ssid, const wifi::bssid_t &bssid) override;
};
#endif
class MacAddressWifiInfo final : public Component, public text_sensor::TextSensor {
public:
@@ -0,0 +1,8 @@
wifi:
ssid: MySSID
password: password1
text_sensor:
- platform: wifi_info
mac_address:
name: MAC Address
+1 -1
View File
@@ -13,6 +13,6 @@ text_sensor:
bssid:
name: BSSID
mac_address:
name: Mac Address
name: MAC Address
dns_address:
name: DNS ADdress
@@ -0,0 +1,4 @@
packages:
i2c: !include ../../test_build_components/common/i2c/esp32-idf.yaml
<<: !include common-mac.yaml
@@ -0,0 +1,4 @@
packages:
i2c: !include ../../test_build_components/common/i2c/esp8266-ard.yaml
<<: !include common-mac.yaml
@@ -0,0 +1,4 @@
packages:
i2c: !include ../../test_build_components/common/i2c/rp2040-ard.yaml
<<: !include common-mac.yaml