Add ethernet DNS text sensor and simplify DNS display format (#6450)

This commit is contained in:
Jimmy Hedman
2024-04-12 06:03:08 +02:00
committed by GitHub
parent 7eb524f920
commit 76daefe21c
8 changed files with 47 additions and 9 deletions
@@ -39,15 +39,10 @@ class IPAddressWiFiInfo : public PollingComponent, public text_sensor::TextSenso
class DNSAddressWifiInfo : public PollingComponent, public text_sensor::TextSensor {
public:
void update() override {
std::string dns_results;
auto dns_one = wifi::global_wifi_component->get_dns_address(0);
auto dns_two = wifi::global_wifi_component->get_dns_address(1);
dns_results += "DNS1: ";
dns_results += dns_one.str();
dns_results += " DNS2: ";
dns_results += dns_two.str();
std::string dns_results = dns_one.str() + " " + dns_two.str();
if (dns_results != this->last_results_) {
this->last_results_ = dns_results;