Move generic tcp sensor entity to specific sensor component
This commit is contained in:
parent
3d83eea5f7
commit
cf93644d54
3 changed files with 110 additions and 112 deletions
|
@ -6,10 +6,11 @@ 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
|
||||
from homeassistant.components.tcp import DOMAIN, CONF_VALUE_ON
|
||||
from homeassistant.components.sensor.tcp import Sensor
|
||||
|
||||
|
||||
DEPENDENCIES = [tcp.DOMAIN]
|
||||
DEPENDENCIES = [DOMAIN]
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -21,10 +22,10 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||
add_entities((BinarySensor(config),))
|
||||
|
||||
|
||||
class BinarySensor(tcp.TCPEntity, BinarySensorDevice):
|
||||
class BinarySensor(Sensor, BinarySensorDevice):
|
||||
""" A binary sensor which is on when its state == CONF_VALUE_ON. """
|
||||
required = (tcp.CONF_VALUE_ON,)
|
||||
required = (CONF_VALUE_ON,)
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
return self._state == self._config[tcp.CONF_VALUE_ON]
|
||||
return self._state == self._config[CONF_VALUE_ON]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue