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:
@@ -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),
|
||||
|
Reference in New Issue
Block a user