Add tcp component.
This commit is contained in:
parent
bca3207e0c
commit
3d83eea5f7
3 changed files with 175 additions and 0 deletions
30
homeassistant/components/binary_sensor/tcp.py
Normal file
30
homeassistant/components/binary_sensor/tcp.py
Normal file
|
@ -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 import tcp
|
||||
|
||||
|
||||
DEPENDENCIES = [tcp.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(config),))
|
||||
|
||||
|
||||
class BinarySensor(tcp.TCPEntity, BinarySensorDevice):
|
||||
""" A binary sensor which is on when its state == CONF_VALUE_ON. """
|
||||
required = (tcp.CONF_VALUE_ON,)
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
return self._state == self._config[tcp.CONF_VALUE_ON]
|
Loading…
Add table
Add a link
Reference in a new issue