mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add homematicip_cloud illuminance sensor (#14720)
* Add iluminance sensor and device_class for sensors * Fix lint
This commit is contained in:
parent
70edb2492a
commit
8f696193f0
@ -10,7 +10,9 @@ import logging
|
|||||||
from homeassistant.components.homematicip_cloud import (
|
from homeassistant.components.homematicip_cloud import (
|
||||||
HomematicipGenericDevice, DOMAIN as HOMEMATICIP_CLOUD_DOMAIN,
|
HomematicipGenericDevice, DOMAIN as HOMEMATICIP_CLOUD_DOMAIN,
|
||||||
ATTR_HOME_ID)
|
ATTR_HOME_ID)
|
||||||
from homeassistant.const import TEMP_CELSIUS
|
from homeassistant.const import (
|
||||||
|
TEMP_CELSIUS, DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_HUMIDITY,
|
||||||
|
DEVICE_CLASS_ILLUMINANCE)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -36,7 +38,7 @@ async def async_setup_platform(hass, config, async_add_devices,
|
|||||||
"""Set up the HomematicIP sensors devices."""
|
"""Set up the HomematicIP sensors devices."""
|
||||||
from homematicip.device import (
|
from homematicip.device import (
|
||||||
HeatingThermostat, TemperatureHumiditySensorWithoutDisplay,
|
HeatingThermostat, TemperatureHumiditySensorWithoutDisplay,
|
||||||
TemperatureHumiditySensorDisplay)
|
TemperatureHumiditySensorDisplay, MotionDetectorIndoor)
|
||||||
|
|
||||||
if discovery_info is None:
|
if discovery_info is None:
|
||||||
return
|
return
|
||||||
@ -50,6 +52,8 @@ async def async_setup_platform(hass, config, async_add_devices,
|
|||||||
TemperatureHumiditySensorWithoutDisplay)):
|
TemperatureHumiditySensorWithoutDisplay)):
|
||||||
devices.append(HomematicipTemperatureSensor(home, device))
|
devices.append(HomematicipTemperatureSensor(home, device))
|
||||||
devices.append(HomematicipHumiditySensor(home, device))
|
devices.append(HomematicipHumiditySensor(home, device))
|
||||||
|
if isinstance(device, MotionDetectorIndoor):
|
||||||
|
devices.append(HomematicipIlluminanceSensor(home, device))
|
||||||
|
|
||||||
if devices:
|
if devices:
|
||||||
async_add_devices(devices)
|
async_add_devices(devices)
|
||||||
@ -149,6 +153,11 @@ class HomematicipHumiditySensor(HomematicipGenericDevice):
|
|||||||
"""Initialize the thermometer device."""
|
"""Initialize the thermometer device."""
|
||||||
super().__init__(home, device, 'Humidity')
|
super().__init__(home, device, 'Humidity')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_class(self):
|
||||||
|
"""Return the device class of the sensor."""
|
||||||
|
return DEVICE_CLASS_HUMIDITY
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
"""Return the icon."""
|
"""Return the icon."""
|
||||||
@ -172,6 +181,11 @@ class HomematicipTemperatureSensor(HomematicipGenericDevice):
|
|||||||
"""Initialize the thermometer device."""
|
"""Initialize the thermometer device."""
|
||||||
super().__init__(home, device, 'Temperature')
|
super().__init__(home, device, 'Temperature')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_class(self):
|
||||||
|
"""Return the device class of the sensor."""
|
||||||
|
return DEVICE_CLASS_TEMPERATURE
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
"""Return the icon."""
|
"""Return the icon."""
|
||||||
@ -186,3 +200,26 @@ class HomematicipTemperatureSensor(HomematicipGenericDevice):
|
|||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
"""Return the unit this state is expressed in."""
|
"""Return the unit this state is expressed in."""
|
||||||
return TEMP_CELSIUS
|
return TEMP_CELSIUS
|
||||||
|
|
||||||
|
|
||||||
|
class HomematicipIlluminanceSensor(HomematicipGenericDevice):
|
||||||
|
"""MomematicIP the thermometer device."""
|
||||||
|
|
||||||
|
def __init__(self, home, device):
|
||||||
|
"""Initialize the device."""
|
||||||
|
super().__init__(home, device, 'Illuminance')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_class(self):
|
||||||
|
"""Return the device class of the sensor."""
|
||||||
|
return DEVICE_CLASS_ILLUMINANCE
|
||||||
|
|
||||||
|
@property
|
||||||
|
def state(self):
|
||||||
|
"""Return the state."""
|
||||||
|
return self._device.illumination
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unit_of_measurement(self):
|
||||||
|
"""Return the unit this state is expressed in."""
|
||||||
|
return 'lx'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user