hass-core/homeassistant/components/xs1/sensor.py
cgtobi 2c07bfb9e0 Remove dependencies and requirements (#23024)
* Remove dependencies and requirements

* Revert "Remove dependencies and requirements"

This reverts commit fe7171b4cd.

* Remove dependencies and requirements

* Revert "Remove dependencies and requirements"

This reverts commit 391355ee2c.

* Remove dependencies and requirements

* Fix flake8 complaints

* Fix more flake8 complaints

* Revert non-component removals
2019-04-12 10:13:30 -07:00

50 lines
1.4 KiB
Python

"""Support for XS1 sensors."""
import logging
from homeassistant.helpers.entity import Entity
from . import ACTUATORS, DOMAIN as COMPONENT_DOMAIN, SENSORS, XS1DeviceEntity
_LOGGER = logging.getLogger(__name__)
async def async_setup_platform(
hass, config, async_add_entities, discovery_info=None):
"""Set up the XS1 sensor platform."""
from xs1_api_client.api_constants import ActuatorType
sensors = hass.data[COMPONENT_DOMAIN][SENSORS]
actuators = hass.data[COMPONENT_DOMAIN][ACTUATORS]
sensor_entities = []
for sensor in sensors:
belongs_to_climate_actuator = False
for actuator in actuators:
if actuator.type() == ActuatorType.TEMPERATURE and \
actuator.name() in sensor.name():
belongs_to_climate_actuator = True
break
if not belongs_to_climate_actuator:
sensor_entities.append(XS1Sensor(sensor))
async_add_entities(sensor_entities)
class XS1Sensor(XS1DeviceEntity, Entity):
"""Representation of a Sensor."""
@property
def name(self):
"""Return the name of the sensor."""
return self.device.name()
@property
def state(self):
"""Return the state of the sensor."""
return self.device.value()
@property
def unit_of_measurement(self):
"""Return the unit of measurement."""
return self.device.unit()