Merge pull request #1268 from flyte/tcp-component-pr

Add generic TCP socket component
This commit is contained in:
Paulus Schoutsen committed 2016-02-21 19:21:20 -08:00
commit 82e11e237e
4 files changed
+368

No files matched your search

@@ -0,0 +1,30 @@
"""
homeassistant.components.binary_sensor.tcp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Provides a binary_sensor which gets its values from a TCP socket.
"""
import logging
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.sensor.tcp import Sensor, DOMAIN, CONF_VALUE_ON
DEPENDENCIES = [DOMAIN]
_LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_entities, discovery_info=None):
""" Create the BinarySensor. """
if not BinarySensor.validate_config(config):
return False
add_entities((BinarySensor(hass, config),))
class BinarySensor(BinarySensorDevice, Sensor):
""" A binary sensor which is on when its state == CONF_VALUE_ON. """
required = (CONF_VALUE_ON,)
@property
def is_on(self):
return self._state == self._config[CONF_VALUE_ON]