Update the sensor classes in the demo binary_sensor
This updates the two demo sensors we have so they show contextual icons in the UI.
This commit is contained in:
parent
d93883f153
commit
d57df2ddde
1 changed files with 9 additions and 3 deletions
|
@ -9,17 +9,23 @@ from homeassistant.components.binary_sensor import BinarySensorDevice
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Sets up the Demo binary sensors. """
|
""" Sets up the Demo binary sensors. """
|
||||||
add_devices([
|
add_devices([
|
||||||
DemoBinarySensor('Basement Floor Wet', False),
|
DemoBinarySensor('Basement Floor Wet', False, 'moisture'),
|
||||||
DemoBinarySensor('Movement Backyard', True),
|
DemoBinarySensor('Movement Backyard', True, 'motion'),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
class DemoBinarySensor(BinarySensorDevice):
|
class DemoBinarySensor(BinarySensorDevice):
|
||||||
""" A Demo binary sensor. """
|
""" A Demo binary sensor. """
|
||||||
|
|
||||||
def __init__(self, name, state):
|
def __init__(self, name, state, sensor_class):
|
||||||
self._name = name
|
self._name = name
|
||||||
self._state = state
|
self._state = state
|
||||||
|
self._sensor_type = sensor_class
|
||||||
|
|
||||||
|
@property
|
||||||
|
def sensor_class(self):
|
||||||
|
""" Return our class. """
|
||||||
|
return self._sensor_type
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue