mirror of
https://github.com/esphome/esphome.git
synced 2024-12-04 04:28:19 +01:00
25 lines
762 B
C
25 lines
762 B
C
|
#pragma once
|
||
|
|
||
|
#include "esphome/core/component.h"
|
||
|
#include "esphome/core/helpers.h"
|
||
|
#include "esphome/components/sensor/sensor.h"
|
||
|
#include "esphome/components/wifi/wifi_component.h"
|
||
|
|
||
|
namespace esphome {
|
||
|
namespace wifi_signal {
|
||
|
|
||
|
class WiFiSignalSensor : public sensor::PollingSensorComponent {
|
||
|
public:
|
||
|
explicit WiFiSignalSensor(const std::string &name, uint32_t update_interval)
|
||
|
: sensor::PollingSensorComponent(name, update_interval) {}
|
||
|
|
||
|
void update() override { this->publish_state(WiFi.RSSI()); }
|
||
|
void dump_config() override;
|
||
|
|
||
|
std::string unique_id() override { return get_mac_address() + "-wifisignal"; }
|
||
|
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
||
|
};
|
||
|
|
||
|
} // namespace wifi_signal
|
||
|
} // namespace esphome
|