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
+11 -2
View File
@@ -1,7 +1,14 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import sensor
from esphome.const import CONF_SENSOR, DEVICE_CLASS_EMPTY, UNIT_OHM, ICON_FLASH, CONF_ID
from esphome.const import (
CONF_SENSOR,
DEVICE_CLASS_EMPTY,
STATE_CLASS_MEASUREMENT,
UNIT_OHM,
ICON_FLASH,
CONF_ID,
)
resistance_ns = cg.esphome_ns.namespace("resistance")
ResistanceSensor = resistance_ns.class_("ResistanceSensor", cg.Component, sensor.Sensor)
@@ -17,7 +24,9 @@ CONFIGURATIONS = {
}
CONFIG_SCHEMA = (
sensor.sensor_schema(UNIT_OHM, ICON_FLASH, 1, DEVICE_CLASS_EMPTY)
sensor.sensor_schema(
UNIT_OHM, ICON_FLASH, 1, DEVICE_CLASS_EMPTY, STATE_CLASS_MEASUREMENT
)
.extend(
{
cv.GenerateID(): cv.declare_id(ResistanceSensor),