Black
This commit is contained in:
1 parent
da05dfe708
commit
4de97abc3a
2676 files changed
+163166
-140084
No files matched your search
@@ -13,33 +13,42 @@ from homeassistant.const import CONF_HOST, CONF_PORT, CONF_SCAN_INTERVAL
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DEFAULT_PORT = 62910
|
||||
DOMAIN = 'maxcube'
|
||||
DOMAIN = "maxcube"
|
||||
|
||||
DATA_KEY = 'maxcube'
|
||||
DATA_KEY = "maxcube"
|
||||
|
||||
NOTIFICATION_ID = 'maxcube_notification'
|
||||
NOTIFICATION_TITLE = 'Max!Cube gateway setup'
|
||||
NOTIFICATION_ID = "maxcube_notification"
|
||||
NOTIFICATION_TITLE = "Max!Cube gateway setup"
|
||||
|
||||
CONF_GATEWAYS = 'gateways'
|
||||
CONF_GATEWAYS = "gateways"
|
||||
|
||||
CONFIG_GATEWAY = vol.Schema({
|
||||
vol.Required(CONF_HOST): cv.string,
|
||||
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
|
||||
vol.Optional(CONF_SCAN_INTERVAL, default=300): cv.time_period,
|
||||
})
|
||||
CONFIG_GATEWAY = vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_HOST): cv.string,
|
||||
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
|
||||
vol.Optional(CONF_SCAN_INTERVAL, default=300): cv.time_period,
|
||||
}
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema({
|
||||
DOMAIN: vol.Schema({
|
||||
vol.Required(CONF_GATEWAYS, default={}):
|
||||
vol.All(cv.ensure_list, [CONFIG_GATEWAY]),
|
||||
}),
|
||||
}, extra=vol.ALLOW_EXTRA)
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
DOMAIN: vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_GATEWAYS, default={}): vol.All(
|
||||
cv.ensure_list, [CONFIG_GATEWAY]
|
||||
)
|
||||
}
|
||||
)
|
||||
},
|
||||
extra=vol.ALLOW_EXTRA,
|
||||
)
|
||||
|
||||
|
||||
def setup(hass, config):
|
||||
"""Establish connection to MAX! Cube."""
|
||||
from maxcube.connection import MaxCubeConnection
|
||||
from maxcube.cube import MaxCube
|
||||
|
||||
if DATA_KEY not in hass.data:
|
||||
hass.data[DATA_KEY] = {}
|
||||
|
||||
@@ -56,18 +65,19 @@ def setup(hass, config):
|
||||
except timeout as ex:
|
||||
_LOGGER.error("Unable to connect to Max!Cube gateway: %s", str(ex))
|
||||
hass.components.persistent_notification.create(
|
||||
'Error: {}<br />'
|
||||
'You will need to restart Home Assistant after fixing.'
|
||||
''.format(ex),
|
||||
"Error: {}<br />"
|
||||
"You will need to restart Home Assistant after fixing."
|
||||
"".format(ex),
|
||||
title=NOTIFICATION_TITLE,
|
||||
notification_id=NOTIFICATION_ID)
|
||||
notification_id=NOTIFICATION_ID,
|
||||
)
|
||||
connection_failed += 1
|
||||
|
||||
if connection_failed >= len(gateways):
|
||||
return False
|
||||
|
||||
load_platform(hass, 'climate', DOMAIN, {}, config)
|
||||
load_platform(hass, 'binary_sensor', DOMAIN, {}, config)
|
||||
load_platform(hass, "climate", DOMAIN, {}, config)
|
||||
load_platform(hass, "binary_sensor", DOMAIN, {}, config)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@@ -14,13 +14,11 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
for handler in hass.data[DATA_KEY].values():
|
||||
cube = handler.cube
|
||||
for device in cube.devices:
|
||||
name = "{} {}".format(
|
||||
cube.room_by_id(device.room_id).name, device.name)
|
||||
name = "{} {}".format(cube.room_by_id(device.room_id).name, device.name)
|
||||
|
||||
# Only add Window Shutters
|
||||
if cube.is_windowshutter(device):
|
||||
devices.append(
|
||||
MaxCubeShutter(handler, name, device.rf_address))
|
||||
devices.append(MaxCubeShutter(handler, name, device.rf_address))
|
||||
|
||||
if devices:
|
||||
add_entities(devices)
|
||||
@@ -32,7 +30,7 @@ class MaxCubeShutter(BinarySensorDevice):
|
||||
def __init__(self, handler, name, rf_address):
|
||||
"""Initialize MAX! Cube BinarySensorDevice."""
|
||||
self._name = name
|
||||
self._sensor_type = 'window'
|
||||
self._sensor_type = "window"
|
||||
self._rf_address = rf_address
|
||||
self._cubehandle = handler
|
||||
self._state = None
|
||||
|
||||
@@ -2,24 +2,28 @@
|
||||
import logging
|
||||
import socket
|
||||
|
||||
from maxcube.device import \
|
||||
MAX_DEVICE_MODE_AUTOMATIC, \
|
||||
MAX_DEVICE_MODE_MANUAL, \
|
||||
MAX_DEVICE_MODE_VACATION, \
|
||||
MAX_DEVICE_MODE_BOOST
|
||||
from maxcube.device import (
|
||||
MAX_DEVICE_MODE_AUTOMATIC,
|
||||
MAX_DEVICE_MODE_MANUAL,
|
||||
MAX_DEVICE_MODE_VACATION,
|
||||
MAX_DEVICE_MODE_BOOST,
|
||||
)
|
||||
|
||||
from homeassistant.components.climate import ClimateDevice
|
||||
from homeassistant.components.climate.const import (
|
||||
HVAC_MODE_AUTO, SUPPORT_TARGET_TEMPERATURE, SUPPORT_PRESET_MODE)
|
||||
HVAC_MODE_AUTO,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
SUPPORT_PRESET_MODE,
|
||||
)
|
||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
||||
|
||||
from . import DATA_KEY
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PRESET_MANUAL = 'manual'
|
||||
PRESET_BOOST = 'boost'
|
||||
PRESET_VACATION = 'vacation'
|
||||
PRESET_MANUAL = "manual"
|
||||
PRESET_BOOST = "boost"
|
||||
PRESET_VACATION = "vacation"
|
||||
|
||||
SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE
|
||||
|
||||
@@ -30,12 +34,10 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
for handler in hass.data[DATA_KEY].values():
|
||||
cube = handler.cube
|
||||
for device in cube.devices:
|
||||
name = '{} {}'.format(
|
||||
cube.room_by_id(device.room_id).name, device.name)
|
||||
name = "{} {}".format(cube.room_by_id(device.room_id).name, device.name)
|
||||
|
||||
if cube.is_thermostat(device) or cube.is_wallthermostat(device):
|
||||
devices.append(
|
||||
MaxCubeClimate(handler, name, device.rf_address))
|
||||
devices.append(MaxCubeClimate(handler, name, device.rf_address))
|
||||
|
||||
if devices:
|
||||
add_entities(devices)
|
||||
@@ -133,11 +135,7 @@ class MaxCubeClimate(ClimateDevice):
|
||||
@property
|
||||
def preset_modes(self):
|
||||
"""Return available preset modes."""
|
||||
return [
|
||||
PRESET_BOOST,
|
||||
PRESET_MANUAL,
|
||||
PRESET_VACATION,
|
||||
]
|
||||
return [PRESET_BOOST, PRESET_MANUAL, PRESET_VACATION]
|
||||
|
||||
def set_preset_mode(self, preset_mode):
|
||||
"""Set new operation mode."""
|
||||
|
||||
Reference in new issue
Block a user