mirror of
https://github.com/esphome/esphome.git
synced 2025-04-14 04:29:05 +02:00
[ethernet_info] return actual ethernet MAC address (#8492)
Co-authored-by: clydebarrow <2366188+clydebarrow@users.noreply.github.com>
This commit is contained in:
parent
219ba6152c
commit
99d5ca3266
2 changed files with 2 additions and 1 deletions
esphome/components
|
@ -580,7 +580,7 @@ void EthernetComponent::get_eth_mac_address_raw(uint8_t *mac) {
|
|||
|
||||
std::string EthernetComponent::get_eth_mac_address_pretty() {
|
||||
uint8_t mac[6];
|
||||
get_mac_address_raw(mac);
|
||||
get_eth_mac_address_raw(mac);
|
||||
return str_snprintf("%02X:%02X:%02X:%02X:%02X:%02X", 17, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ class DNSAddressEthernetInfo : public PollingComponent, public text_sensor::Text
|
|||
class MACAddressEthernetInfo : public Component, public text_sensor::TextSensor {
|
||||
public:
|
||||
void setup() override { this->publish_state(ethernet::global_eth_component->get_eth_mac_address_pretty()); }
|
||||
float get_setup_priority() const override { return setup_priority::ETHERNET; }
|
||||
std::string unique_id() override { return get_mac_address() + "-ethernetinfo-mac"; }
|
||||
void dump_config() override;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue