1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-14 01:02:19 +01:00

Add support for Sensor state class (#1835)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Franck Nijhof
2021-06-03 03:49:56 +02:00
committed by GitHub
parent 913ac8b7e8
commit 11fb54c74e
112 changed files with 1237 additions and 269 deletions

View File

@@ -2,7 +2,14 @@ import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import pins
from esphome.components import sensor
from esphome.const import CONF_ID, CONF_PIN, DEVICE_CLASS_EMPTY, UNIT_SECOND, ICON_TIMER
from esphome.const import (
CONF_ID,
CONF_PIN,
DEVICE_CLASS_EMPTY,
STATE_CLASS_MEASUREMENT,
UNIT_SECOND,
ICON_TIMER,
)
pulse_width_ns = cg.esphome_ns.namespace("pulse_width")
@@ -11,7 +18,9 @@ PulseWidthSensor = pulse_width_ns.class_(
)
CONFIG_SCHEMA = (
sensor.sensor_schema(UNIT_SECOND, ICON_TIMER, 3, DEVICE_CLASS_EMPTY)
sensor.sensor_schema(
UNIT_SECOND, ICON_TIMER, 3, DEVICE_CLASS_EMPTY, STATE_CLASS_MEASUREMENT
)
.extend(
{
cv.GenerateID(): cv.declare_id(PulseWidthSensor),