Created
May 17, 2018 18:09
-
-
Save fliphess/a3eb2341a630fa51290936196551521e to your computer and use it in GitHub Desktop.
Home assistant DST binary sensor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from homeassistant.components.binary_sensor import BinarySensorDevice | |
def setup_platform(hass, config, add_devices, discovery_info=None): | |
add_devices([DSTBinarySensor()]) | |
class DSTBinarySensor(BinarySensorDevice): | |
"""representation of a DST binary sensor.""" | |
def __init__(self): | |
self._name = 'DST Binary Sensor' | |
self._state = None | |
self._sensor_type = 'dst' | |
@property | |
def device_class(self): | |
"""Return the class of this sensor.""" | |
return self._sensor_type | |
@property | |
def should_poll(self): | |
"""No polling needed for a demo binary sensor.""" | |
return False | |
@property | |
def name(self): | |
"""Return the name of the binary sensor.""" | |
return self._name | |
@property | |
def is_on(self): | |
"""Return true if the binary sensor is on.""" | |
return bool(time.localtime().tm_isdst) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment