mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 02:49:40 +00:00
Add unique ID to Airly config entries (#30681)
* Add unique ID to Airly config entries * Update tests * Update tests * Fix typo * Remove unnecesary and undo changes in first test * Suggested change
This commit is contained in:
committed by
springstan
parent
ce13fb8d73
commit
15645ab0c9
@@ -2,8 +2,6 @@
|
||||
from homeassistant.const import (
|
||||
ATTR_ATTRIBUTION,
|
||||
ATTR_DEVICE_CLASS,
|
||||
CONF_LATITUDE,
|
||||
CONF_LONGITUDE,
|
||||
CONF_NAME,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_PRESSURE,
|
||||
@@ -62,14 +60,12 @@ SENSOR_TYPES = {
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up Airly sensor entities based on a config entry."""
|
||||
name = config_entry.data[CONF_NAME]
|
||||
latitude = config_entry.data[CONF_LATITUDE]
|
||||
longitude = config_entry.data[CONF_LONGITUDE]
|
||||
|
||||
data = hass.data[DOMAIN][DATA_CLIENT][config_entry.entry_id]
|
||||
|
||||
sensors = []
|
||||
for sensor in SENSOR_TYPES:
|
||||
unique_id = f"{latitude}-{longitude}-{sensor.lower()}"
|
||||
unique_id = f"{config_entry.unique_id}-{sensor.lower()}"
|
||||
sensors.append(AirlySensor(data, name, sensor, unique_id))
|
||||
|
||||
async_add_entities(sensors, True)
|
||||
|
||||
Reference in New Issue
Block a user