mirror of
https://github.com/esphome/esphome.git
synced 2025-09-06 21:32:21 +01:00
Add class as first positional arg to sensor_schema (#3216)
This commit is contained in:
@@ -3,7 +3,6 @@ import esphome.config_validation as cv
|
||||
from esphome import pins
|
||||
from esphome.components import sensor
|
||||
from esphome.const import (
|
||||
CONF_ID,
|
||||
CONF_PIN,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
UNIT_SECOND,
|
||||
@@ -18,6 +17,7 @@ PulseWidthSensor = pulse_width_ns.class_(
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
sensor.sensor_schema(
|
||||
PulseWidthSensor,
|
||||
unit_of_measurement=UNIT_SECOND,
|
||||
icon=ICON_TIMER,
|
||||
accuracy_decimals=3,
|
||||
@@ -25,7 +25,6 @@ CONFIG_SCHEMA = (
|
||||
)
|
||||
.extend(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(PulseWidthSensor),
|
||||
cv.Required(CONF_PIN): cv.All(pins.internal_gpio_input_pin_schema),
|
||||
}
|
||||
)
|
||||
@@ -34,9 +33,8 @@ CONFIG_SCHEMA = (
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
var = await sensor.new_sensor(config)
|
||||
await cg.register_component(var, config)
|
||||
await sensor.register_sensor(var, config)
|
||||
|
||||
pin = await cg.gpio_pin_expression(config[CONF_PIN])
|
||||
cg.add(var.set_pin(pin))
|
||||
|
Reference in New Issue
Block a user