Add Egg Minder support
parent
13b0d2afa3
commit
3ed69cec68
|
@ -0,0 +1,64 @@
|
|||
"""
|
||||
homeassistant.components.egg_minder.wink
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Support for Wink Egg Minder.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
at https://home-assistant.io/components/sensor.wink/
|
||||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||
|
||||
REQUIREMENTS = ['https://github.com/balloob/python-wink/archive/'
|
||||
'42fdcfa721b1bc583688e3592d8427f4c13ba6d9.zip'
|
||||
'#python-wink==0.2']
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
""" Sets up the Wink platform. """
|
||||
import pywink
|
||||
|
||||
if discovery_info is None:
|
||||
token = config.get('access_token')
|
||||
|
||||
if token is None:
|
||||
logging.getLogger(__name__).error(
|
||||
"Missing wink access_token. "
|
||||
"Get one at https://winkbearertoken.appspot.com/")
|
||||
return
|
||||
|
||||
pywink.set_bearer_token(token)
|
||||
|
||||
add_devices(WinkEggMinder(eggtray) for eggtray in pywink.get_eggtrays())
|
||||
|
||||
|
||||
class WinkEggMinder(Entity):
|
||||
""" Represents a Wink sensor. """
|
||||
|
||||
def __init__(self, wink):
|
||||
self.wink = wink
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
""" Returns the state. """
|
||||
return self.egg_count
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
""" Returns the id of this wink sensor """
|
||||
return "{}.{}".format(self.__class__, self.wink.deviceId())
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""" Returns the name of the sensor if any. """
|
||||
return self.wink.name()
|
||||
|
||||
@property
|
||||
def update(self):
|
||||
""" Update state of the Egg Minder. """
|
||||
self.wink.updateState()
|
||||
|
||||
@property
|
||||
def egg_count(self):
|
||||
""" The number of eggs """
|
||||
return self.wink.state()
|
|
@ -17,14 +17,14 @@ from homeassistant.const import (
|
|||
ATTR_SERVICE, ATTR_DISCOVERED, ATTR_FRIENDLY_NAME)
|
||||
|
||||
DOMAIN = "wink"
|
||||
DEPENDENCIES = []
|
||||
REQUIREMENTS = ['https://github.com/balloob/python-wink/archive/'
|
||||
'42fdcfa721b1bc583688e3592d8427f4c13ba6d9.zip'
|
||||
'#python-wink==0.2']
|
||||
'9eb39eaba0717922815e673ad1114c685839d890.zip'
|
||||
'#python-wink==0.1.1']
|
||||
|
||||
DISCOVER_LIGHTS = "wink.lights"
|
||||
DISCOVER_SWITCHES = "wink.switches"
|
||||
DISCOVER_SENSORS = "wink.sensors"
|
||||
DISCOVER_LOCKS = "wink.locks"
|
||||
|
||||
|
||||
def setup(hass, config):
|
||||
|
@ -42,7 +42,7 @@ def setup(hass, config):
|
|||
('light', pywink.get_bulbs, DISCOVER_LIGHTS),
|
||||
('switch', pywink.get_switches, DISCOVER_SWITCHES),
|
||||
('sensor', pywink.get_sensors, DISCOVER_SENSORS),
|
||||
('lock', pywink.get_locks, DISCOVER_LOCKS)):
|
||||
('sensor', pywink.get_eggtrays, DISCOVER_SENSORS)):
|
||||
|
||||
if func_exists():
|
||||
component = get_component(component_name)
|
||||
|
|
Loading…
Reference in New Issue