diff --git a/homeassistant/components/abode/sensor.py b/homeassistant/components/abode/sensor.py index e25921f295f3dc2998157391967f558fce911a88..6ee0cf59cbf7231458233774ca0fbe2af553daf6 100644 --- a/homeassistant/components/abode/sensor.py +++ b/homeassistant/components/abode/sensor.py @@ -16,9 +16,9 @@ _LOGGER = logging.getLogger(__name__) # Sensor types: Name, icon SENSOR_TYPES = { - "temp": ["Temperature", DEVICE_CLASS_TEMPERATURE], - "humidity": ["Humidity", DEVICE_CLASS_HUMIDITY], - "lux": ["Lux", DEVICE_CLASS_ILLUMINANCE], + CONST.TEMP_STATUS_KEY: ["Temperature", DEVICE_CLASS_TEMPERATURE], + CONST.HUMI_STATUS_KEY: ["Humidity", DEVICE_CLASS_HUMIDITY], + CONST.LUX_STATUS_KEY: ["Lux", DEVICE_CLASS_ILLUMINANCE], } @@ -29,15 +29,16 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async def async_setup_entry(hass, config_entry, async_add_entities): """Set up a sensor for an Abode device.""" - data = hass.data[DOMAIN] + entities = [] - devices = [] for device in data.abode.get_devices(generic_type=CONST.TYPE_SENSOR): for sensor_type in SENSOR_TYPES: - devices.append(AbodeSensor(data, device, sensor_type)) + if sensor_type not in device.get_value(CONST.STATUSES_KEY): + continue + entities.append(AbodeSensor(data, device, sensor_type)) - async_add_entities(devices) + async_add_entities(entities) class AbodeSensor(AbodeDevice): @@ -62,6 +63,11 @@ class AbodeSensor(AbodeDevice): """Return the device class.""" return self._device_class + @property + def unique_id(self): + """Return a unique ID to use for this device.""" + return f"{self._device.device_uuid}-{self._sensor_type}" + @property def state(self): """Return the state of the sensor."""