Fix PEP8 and PEP257 issues (#10108)
parent
186f8f6996
commit
560a4ef5eb
|
@ -3,23 +3,20 @@ Toon van Eneco Thermostat Support.
|
||||||
|
|
||||||
This provides a component for the rebranded Quby thermostat as provided by
|
This provides a component for the rebranded Quby thermostat as provided by
|
||||||
Eneco.
|
Eneco.
|
||||||
|
|
||||||
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/climate.toon/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from homeassistant.components.climate import (ClimateDevice,
|
|
||||||
ATTR_TEMPERATURE,
|
|
||||||
STATE_PERFORMANCE,
|
|
||||||
STATE_HEAT,
|
|
||||||
STATE_ECO,
|
|
||||||
STATE_COOL)
|
|
||||||
from homeassistant.const import TEMP_CELSIUS
|
|
||||||
|
|
||||||
import homeassistant.components.toon as toon_main
|
import homeassistant.components.toon as toon_main
|
||||||
|
from homeassistant.components.climate import (
|
||||||
|
ClimateDevice, ATTR_TEMPERATURE, STATE_PERFORMANCE, STATE_HEAT, STATE_ECO,
|
||||||
|
STATE_COOL)
|
||||||
|
from homeassistant.const import TEMP_CELSIUS
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Setup thermostat."""
|
"""Set up the Toon thermostat."""
|
||||||
# Add toon
|
add_devices([ThermostatDevice(hass)], True)
|
||||||
add_devices((ThermostatDevice(hass), ), True)
|
|
||||||
|
|
||||||
|
|
||||||
class ThermostatDevice(ClimateDevice):
|
class ThermostatDevice(ClimateDevice):
|
||||||
|
@ -31,25 +28,21 @@ class ThermostatDevice(ClimateDevice):
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
self.thermos = hass.data[toon_main.TOON_HANDLE]
|
self.thermos = hass.data[toon_main.TOON_HANDLE]
|
||||||
|
|
||||||
# set up internal state vars
|
|
||||||
self._state = None
|
self._state = None
|
||||||
self._temperature = None
|
self._temperature = None
|
||||||
self._setpoint = None
|
self._setpoint = None
|
||||||
self._operation_list = [STATE_PERFORMANCE,
|
self._operation_list = [
|
||||||
STATE_HEAT,
|
STATE_PERFORMANCE,
|
||||||
STATE_ECO,
|
STATE_HEAT,
|
||||||
STATE_COOL]
|
STATE_ECO,
|
||||||
|
STATE_COOL,
|
||||||
|
]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Name of this Thermostat."""
|
"""Name of this Thermostat."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""Polling is required."""
|
|
||||||
return True
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def temperature_unit(self):
|
def temperature_unit(self):
|
||||||
"""The unit of measurement used by the platform."""
|
"""The unit of measurement used by the platform."""
|
||||||
|
@ -83,10 +76,12 @@ class ThermostatDevice(ClimateDevice):
|
||||||
|
|
||||||
def set_operation_mode(self, operation_mode):
|
def set_operation_mode(self, operation_mode):
|
||||||
"""Set new operation mode as toonlib requires it."""
|
"""Set new operation mode as toonlib requires it."""
|
||||||
toonlib_values = {STATE_PERFORMANCE: 'Comfort',
|
toonlib_values = {
|
||||||
STATE_HEAT: 'Home',
|
STATE_PERFORMANCE: 'Comfort',
|
||||||
STATE_ECO: 'Away',
|
STATE_HEAT: 'Home',
|
||||||
STATE_COOL: 'Sleep'}
|
STATE_ECO: 'Away',
|
||||||
|
STATE_COOL: 'Sleep',
|
||||||
|
}
|
||||||
|
|
||||||
self.thermos.set_state(toonlib_values[operation_mode])
|
self.thermos.set_state(toonlib_values[operation_mode])
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
"""
|
"""
|
||||||
Toon van Eneco Utility Gages.
|
Component for the rebranded Quby thermostat as provided by Eneco.
|
||||||
|
|
||||||
This provides a component for the rebranded Quby thermostat as provided by
|
For more details about this platform, please refer to the documentation at
|
||||||
Eneco.
|
https://home-assistant.io/components/sensor.toon/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import datetime as datetime
|
import datetime as datetime
|
||||||
|
@ -12,46 +12,33 @@ import homeassistant.components.toon as toon_main
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
STATE_ATTR_DEVICE_TYPE = "device_type"
|
STATE_ATTR_DEVICE_TYPE = 'device_type'
|
||||||
STATE_ATTR_LAST_CONNECTED_CHANGE = "last_connected_change"
|
STATE_ATTR_LAST_CONNECTED_CHANGE = 'last_connected_change'
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Setup sensors."""
|
"""Set up the Toon sensors."""
|
||||||
_toon_main = hass.data[toon_main.TOON_HANDLE]
|
_toon_main = hass.data[toon_main.TOON_HANDLE]
|
||||||
|
|
||||||
sensor_items = []
|
sensor_items = []
|
||||||
sensor_items.extend([ToonSensor(hass,
|
sensor_items.extend([
|
||||||
'Power_current',
|
ToonSensor(hass, 'Power_current', 'power-plug', 'Watt'),
|
||||||
'power-plug',
|
ToonSensor(hass, 'Power_today', 'power-plug', 'kWh'),
|
||||||
'Watt'),
|
])
|
||||||
ToonSensor(hass,
|
|
||||||
'Power_today',
|
|
||||||
'power-plug',
|
|
||||||
'kWh')])
|
|
||||||
|
|
||||||
if _toon_main.gas:
|
if _toon_main.gas:
|
||||||
sensor_items.extend([ToonSensor(hass,
|
sensor_items.extend([
|
||||||
'Gas_current',
|
ToonSensor(hass, 'Gas_current', 'gas-cylinder', 'CM3'),
|
||||||
'gas-cylinder',
|
ToonSensor(hass, 'Gas_today', 'gas-cylinder', 'M3'),
|
||||||
'CM3'),
|
])
|
||||||
ToonSensor(hass,
|
|
||||||
'Gas_today',
|
|
||||||
'gas-cylinder',
|
|
||||||
'M3')])
|
|
||||||
|
|
||||||
for plug in _toon_main.toon.smartplugs:
|
for plug in _toon_main.toon.smartplugs:
|
||||||
sensor_items.extend([
|
sensor_items.extend([
|
||||||
FibaroSensor(hass,
|
FibaroSensor(hass, '{}_current_power'.format(plug.name),
|
||||||
'{}_current_power'.format(plug.name),
|
plug.name, 'power-socket-eu', 'Watt'),
|
||||||
plug.name,
|
FibaroSensor(hass, '{}_today_energy'.format(plug.name),
|
||||||
'power-socket-eu',
|
plug.name, 'power-socket-eu', 'kWh'),
|
||||||
'Watt'),
|
])
|
||||||
FibaroSensor(hass,
|
|
||||||
'{}_today_energy'.format(plug.name),
|
|
||||||
plug.name,
|
|
||||||
'power-socket-eu',
|
|
||||||
'kWh')])
|
|
||||||
|
|
||||||
if _toon_main.toon.solar.produced or _toon_main.solar:
|
if _toon_main.toon.solar.produced or _toon_main.solar:
|
||||||
sensor_items.extend([
|
sensor_items.extend([
|
||||||
|
@ -61,36 +48,30 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
SolarSensor(hass, 'Solar_average_produced', 'kWh'),
|
SolarSensor(hass, 'Solar_average_produced', 'kWh'),
|
||||||
SolarSensor(hass, 'Solar_meter_reading_low_produced', 'kWh'),
|
SolarSensor(hass, 'Solar_meter_reading_low_produced', 'kWh'),
|
||||||
SolarSensor(hass, 'Solar_meter_reading_produced', 'kWh'),
|
SolarSensor(hass, 'Solar_meter_reading_produced', 'kWh'),
|
||||||
SolarSensor(hass, 'Solar_daily_cost_produced', 'Euro')
|
SolarSensor(hass, 'Solar_daily_cost_produced', 'Euro'),
|
||||||
])
|
])
|
||||||
|
|
||||||
for smokedetector in _toon_main.toon.smokedetectors:
|
for smokedetector in _toon_main.toon.smokedetectors:
|
||||||
sensor_items.append(
|
sensor_items.append(
|
||||||
FibaroSmokeDetector(hass,
|
FibaroSmokeDetector(
|
||||||
'{}_smoke_detector'.format(smokedetector.name),
|
hass, '{}_smoke_detector'.format(smokedetector.name),
|
||||||
smokedetector.device_uuid,
|
smokedetector.device_uuid, 'alarm-bell', '%')
|
||||||
'alarm-bell',
|
)
|
||||||
'%'))
|
|
||||||
|
|
||||||
add_devices(sensor_items)
|
add_devices(sensor_items)
|
||||||
|
|
||||||
|
|
||||||
class ToonSensor(Entity):
|
class ToonSensor(Entity):
|
||||||
"""Representation of a sensor."""
|
"""Representation of a Toon sensor."""
|
||||||
|
|
||||||
def __init__(self, hass, name, icon, unit_of_measurement):
|
def __init__(self, hass, name, icon, unit_of_measurement):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the Toon sensor."""
|
||||||
self._name = name
|
self._name = name
|
||||||
self._state = None
|
self._state = None
|
||||||
self._icon = "mdi:" + icon
|
self._icon = 'mdi:{}'.format(icon)
|
||||||
self._unit_of_measurement = unit_of_measurement
|
self._unit_of_measurement = unit_of_measurement
|
||||||
self.thermos = hass.data[toon_main.TOON_HANDLE]
|
self.thermos = hass.data[toon_main.TOON_HANDLE]
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""Polling required."""
|
|
||||||
return True
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
|
@ -117,22 +98,17 @@ class ToonSensor(Entity):
|
||||||
|
|
||||||
|
|
||||||
class FibaroSensor(Entity):
|
class FibaroSensor(Entity):
|
||||||
"""Representation of a sensor."""
|
"""Representation of a Fibaro sensor."""
|
||||||
|
|
||||||
def __init__(self, hass, name, plug_name, icon, unit_of_measurement):
|
def __init__(self, hass, name, plug_name, icon, unit_of_measurement):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the Fibaro sensor."""
|
||||||
self._name = name
|
self._name = name
|
||||||
self._plug_name = plug_name
|
self._plug_name = plug_name
|
||||||
self._state = None
|
self._state = None
|
||||||
self._icon = "mdi:" + icon
|
self._icon = 'mdi:{}'.format(icon)
|
||||||
self._unit_of_measurement = unit_of_measurement
|
self._unit_of_measurement = unit_of_measurement
|
||||||
self.toon = hass.data[toon_main.TOON_HANDLE]
|
self.toon = hass.data[toon_main.TOON_HANDLE]
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""Polling required."""
|
|
||||||
return True
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
|
@ -160,21 +136,16 @@ class FibaroSensor(Entity):
|
||||||
|
|
||||||
|
|
||||||
class SolarSensor(Entity):
|
class SolarSensor(Entity):
|
||||||
"""Representation of a sensor."""
|
"""Representation of a Solar sensor."""
|
||||||
|
|
||||||
def __init__(self, hass, name, unit_of_measurement):
|
def __init__(self, hass, name, unit_of_measurement):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the Solar sensor."""
|
||||||
self._name = name
|
self._name = name
|
||||||
self._state = None
|
self._state = None
|
||||||
self._icon = "mdi:weather-sunny"
|
self._icon = 'mdi:weather-sunny'
|
||||||
self._unit_of_measurement = unit_of_measurement
|
self._unit_of_measurement = unit_of_measurement
|
||||||
self.toon = hass.data[toon_main.TOON_HANDLE]
|
self.toon = hass.data[toon_main.TOON_HANDLE]
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""Polling required."""
|
|
||||||
return True
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
|
@ -201,22 +172,17 @@ class SolarSensor(Entity):
|
||||||
|
|
||||||
|
|
||||||
class FibaroSmokeDetector(Entity):
|
class FibaroSmokeDetector(Entity):
|
||||||
"""Representation of a smoke detector."""
|
"""Representation of a Fibaro smoke detector."""
|
||||||
|
|
||||||
def __init__(self, hass, name, uid, icon, unit_of_measurement):
|
def __init__(self, hass, name, uid, icon, unit_of_measurement):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the Fibaro smoke sensor."""
|
||||||
self._name = name
|
self._name = name
|
||||||
self._uid = uid
|
self._uid = uid
|
||||||
self._state = None
|
self._state = None
|
||||||
self._icon = "mdi:" + icon
|
self._icon = 'mdi:{}'.format(icon)
|
||||||
self._unit_of_measurement = unit_of_measurement
|
self._unit_of_measurement = unit_of_measurement
|
||||||
self.toon = hass.data[toon_main.TOON_HANDLE]
|
self.toon = hass.data[toon_main.TOON_HANDLE]
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""Polling required."""
|
|
||||||
return True
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
|
@ -235,9 +201,9 @@ class FibaroSmokeDetector(Entity):
|
||||||
).strftime('%Y-%m-%d %H:%M:%S')
|
).strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
STATE_ATTR_DEVICE_TYPE: self.toon.get_data('device_type',
|
STATE_ATTR_DEVICE_TYPE:
|
||||||
self.name),
|
self.toon.get_data('device_type', self.name),
|
||||||
STATE_ATTR_LAST_CONNECTED_CHANGE: value
|
STATE_ATTR_LAST_CONNECTED_CHANGE: value,
|
||||||
}
|
}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
"""
|
"""
|
||||||
Support for Eneco Slimmer stekkers (Smart Plugs).
|
Support for Eneco Slimmer stekkers (Smart Plugs).
|
||||||
|
|
||||||
This provides controlls for the z-wave smart plugs Toon can control.
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/switch.toon/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.switch import SwitchDevice
|
|
||||||
import homeassistant.components.toon as toon_main
|
import homeassistant.components.toon as toon_main
|
||||||
|
from homeassistant.components.switch import SwitchDevice
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||||
"""Setup discovered Smart Plugs."""
|
"""Set up the discovered Toon Smart Plugs."""
|
||||||
_toon_main = hass.data[toon_main.TOON_HANDLE]
|
_toon_main = hass.data[toon_main.TOON_HANDLE]
|
||||||
switch_items = []
|
switch_items = []
|
||||||
for plug in _toon_main.toon.smartplugs:
|
for plug in _toon_main.toon.smartplugs:
|
||||||
|
@ -22,18 +23,13 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||||
|
|
||||||
|
|
||||||
class EnecoSmartPlug(SwitchDevice):
|
class EnecoSmartPlug(SwitchDevice):
|
||||||
"""Representation of a Smart Plug."""
|
"""Representation of a Toon Smart Plug."""
|
||||||
|
|
||||||
def __init__(self, hass, plug):
|
def __init__(self, hass, plug):
|
||||||
"""Initialize the Smart Plug."""
|
"""Initialize the Smart Plug."""
|
||||||
self.smartplug = plug
|
self.smartplug = plug
|
||||||
self.toon_data_store = hass.data[toon_main.TOON_HANDLE]
|
self.toon_data_store = hass.data[toon_main.TOON_HANDLE]
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""No polling needed with subscriptions."""
|
|
||||||
return True
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return the ID of this switch."""
|
"""Return the ID of this switch."""
|
||||||
|
|
|
@ -1,32 +1,33 @@
|
||||||
"""
|
"""
|
||||||
Toon van Eneco Support.
|
Toon van Eneco Support.
|
||||||
|
|
||||||
This provides a component for the rebranded Quby thermostat as provided by
|
For more details about this component, please refer to the documentation at
|
||||||
Eneco.
|
https://home-assistant.io/components/toon/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
# Import the device class from the component that you want to support
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.const import (CONF_USERNAME, CONF_PASSWORD)
|
from homeassistant.const import (CONF_USERNAME, CONF_PASSWORD)
|
||||||
from homeassistant.helpers.discovery import load_platform
|
from homeassistant.helpers.discovery import load_platform
|
||||||
import homeassistant.helpers.config_validation as cv
|
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
|
|
||||||
# Home Assistant depends on 3rd party packages for API specific code.
|
|
||||||
REQUIREMENTS = ['toonlib==1.0.2']
|
REQUIREMENTS = ['toonlib==1.0.2']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
CONF_GAS = 'gas'
|
||||||
|
CONF_SOLAR = 'solar'
|
||||||
|
|
||||||
|
DEFAULT_GAS = True
|
||||||
|
DEFAULT_SOLAR = False
|
||||||
|
DOMAIN = 'toon'
|
||||||
|
|
||||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=5)
|
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=5)
|
||||||
|
|
||||||
DOMAIN = 'toon'
|
|
||||||
TOON_HANDLE = 'toon_handle'
|
TOON_HANDLE = 'toon_handle'
|
||||||
CONF_GAS = 'gas'
|
|
||||||
DEFAULT_GAS = True
|
|
||||||
CONF_SOLAR = 'solar'
|
|
||||||
DEFAULT_SOLAR = False
|
|
||||||
|
|
||||||
# Validation of the user's configuration
|
# Validation of the user's configuration
|
||||||
CONFIG_SCHEMA = vol.Schema({
|
CONFIG_SCHEMA = vol.Schema({
|
||||||
|
@ -40,37 +41,32 @@ CONFIG_SCHEMA = vol.Schema({
|
||||||
|
|
||||||
|
|
||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
"""Setup toon."""
|
"""Set up the Toon component."""
|
||||||
from toonlib import InvalidCredentials
|
from toonlib import InvalidCredentials
|
||||||
gas = config['toon']['gas']
|
gas = config[DOMAIN][CONF_GAS]
|
||||||
solar = config['toon']['solar']
|
solar = config[DOMAIN][CONF_SOLAR]
|
||||||
|
username = config[DOMAIN][CONF_USERNAME]
|
||||||
|
password = config[DOMAIN][CONF_PASSWORD]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
hass.data[TOON_HANDLE] = ToonDataStore(config['toon']['username'],
|
hass.data[TOON_HANDLE] = ToonDataStore(username, password, gas, solar)
|
||||||
config['toon']['password'],
|
|
||||||
gas,
|
|
||||||
solar)
|
|
||||||
except InvalidCredentials:
|
except InvalidCredentials:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Load all platforms
|
|
||||||
for platform in ('climate', 'sensor', 'switch'):
|
for platform in ('climate', 'sensor', 'switch'):
|
||||||
load_platform(hass, platform, DOMAIN, {}, config)
|
load_platform(hass, platform, DOMAIN, {}, config)
|
||||||
|
|
||||||
# Initialization successfull
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class ToonDataStore:
|
class ToonDataStore(object):
|
||||||
"""An object to store the toon data."""
|
"""An object to store the Toon data."""
|
||||||
|
|
||||||
def __init__(self, username, password, gas=DEFAULT_GAS,
|
def __init__(self, username, password, gas=DEFAULT_GAS,
|
||||||
solar=DEFAULT_SOLAR):
|
solar=DEFAULT_SOLAR):
|
||||||
"""Initialize toon."""
|
"""Initialize Toon."""
|
||||||
from toonlib import Toon
|
from toonlib import Toon
|
||||||
|
|
||||||
# Creating the class
|
|
||||||
|
|
||||||
toon = Toon(username, password)
|
toon = Toon(username, password)
|
||||||
|
|
||||||
self.toon = toon
|
self.toon = toon
|
||||||
|
@ -83,7 +79,7 @@ class ToonDataStore:
|
||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update toon data."""
|
"""Update Toon data."""
|
||||||
self.last_update = datetime.now()
|
self.last_update = datetime.now()
|
||||||
|
|
||||||
self.data['power_current'] = self.toon.power.value
|
self.data['power_current'] = self.toon.power.value
|
||||||
|
@ -104,11 +100,12 @@ class ToonDataStore:
|
||||||
1000, 2)
|
1000, 2)
|
||||||
|
|
||||||
for plug in self.toon.smartplugs:
|
for plug in self.toon.smartplugs:
|
||||||
self.data[plug.name] = {'current_power': plug.current_usage,
|
self.data[plug.name] = {
|
||||||
'today_energy': round(
|
'current_power': plug.current_usage,
|
||||||
float(plug.daily_usage) / 1000, 2),
|
'today_energy': round(float(plug.daily_usage) / 1000, 2),
|
||||||
'current_state': plug.current_state,
|
'current_state': plug.current_state,
|
||||||
'is_connected': plug.is_connected}
|
'is_connected': plug.is_connected,
|
||||||
|
}
|
||||||
|
|
||||||
self.data['solar_maximum'] = self.toon.solar.maximum
|
self.data['solar_maximum'] = self.toon.solar.maximum
|
||||||
self.data['solar_produced'] = self.toon.solar.produced
|
self.data['solar_produced'] = self.toon.solar.produced
|
||||||
|
@ -123,11 +120,12 @@ class ToonDataStore:
|
||||||
|
|
||||||
for detector in self.toon.smokedetectors:
|
for detector in self.toon.smokedetectors:
|
||||||
value = '{}_smoke_detector'.format(detector.name)
|
value = '{}_smoke_detector'.format(detector.name)
|
||||||
self.data[value] = {'smoke_detector': detector.battery_level,
|
self.data[value] = {
|
||||||
'device_type': detector.device_type,
|
'smoke_detector': detector.battery_level,
|
||||||
'is_connected': detector.is_connected,
|
'device_type': detector.device_type,
|
||||||
'last_connected_change':
|
'is_connected': detector.is_connected,
|
||||||
detector.last_connected_change}
|
'last_connected_change': detector.last_connected_change,
|
||||||
|
}
|
||||||
|
|
||||||
def set_state(self, state):
|
def set_state(self, state):
|
||||||
"""Push a new state to the Toon unit."""
|
"""Push a new state to the Toon unit."""
|
||||||
|
|
Loading…
Reference in New Issue