From 0cbc29caca6c4de674cbe616888cb7aa8afef55d Mon Sep 17 00:00:00 2001 From: Diogo Gomes Date: Sun, 20 Mar 2022 21:48:11 +0000 Subject: [PATCH] Add unique_id through YAML to the integration component (#68435) --- homeassistant/components/integration/sensor.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/integration/sensor.py b/homeassistant/components/integration/sensor.py index 837886bbf56..c0bac1b2745 100644 --- a/homeassistant/components/integration/sensor.py +++ b/homeassistant/components/integration/sensor.py @@ -18,6 +18,7 @@ from homeassistant.const import ( ATTR_UNIT_OF_MEASUREMENT, CONF_METHOD, CONF_NAME, + CONF_UNIQUE_ID, STATE_UNAVAILABLE, STATE_UNKNOWN, TIME_DAYS, @@ -70,6 +71,7 @@ PLATFORM_SCHEMA = vol.All( PLATFORM_SCHEMA.extend( { vol.Optional(CONF_NAME): cv.string, + vol.Optional(CONF_UNIQUE_ID): cv.string, vol.Required(CONF_SOURCE_SENSOR): cv.entity_id, vol.Optional(CONF_ROUND_DIGITS, default=DEFAULT_ROUND): vol.Coerce(int), vol.Optional(CONF_UNIT_PREFIX, default=None): vol.In(UNIT_PREFIXES), @@ -125,7 +127,7 @@ async def async_setup_platform( name=config.get(CONF_NAME), round_digits=config[CONF_ROUND_DIGITS], source_entity=config[CONF_SOURCE_SENSOR], - unique_id=None, + unique_id=config.get(CONF_UNIQUE_ID), unit_of_measurement=config.get(CONF_UNIT_OF_MEASUREMENT), unit_prefix=config[CONF_UNIT_PREFIX], unit_time=config[CONF_UNIT_TIME],