parent
ff81f6a762
commit
583a375876
@ -0,0 +1,26 @@
|
|||||||
|
#include "esphome/core/log.h"
|
||||||
|
#include "empty_uart_sensor.h"
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
namespace empty_uart_sensor {
|
||||||
|
|
||||||
|
static const char *TAG = "empty_uart_sensor.sensor";
|
||||||
|
|
||||||
|
void EmptyUARTSensor::setup() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmptyUARTSensor::update() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmptyUARTSensor::loop() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmptyUARTSensor::dump_config(){
|
||||||
|
ESP_LOGCONFIG(TAG, "Empty UART sensor");
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace empty_UART_sensor
|
||||||
|
} // namespace esphome
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "esphome/core/component.h"
|
||||||
|
#include "esphome/components/sensor/sensor.h"
|
||||||
|
#include "esphome/components/uart/uart.h"
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
namespace empty_uart_sensor {
|
||||||
|
|
||||||
|
class EmptyUARTSensor : public sensor::Sensor, public PollingComponent, public uart::UARTDevice {
|
||||||
|
public:
|
||||||
|
void setup() override;
|
||||||
|
void update() override;
|
||||||
|
void loop() override;
|
||||||
|
void dump_config() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace empty_uart_sensor
|
||||||
|
} // namespace esphome
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
import esphome.codegen as cg
|
||||||
|
import esphome.config_validation as cv
|
||||||
|
from esphome.components import uart, sensor
|
||||||
|
from esphome.const import CONF_ID, ICON_EMPTY, UNIT_EMPTY
|
||||||
|
|
||||||
|
DEPENDENCIES = ['uart']
|
||||||
|
|
||||||
|
empty_uart_sensor_ns = cg.esphome_ns.namespace('empty_uart_sensor')
|
||||||
|
EmptyUARTSensor = empty_uart_sensor_ns.class_('EmptyUARTSensor', cg.PollingComponent, uart.UARTDevice)
|
||||||
|
|
||||||
|
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_EMPTY, ICON_EMPTY, 1).extend({
|
||||||
|
cv.GenerateID(): cv.declare_id(EmptyUARTSensor),
|
||||||
|
}).extend(cv.polling_component_schema('60s')).extend(uart.UART_DEVICE_SCHEMA)
|
||||||
|
|
||||||
|
def to_code(config):
|
||||||
|
var = cg.new_Pvariable(config[CONF_ID])
|
||||||
|
yield cg.register_component(var, config)
|
||||||
|
yield sensor.register_sensor(var, config)
|
||||||
|
yield uart.register_uart_device(var, config)
|
||||||
|
|
||||||
Loading…
Reference in new issue