Add unique id to mold_indicator setup from yaml (#126992)

This commit is contained in:
G Johansson 2024-09-30 09:02:43 +02:00 committed by GitHub
parent e87542e091
commit 0b3d69aa8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -20,6 +20,7 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ATTR_UNIT_OF_MEASUREMENT, ATTR_UNIT_OF_MEASUREMENT,
CONF_NAME, CONF_NAME,
CONF_UNIQUE_ID,
PERCENTAGE, PERCENTAGE,
STATE_UNKNOWN, STATE_UNKNOWN,
UnitOfTemperature, UnitOfTemperature,
@ -64,6 +65,7 @@ PLATFORM_SCHEMA = SENSOR_PLATFORM_SCHEMA.extend(
vol.Required(CONF_INDOOR_HUMIDITY): cv.entity_id, vol.Required(CONF_INDOOR_HUMIDITY): cv.entity_id,
vol.Optional(CONF_CALIBRATION_FACTOR): vol.Coerce(float), vol.Optional(CONF_CALIBRATION_FACTOR): vol.Coerce(float),
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_UNIQUE_ID): cv.string,
} }
) )
@ -80,6 +82,7 @@ async def async_setup_platform(
outdoor_temp_sensor: str = config[CONF_OUTDOOR_TEMP] outdoor_temp_sensor: str = config[CONF_OUTDOOR_TEMP]
indoor_humidity_sensor: str = config[CONF_INDOOR_HUMIDITY] indoor_humidity_sensor: str = config[CONF_INDOOR_HUMIDITY]
calib_factor: float = config[CONF_CALIBRATION_FACTOR] calib_factor: float = config[CONF_CALIBRATION_FACTOR]
unique_id: str | None = config.get(CONF_UNIQUE_ID)
async_add_entities( async_add_entities(
[ [
@ -91,7 +94,7 @@ async def async_setup_platform(
outdoor_temp_sensor, outdoor_temp_sensor,
indoor_humidity_sensor, indoor_humidity_sensor,
calib_factor, calib_factor,
None, unique_id,
) )
], ],
False, False,