mirror of
https://github.com/esphome/esphome.git
synced 2026-05-29 06:27:24 +08:00
[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
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:
@@ -6,6 +6,8 @@ namespace esphome::wifi_info {
|
|||||||
|
|
||||||
static const char *const TAG = "wifi_info";
|
static const char *const TAG = "wifi_info";
|
||||||
|
|
||||||
|
#ifdef USE_WIFI_LISTENERS
|
||||||
|
|
||||||
static constexpr size_t MAX_STATE_LENGTH = 255;
|
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);
|
this->publish_state(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* MacAddressWifiInfo
|
* MacAddressWifiInfo
|
||||||
********************/
|
********************/
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
namespace esphome::wifi_info {
|
namespace esphome::wifi_info {
|
||||||
|
|
||||||
|
#ifdef USE_WIFI_LISTENERS
|
||||||
class IPAddressWiFiInfo final : public Component, public text_sensor::TextSensor, public wifi::WiFiIPStateListener {
|
class IPAddressWiFiInfo final : public Component, public text_sensor::TextSensor, public wifi::WiFiIPStateListener {
|
||||||
public:
|
public:
|
||||||
void setup() override;
|
void setup() override;
|
||||||
@@ -62,6 +63,7 @@ class BSSIDWiFiInfo final : public Component, public text_sensor::TextSensor, pu
|
|||||||
// WiFiConnectStateListener interface
|
// WiFiConnectStateListener interface
|
||||||
void on_wifi_connect_state(const std::string &ssid, const wifi::bssid_t &bssid) override;
|
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 {
|
class MacAddressWifiInfo final : public Component, public text_sensor::TextSensor {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
wifi:
|
||||||
|
ssid: MySSID
|
||||||
|
password: password1
|
||||||
|
|
||||||
|
text_sensor:
|
||||||
|
- platform: wifi_info
|
||||||
|
mac_address:
|
||||||
|
name: MAC Address
|
||||||
@@ -13,6 +13,6 @@ text_sensor:
|
|||||||
bssid:
|
bssid:
|
||||||
name: BSSID
|
name: BSSID
|
||||||
mac_address:
|
mac_address:
|
||||||
name: Mac Address
|
name: MAC Address
|
||||||
dns_address:
|
dns_address:
|
||||||
name: 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
|
||||||
Reference in New Issue
Block a user