hygrometers and disabling of components
parent
e37869616b
commit
4707b122cc
|
@ -23,20 +23,30 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
sensors = []
|
||||
|
||||
sensors.extend([
|
||||
VerisureClimateDevice(value)
|
||||
VerisureThermometer(value)
|
||||
for value in verisure.get_climate_status().values()
|
||||
if verisure.SHOW_THERMOMETERS and
|
||||
hasattr(value, 'temperature') and value.temperature
|
||||
])
|
||||
|
||||
sensors.extend([
|
||||
VerisureAlarmDevice(value)
|
||||
VerisureHygrometer(value)
|
||||
for value in verisure.get_climate_status().values()
|
||||
if verisure.SHOW_HYGROMETERS and
|
||||
hasattr(value, 'humidity') and value.humidity
|
||||
])
|
||||
|
||||
sensors.extend([
|
||||
VerisureAlarm(value)
|
||||
for value in verisure.get_alarm_status().values()
|
||||
if verisure.SHOW_ALARM
|
||||
])
|
||||
|
||||
add_devices(sensors)
|
||||
|
||||
|
||||
class VerisureClimateDevice(Entity):
|
||||
""" represents a Verisure climate sensor within home assistant. """
|
||||
class VerisureThermometer(Entity):
|
||||
""" represents a Verisure thermometer within home assistant. """
|
||||
|
||||
def __init__(self, climate_status):
|
||||
self._id = climate_status.id
|
||||
|
@ -45,7 +55,9 @@ class VerisureClimateDevice(Entity):
|
|||
@property
|
||||
def name(self):
|
||||
""" Returns the name of the device. """
|
||||
return verisure.STATUS[self._device][self._id].location
|
||||
return '{} {}'.format(
|
||||
verisure.STATUS[self._device][self._id].location,
|
||||
"Temperature")
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
|
@ -59,10 +71,41 @@ class VerisureClimateDevice(Entity):
|
|||
return TEMP_CELCIUS # can verisure report in fahrenheit?
|
||||
|
||||
def update(self):
|
||||
''' update sensor '''
|
||||
verisure.update()
|
||||
|
||||
|
||||
class VerisureAlarmDevice(Entity):
|
||||
class VerisureHygrometer(Entity):
|
||||
""" represents a Verisure hygrometer within home assistant. """
|
||||
|
||||
def __init__(self, climate_status):
|
||||
self._id = climate_status.id
|
||||
self._device = verisure.MY_PAGES.DEVICE_CLIMATE
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""" Returns the name of the device. """
|
||||
return '{} {}'.format(
|
||||
verisure.STATUS[self._device][self._id].location,
|
||||
"Humidity")
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
""" Returns the state of the device. """
|
||||
# remove % character
|
||||
return verisure.STATUS[self._device][self._id].humidity[:-1]
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
""" Unit of measurement of this entity """
|
||||
return "%"
|
||||
|
||||
def update(self):
|
||||
''' update sensor '''
|
||||
verisure.update()
|
||||
|
||||
|
||||
class VerisureAlarm(Entity):
|
||||
""" represents a Verisure alarm status within home assistant. """
|
||||
|
||||
def __init__(self, alarm_status):
|
||||
|
@ -80,4 +123,5 @@ class VerisureAlarmDevice(Entity):
|
|||
return verisure.STATUS[self._device][self._id].label
|
||||
|
||||
def update(self):
|
||||
''' update sensor '''
|
||||
verisure.update()
|
||||
|
|
|
@ -2,14 +2,6 @@
|
|||
homeassistant.components.switch.verisure
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Support for Verisure Smartplugs
|
||||
|
||||
Configuration:
|
||||
|
||||
switch:
|
||||
platform: verisure
|
||||
|
||||
Variables:
|
||||
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
@ -31,6 +23,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
switches.extend([
|
||||
VerisureSmartplug(value)
|
||||
for value in verisure.get_smartplug_status().values()
|
||||
if verisure.SHOW_SMARTPLUGS
|
||||
])
|
||||
|
||||
add_devices(switches)
|
||||
|
|
|
@ -1,6 +1,45 @@
|
|||
"""
|
||||
components.verisure
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Provides support for verisure components
|
||||
|
||||
Configuration:
|
||||
|
||||
verisure:
|
||||
username: user@example.com
|
||||
password: password
|
||||
alarm: 1
|
||||
hygrometers: 0
|
||||
smartplugs: 1
|
||||
thermometers: 0
|
||||
|
||||
|
||||
Variables:
|
||||
|
||||
username
|
||||
*Required
|
||||
Username to verisure mypages
|
||||
|
||||
password
|
||||
*Required
|
||||
Password to verisure mypages
|
||||
|
||||
alarm
|
||||
*Opional
|
||||
Set to 1 to show alarm, 0 to disable. Default 1
|
||||
|
||||
hygrometers
|
||||
*Opional
|
||||
Set to 1 to show hygrometers, 0 to disable. Default 1
|
||||
|
||||
smartplugs
|
||||
*Opional
|
||||
Set to 1 to show smartplugs, 0 to disable. Default 1
|
||||
|
||||
thermometers
|
||||
*Opional
|
||||
Set to 1 to show thermometers, 0 to disable. Default 1
|
||||
"""
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
|
@ -33,6 +72,11 @@ STATUS = {}
|
|||
VERISURE_LOGIN_ERROR = None
|
||||
VERISURE_ERROR = None
|
||||
|
||||
SHOW_THERMOMETERS = True
|
||||
SHOW_HYGROMETERS = True
|
||||
SHOW_ALARM = True
|
||||
SHOW_SMARTPLUGS = True
|
||||
|
||||
# if wrong password was given don't try again
|
||||
WRONG_PASSWORD_GIVEN = False
|
||||
|
||||
|
@ -53,6 +97,12 @@ def setup(hass, config):
|
|||
STATUS[MyPages.DEVICE_CLIMATE] = {}
|
||||
STATUS[MyPages.DEVICE_SMARTPLUG] = {}
|
||||
|
||||
global SHOW_THERMOMETERS, SHOW_HYGROMETERS, SHOW_ALARM, SHOW_SMARTPLUGS
|
||||
SHOW_THERMOMETERS = int(config[DOMAIN].get('thermometers', '1'))
|
||||
SHOW_HYGROMETERS = int(config[DOMAIN].get('hygrometers', '1'))
|
||||
SHOW_ALARM = int(config[DOMAIN].get('alarm', '1'))
|
||||
SHOW_SMARTPLUGS = int(config[DOMAIN].get('smartplugs', '1'))
|
||||
|
||||
global MY_PAGES
|
||||
MY_PAGES = MyPages(
|
||||
config[DOMAIN][CONF_USERNAME],
|
||||
|
@ -73,6 +123,7 @@ def setup(hass, config):
|
|||
for comp_name, discovery in ((('sensor', DISCOVER_SENSORS),
|
||||
('switch', DISCOVER_SWITCHES))):
|
||||
component = get_component(comp_name)
|
||||
_LOGGER.info(config[DOMAIN])
|
||||
bootstrap.setup_component(hass, component.DOMAIN, config)
|
||||
|
||||
hass.bus.fire(EVENT_PLATFORM_DISCOVERED,
|
||||
|
|
Loading…
Reference in New Issue