Add configurable state_class to Modbus sensors (#54103)

* add configurable state_class

* Add test of new parameter.

Co-authored-by: jan Iversen <jancasacondor@gmail.com>
This commit is contained in:
Matthias Alphart 2021-08-25 11:50:54 +02:00 committed by GitHub
parent 186b8d4f4b
commit 51361fbd2b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 1 deletions

View file

@ -9,6 +9,7 @@ from homeassistant.components.modbus.const import (
CONF_LAZY_ERROR,
CONF_PRECISION,
CONF_SCALE,
CONF_STATE_CLASS,
CONF_SWAP,
CONF_SWAP_BYTE,
CONF_SWAP_NONE,
@ -20,7 +21,10 @@ from homeassistant.components.modbus.const import (
DATA_TYPE_STRING,
DATA_TYPE_UINT,
)
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.components.sensor import (
DOMAIN as SENSOR_DOMAIN,
STATE_CLASS_MEASUREMENT,
)
from homeassistant.const import (
CONF_ADDRESS,
CONF_COUNT,
@ -62,6 +66,7 @@ ENTITY_ID = f"{SENSOR_DOMAIN}.{TEST_ENTITY_NAME}"
CONF_PRECISION: 0,
CONF_SCALE: 1,
CONF_OFFSET: 0,
CONF_STATE_CLASS: STATE_CLASS_MEASUREMENT,
CONF_LAZY_ERROR: 10,
CONF_INPUT_TYPE: CALL_TYPE_REGISTER_HOLDING,
CONF_DEVICE_CLASS: "battery",