2019-04-17 12:06:00 +02:00
|
|
|
#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 {
|
|
|
|
|
2019-04-22 21:56:30 +02:00
|
|
|
class WiFiSignalSensor : public sensor::Sensor, public PollingComponent {
|
2019-04-17 12:06:00 +02:00
|
|
|
public:
|
|
|
|
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
|