Minor updates (#16106)
This commit is contained in:
parent
1ce51bfbd6
commit
0e1fb74e1b
20 changed files with 172 additions and 180 deletions
|
@ -1,32 +1,31 @@
|
|||
"""
|
||||
Support for HomematicIP alarm control panel.
|
||||
Support for HomematicIP Cloud alarm control panel.
|
||||
|
||||
For more details about this component, please refer to the documentation at
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/alarm_control_panel.homematicip_cloud/
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from homeassistant.components.alarm_control_panel import AlarmControlPanel
|
||||
from homeassistant.components.homematicip_cloud import (
|
||||
HMIPC_HAPID, HomematicipGenericDevice)
|
||||
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
|
||||
from homeassistant.const import (
|
||||
STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED,
|
||||
STATE_ALARM_TRIGGERED)
|
||||
from homeassistant.components.alarm_control_panel import AlarmControlPanel
|
||||
from homeassistant.components.homematicip_cloud import (
|
||||
HomematicipGenericDevice, DOMAIN as HMIPC_DOMAIN,
|
||||
HMIPC_HAPID)
|
||||
|
||||
|
||||
DEPENDENCIES = ['homematicip_cloud']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DEPENDENCIES = ['homematicip_cloud']
|
||||
|
||||
HMIP_ZONE_AWAY = 'EXTERNAL'
|
||||
HMIP_ZONE_HOME = 'INTERNAL'
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_devices,
|
||||
discovery_info=None):
|
||||
"""Set up the HomematicIP alarm control devices."""
|
||||
async def async_setup_platform(
|
||||
hass, config, async_add_devices, discovery_info=None):
|
||||
"""Set up the HomematicIP Cloud alarm control devices."""
|
||||
pass
|
||||
|
||||
|
||||
|
@ -45,7 +44,7 @@ async def async_setup_entry(hass, config_entry, async_add_devices):
|
|||
|
||||
|
||||
class HomematicipSecurityZone(HomematicipGenericDevice, AlarmControlPanel):
|
||||
"""Representation of an HomematicIP security zone group."""
|
||||
"""Representation of an HomematicIP Cloud security zone group."""
|
||||
|
||||
def __init__(self, home, device):
|
||||
"""Initialize the security zone group."""
|
||||
|
|
|
@ -5,27 +5,28 @@ For more details about this platform, please refer to the documentation at
|
|||
https://home-assistant.io/components/binary_sensor.homematic/
|
||||
"""
|
||||
import logging
|
||||
from homeassistant.const import STATE_UNKNOWN
|
||||
|
||||
from homeassistant.components.binary_sensor import BinarySensorDevice
|
||||
from homeassistant.components.homematic import HMDevice, ATTR_DISCOVER_DEVICES
|
||||
from homeassistant.components.homematic import ATTR_DISCOVER_DEVICES, HMDevice
|
||||
from homeassistant.const import STATE_UNKNOWN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DEPENDENCIES = ['homematic']
|
||||
|
||||
SENSOR_TYPES_CLASS = {
|
||||
'Remote': None,
|
||||
'ShutterContact': 'opening',
|
||||
'MaxShutterContact': 'opening',
|
||||
'IPShutterContact': 'opening',
|
||||
'Smoke': 'smoke',
|
||||
'SmokeV2': 'smoke',
|
||||
'MaxShutterContact': 'opening',
|
||||
'Motion': 'motion',
|
||||
'MotionV2': 'motion',
|
||||
'RemoteMotion': None,
|
||||
'WeatherSensor': None,
|
||||
'TiltSensor': None,
|
||||
'PresenceIP': 'motion',
|
||||
'Remote': None,
|
||||
'RemoteMotion': None,
|
||||
'ShutterContact': 'opening',
|
||||
'Smoke': 'smoke',
|
||||
'SmokeV2': 'smoke',
|
||||
'TiltSensor': None,
|
||||
'WeatherSensor': None,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
"""
|
||||
Support for HomematicIP binary sensor.
|
||||
Support for HomematicIP Cloud binary sensor.
|
||||
|
||||
For more details about this component, please refer to the documentation at
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/binary_sensor.homematicip_cloud/
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from homeassistant.components.binary_sensor import BinarySensorDevice
|
||||
from homeassistant.components.homematicip_cloud import (
|
||||
HomematicipGenericDevice, DOMAIN as HMIPC_DOMAIN,
|
||||
HMIPC_HAPID)
|
||||
HMIPC_HAPID, HomematicipGenericDevice)
|
||||
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
|
||||
|
||||
DEPENDENCIES = ['homematicip_cloud']
|
||||
|
||||
|
@ -19,14 +18,14 @@ _LOGGER = logging.getLogger(__name__)
|
|||
STATE_SMOKE_OFF = 'IDLE_OFF'
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_devices,
|
||||
discovery_info=None):
|
||||
"""Set up the binary sensor devices."""
|
||||
async def async_setup_platform(
|
||||
hass, config, async_add_devices, discovery_info=None):
|
||||
"""Set up the HomematicIP Cloud binary sensor devices."""
|
||||
pass
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_devices):
|
||||
"""Set up the HomematicIP binary sensor from a config entry."""
|
||||
"""Set up the HomematicIP Cloud binary sensor from a config entry."""
|
||||
from homematicip.aio.device import (
|
||||
AsyncShutterContact, AsyncMotionDetectorIndoor, AsyncSmokeDetector)
|
||||
|
||||
|
@ -45,7 +44,7 @@ async def async_setup_entry(hass, config_entry, async_add_devices):
|
|||
|
||||
|
||||
class HomematicipShutterContact(HomematicipGenericDevice, BinarySensorDevice):
|
||||
"""HomematicIP shutter contact."""
|
||||
"""Representation of a HomematicIP Cloud shutter contact."""
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
|
@ -65,7 +64,7 @@ class HomematicipShutterContact(HomematicipGenericDevice, BinarySensorDevice):
|
|||
|
||||
|
||||
class HomematicipMotionDetector(HomematicipGenericDevice, BinarySensorDevice):
|
||||
"""HomematicIP motion detector."""
|
||||
"""Representation of a HomematicIP Cloud motion detector."""
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
|
@ -81,7 +80,7 @@ class HomematicipMotionDetector(HomematicipGenericDevice, BinarySensorDevice):
|
|||
|
||||
|
||||
class HomematicipSmokeDetector(HomematicipGenericDevice, BinarySensorDevice):
|
||||
"""HomematicIP smoke detector."""
|
||||
"""Representation of a HomematicIP Cloud smoke detector."""
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
|
|
|
@ -5,12 +5,13 @@ For more details about this platform, please refer to the documentation at
|
|||
https://home-assistant.io/components/climate.homematic/
|
||||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.components.climate import (
|
||||
ClimateDevice, STATE_AUTO, SUPPORT_TARGET_TEMPERATURE,
|
||||
SUPPORT_OPERATION_MODE)
|
||||
STATE_AUTO, SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE,
|
||||
ClimateDevice)
|
||||
from homeassistant.components.homematic import (
|
||||
HMDevice, ATTR_DISCOVER_DEVICES, HM_ATTRIBUTE_SUPPORT)
|
||||
from homeassistant.const import TEMP_CELSIUS, STATE_UNKNOWN, ATTR_TEMPERATURE
|
||||
ATTR_DISCOVER_DEVICES, HM_ATTRIBUTE_SUPPORT, HMDevice)
|
||||
from homeassistant.const import ATTR_TEMPERATURE, STATE_UNKNOWN, TEMP_CELSIUS
|
||||
|
||||
DEPENDENCIES = ['homematic']
|
||||
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
"""
|
||||
Support for HomematicIP climate.
|
||||
Support for HomematicIP Cloud climate devices.
|
||||
|
||||
For more details about this component, please refer to the documentation at
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/climate.homematicip_cloud/
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from homeassistant.components.climate import (
|
||||
ClimateDevice, SUPPORT_TARGET_TEMPERATURE, ATTR_TEMPERATURE,
|
||||
STATE_AUTO, STATE_MANUAL)
|
||||
from homeassistant.const import TEMP_CELSIUS
|
||||
ATTR_TEMPERATURE, STATE_AUTO, STATE_MANUAL, SUPPORT_TARGET_TEMPERATURE,
|
||||
ClimateDevice)
|
||||
from homeassistant.components.homematicip_cloud import (
|
||||
HomematicipGenericDevice, DOMAIN as HMIPC_DOMAIN,
|
||||
HMIPC_HAPID)
|
||||
HMIPC_HAPID, HomematicipGenericDevice)
|
||||
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
|
||||
from homeassistant.const import TEMP_CELSIUS
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -27,9 +26,9 @@ HA_STATE_TO_HMIP = {
|
|||
HMIP_STATE_TO_HA = {value: key for key, value in HA_STATE_TO_HMIP.items()}
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_devices,
|
||||
discovery_info=None):
|
||||
"""Set up the HomematicIP climate devices."""
|
||||
async def async_setup_platform(
|
||||
hass, config, async_add_devices, discovery_info=None):
|
||||
"""Set up the HomematicIP Cloud climate devices."""
|
||||
pass
|
||||
|
||||
|
||||
|
@ -48,7 +47,7 @@ async def async_setup_entry(hass, config_entry, async_add_devices):
|
|||
|
||||
|
||||
class HomematicipHeatingGroup(HomematicipGenericDevice, ClimateDevice):
|
||||
"""Representation of a MomematicIP heating group."""
|
||||
"""Representation of a HomematicIP heating group."""
|
||||
|
||||
def __init__(self, home, device):
|
||||
"""Initialize heating group."""
|
||||
|
|
|
@ -6,9 +6,9 @@ https://home-assistant.io/components/cover.homematic/
|
|||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.components.cover import CoverDevice, ATTR_POSITION,\
|
||||
ATTR_TILT_POSITION
|
||||
from homeassistant.components.homematic import HMDevice, ATTR_DISCOVER_DEVICES
|
||||
from homeassistant.components.cover import (
|
||||
ATTR_POSITION, ATTR_TILT_POSITION, CoverDevice)
|
||||
from homeassistant.components.homematic import ATTR_DISCOVER_DEVICES, HMDevice
|
||||
from homeassistant.const import STATE_UNKNOWN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
|
|
@ -1,24 +1,23 @@
|
|||
"""
|
||||
Support for HomematicIP components.
|
||||
Support for HomematicIP Cloud components.
|
||||
|
||||
For more details about this component, please refer to the documentation at
|
||||
https://home-assistant.io/components/homematicip_cloud/
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.const import CONF_NAME
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
from .const import (
|
||||
DOMAIN, HMIPC_HAPID, HMIPC_AUTHTOKEN, HMIPC_NAME,
|
||||
CONF_ACCESSPOINT, CONF_AUTHTOKEN, CONF_NAME)
|
||||
# Loading the config flow file will register the flow
|
||||
from .config_flow import configured_haps
|
||||
from .hap import HomematicipHAP, HomematicipAuth # noqa: F401
|
||||
from .const import (
|
||||
CONF_ACCESSPOINT, CONF_AUTHTOKEN, DOMAIN, HMIPC_AUTHTOKEN, HMIPC_HAPID,
|
||||
HMIPC_NAME)
|
||||
from .device import HomematicipGenericDevice # noqa: F401
|
||||
from .hap import HomematicipAuth, HomematicipHAP # noqa: F401
|
||||
|
||||
REQUIREMENTS = ['homematicip==0.9.8']
|
||||
|
||||
|
@ -34,7 +33,7 @@ CONFIG_SCHEMA = vol.Schema({
|
|||
|
||||
|
||||
async def async_setup(hass, config):
|
||||
"""Set up the HomematicIP component."""
|
||||
"""Set up the HomematicIP Cloud component."""
|
||||
hass.data[DOMAIN] = {}
|
||||
|
||||
accesspoints = config.get(DOMAIN, [])
|
||||
|
@ -54,7 +53,7 @@ async def async_setup(hass, config):
|
|||
|
||||
|
||||
async def async_setup_entry(hass, entry):
|
||||
"""Set up an accsspoint from a config entry."""
|
||||
"""Set up an access point from a config entry."""
|
||||
hap = HomematicipHAP(hass, entry)
|
||||
hapid = entry.data[HMIPC_HAPID].replace('-', '').upper()
|
||||
hass.data[DOMAIN][hapid] = hap
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
"""Config flow to configure HomematicIP Cloud."""
|
||||
"""Config flow to configure the HomematicIP Cloud component."""
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant.core import callback
|
||||
|
||||
from .const import (
|
||||
DOMAIN as HMIPC_DOMAIN, _LOGGER,
|
||||
HMIPC_HAPID, HMIPC_AUTHTOKEN, HMIPC_PIN, HMIPC_NAME)
|
||||
from .const import DOMAIN as HMIPC_DOMAIN
|
||||
from .const import HMIPC_AUTHTOKEN, HMIPC_HAPID, HMIPC_NAME, HMIPC_PIN
|
||||
from .const import _LOGGER
|
||||
from .hap import HomematicipAuth
|
||||
|
||||
|
||||
@callback
|
||||
def configured_haps(hass):
|
||||
"""Return a set of the configured accesspoints."""
|
||||
"""Return a set of the configured access points."""
|
||||
return set(entry.data[HMIPC_HAPID] for entry
|
||||
in hass.config_entries.async_entries(HMIPC_DOMAIN))
|
||||
|
||||
|
||||
@config_entries.HANDLERS.register(HMIPC_DOMAIN)
|
||||
class HomematicipCloudFlowHandler(data_entry_flow.FlowHandler):
|
||||
"""Config flow HomematicIP Cloud."""
|
||||
"""Config flow for the HomematicIP Cloud component."""
|
||||
|
||||
VERSION = 1
|
||||
|
||||
|
@ -44,28 +44,28 @@ class HomematicipCloudFlowHandler(data_entry_flow.FlowHandler):
|
|||
self.auth = HomematicipAuth(self.hass, user_input)
|
||||
connected = await self.auth.async_setup()
|
||||
if connected:
|
||||
_LOGGER.info("Connection established")
|
||||
_LOGGER.info("Connection to HomematicIP Cloud established")
|
||||
return await self.async_step_link()
|
||||
|
||||
return self.async_show_form(
|
||||
step_id='init',
|
||||
data_schema=vol.Schema({
|
||||
vol.Required(HMIPC_HAPID): str,
|
||||
vol.Optional(HMIPC_PIN): str,
|
||||
vol.Optional(HMIPC_NAME): str,
|
||||
vol.Optional(HMIPC_PIN): str,
|
||||
}),
|
||||
errors=errors
|
||||
)
|
||||
|
||||
async def async_step_link(self, user_input=None):
|
||||
"""Attempt to link with the HomematicIP Cloud accesspoint."""
|
||||
"""Attempt to link with the HomematicIP Cloud access point."""
|
||||
errors = {}
|
||||
|
||||
pressed = await self.auth.async_checkbutton()
|
||||
if pressed:
|
||||
authtoken = await self.auth.async_register()
|
||||
if authtoken:
|
||||
_LOGGER.info("Write config entry")
|
||||
_LOGGER.info("Write config entry for HomematicIP Cloud")
|
||||
return self.async_create_entry(
|
||||
title=self.auth.config.get(HMIPC_HAPID),
|
||||
data={
|
||||
|
@ -73,13 +73,13 @@ class HomematicipCloudFlowHandler(data_entry_flow.FlowHandler):
|
|||
HMIPC_AUTHTOKEN: authtoken,
|
||||
HMIPC_NAME: self.auth.config.get(HMIPC_NAME)
|
||||
})
|
||||
return self.async_abort(reason='conection_aborted')
|
||||
return self.async_abort(reason='connection_aborted')
|
||||
errors['base'] = 'press_the_button'
|
||||
|
||||
return self.async_show_form(step_id='link', errors=errors)
|
||||
|
||||
async def async_step_import(self, import_info):
|
||||
"""Import a new bridge as a config entry."""
|
||||
"""Import a new access point as a config entry."""
|
||||
hapid = import_info[HMIPC_HAPID]
|
||||
authtoken = import_info[HMIPC_AUTHTOKEN]
|
||||
name = import_info[HMIPC_NAME]
|
||||
|
@ -88,13 +88,13 @@ class HomematicipCloudFlowHandler(data_entry_flow.FlowHandler):
|
|||
if hapid in configured_haps(self.hass):
|
||||
return self.async_abort(reason='already_configured')
|
||||
|
||||
_LOGGER.info('Imported authentication for %s', hapid)
|
||||
_LOGGER.info("Imported authentication for %s", hapid)
|
||||
|
||||
return self.async_create_entry(
|
||||
title=hapid,
|
||||
data={
|
||||
HMIPC_HAPID: hapid,
|
||||
HMIPC_AUTHTOKEN: authtoken,
|
||||
HMIPC_NAME: name
|
||||
HMIPC_HAPID: hapid,
|
||||
HMIPC_NAME: name,
|
||||
}
|
||||
)
|
||||
|
|
|
@ -14,7 +14,6 @@ COMPONENTS = [
|
|||
'switch',
|
||||
]
|
||||
|
||||
CONF_NAME = 'name'
|
||||
CONF_ACCESSPOINT = 'accesspoint'
|
||||
CONF_AUTHTOKEN = 'authtoken'
|
||||
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
"""GenericDevice for the HomematicIP Cloud component."""
|
||||
"""Generic device for the HomematicIP Cloud component."""
|
||||
import logging
|
||||
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
ATTR_HOME_ID = 'home_id'
|
||||
ATTR_HOME_NAME = 'home_name'
|
||||
ATTR_CONNECTED = 'connected'
|
||||
ATTR_DEVICE_ID = 'device_id'
|
||||
ATTR_DEVICE_LABEL = 'device_label'
|
||||
ATTR_STATUS_UPDATE = 'status_update'
|
||||
ATTR_FIRMWARE_STATE = 'firmware_state'
|
||||
ATTR_UNREACHABLE = 'unreachable'
|
||||
ATTR_LOW_BATTERY = 'low_battery'
|
||||
ATTR_MODEL_TYPE = 'model_type'
|
||||
ATTR_GROUP_TYPE = 'group_type'
|
||||
ATTR_DEVICE_RSSI = 'device_rssi'
|
||||
ATTR_DUTY_CYCLE = 'duty_cycle'
|
||||
ATTR_CONNECTED = 'connected'
|
||||
ATTR_SABOTAGE = 'sabotage'
|
||||
ATTR_FIRMWARE_STATE = 'firmware_state'
|
||||
ATTR_GROUP_TYPE = 'group_type'
|
||||
ATTR_HOME_ID = 'home_id'
|
||||
ATTR_HOME_NAME = 'home_name'
|
||||
ATTR_LOW_BATTERY = 'low_battery'
|
||||
ATTR_MODEL_TYPE = 'model_type'
|
||||
ATTR_OPERATION_LOCK = 'operation_lock'
|
||||
ATTR_SABOTAGE = 'sabotage'
|
||||
ATTR_STATUS_UPDATE = 'status_update'
|
||||
ATTR_UNREACHABLE = 'unreachable'
|
||||
|
||||
|
||||
class HomematicipGenericDevice(Entity):
|
||||
|
@ -30,8 +30,7 @@ class HomematicipGenericDevice(Entity):
|
|||
self._home = home
|
||||
self._device = device
|
||||
self.post = post
|
||||
_LOGGER.info('Setting up %s (%s)', self.name,
|
||||
self._device.modelType)
|
||||
_LOGGER.info("Setting up %s (%s)", self.name, self._device.modelType)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Register callbacks."""
|
||||
|
@ -39,16 +38,16 @@ class HomematicipGenericDevice(Entity):
|
|||
|
||||
def _device_changed(self, json, **kwargs):
|
||||
"""Handle device state changes."""
|
||||
_LOGGER.debug('Event %s (%s)', self.name, self._device.modelType)
|
||||
_LOGGER.debug("Event %s (%s)", self.name, self._device.modelType)
|
||||
self.async_schedule_update_ha_state()
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the generic device."""
|
||||
name = self._device.label
|
||||
if (self._home.name is not None and self._home.name != ''):
|
||||
if self._home.name is not None and self._home.name != '':
|
||||
name = "{} {}".format(self._home.name, name)
|
||||
if (self.post is not None and self.post != ''):
|
||||
if self.post is not None and self.post != '':
|
||||
name = "{} {}".format(name, self.post)
|
||||
return name
|
||||
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
"""Errors for the HomematicIP component."""
|
||||
"""Errors for the HomematicIP Cloud component."""
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
|
||||
class HmipcException(HomeAssistantError):
|
||||
"""Base class for HomematicIP exceptions."""
|
||||
"""Base class for HomematicIP Cloud exceptions."""
|
||||
|
||||
|
||||
class HmipcConnectionError(HmipcException):
|
||||
"""Unable to connect to the HomematicIP cloud server."""
|
||||
"""Unable to connect to the HomematicIP Cloud server."""
|
||||
|
||||
|
||||
class HmipcConnectionWait(HmipcException):
|
||||
"""Wait for registration to the HomematicIP cloud server."""
|
||||
"""Wait for registration to the HomematicIP Cloud server."""
|
||||
|
||||
|
||||
class HmipcRegistrationFailed(HmipcException):
|
||||
"""Registration on HomematicIP cloud failed."""
|
||||
"""Registration on HomematicIP Cloud failed."""
|
||||
|
||||
|
||||
class HmipcPressButton(HmipcException):
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
"""Accesspoint for the HomematicIP Cloud component."""
|
||||
"""Access point for the HomematicIP Cloud component."""
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
from .const import (
|
||||
HMIPC_HAPID, HMIPC_AUTHTOKEN, HMIPC_PIN, HMIPC_NAME,
|
||||
COMPONENTS)
|
||||
COMPONENTS, HMIPC_AUTHTOKEN, HMIPC_HAPID, HMIPC_NAME, HMIPC_PIN)
|
||||
from .errors import HmipcConnectionError
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -74,10 +73,10 @@ class HomematicipAuth:
|
|||
|
||||
|
||||
class HomematicipHAP:
|
||||
"""Manages HomematicIP http and websocket connection."""
|
||||
"""Manages HomematicIP HTTP and WebSocket connection."""
|
||||
|
||||
def __init__(self, hass, config_entry):
|
||||
"""Initialize HomematicIP cloud connection."""
|
||||
"""Initialize HomematicIP Cloud connection."""
|
||||
self.hass = hass
|
||||
self.config_entry = config_entry
|
||||
self.home = None
|
||||
|
@ -100,7 +99,7 @@ class HomematicipHAP:
|
|||
except HmipcConnectionError:
|
||||
retry_delay = 2 ** min(tries + 1, 6)
|
||||
_LOGGER.error("Error connecting to HomematicIP with HAP %s. "
|
||||
"Retrying in %d seconds.",
|
||||
"Retrying in %d seconds",
|
||||
self.config_entry.data.get(HMIPC_HAPID), retry_delay)
|
||||
|
||||
async def retry_setup(_now):
|
||||
|
@ -113,7 +112,7 @@ class HomematicipHAP:
|
|||
|
||||
return False
|
||||
|
||||
_LOGGER.info('Connected to HomematicIP with HAP %s.',
|
||||
_LOGGER.info("Connected to HomematicIP with HAP %s",
|
||||
self.config_entry.data.get(HMIPC_HAPID))
|
||||
|
||||
for component in COMPONENTS:
|
||||
|
@ -127,7 +126,7 @@ class HomematicipHAP:
|
|||
def async_update(self, *args, **kwargs):
|
||||
"""Async update the home device.
|
||||
|
||||
Triggered when the hmip HOME_CHANGED event has fired.
|
||||
Triggered when the HMIP HOME_CHANGED event has fired.
|
||||
There are several occasions for this event to happen.
|
||||
We are only interested to check whether the access point
|
||||
is still connected. If not, device state changes cannot
|
||||
|
@ -147,7 +146,7 @@ class HomematicipHAP:
|
|||
job.add_done_callback(self.get_state_finished)
|
||||
|
||||
async def get_state(self):
|
||||
"""Update hmip state and tell hass."""
|
||||
"""Update HMIP state and tell Home Assistant."""
|
||||
await self.home.get_current_state()
|
||||
self.update_all()
|
||||
|
||||
|
@ -161,11 +160,11 @@ class HomematicipHAP:
|
|||
# Somehow connection could not recover. Will disconnect and
|
||||
# so reconnect loop is taking over.
|
||||
_LOGGER.error(
|
||||
"updating state after himp access point reconnect failed.")
|
||||
"Updating state after HMIP access point reconnect failed")
|
||||
self.hass.async_add_job(self.home.disable_events())
|
||||
|
||||
def set_all_to_unavailable(self):
|
||||
"""Set all devices to unavailable and tell Hass."""
|
||||
"""Set all devices to unavailable and tell Home Assistant."""
|
||||
for device in self.home.devices:
|
||||
device.unreach = True
|
||||
self.update_all()
|
||||
|
@ -190,7 +189,7 @@ class HomematicipHAP:
|
|||
return
|
||||
|
||||
async def async_connect(self):
|
||||
"""Start websocket connection."""
|
||||
"""Start WebSocket connection."""
|
||||
from homematicip.base.base_connection import HmipConnectionError
|
||||
|
||||
tries = 0
|
||||
|
@ -210,7 +209,7 @@ class HomematicipHAP:
|
|||
tries += 1
|
||||
retry_delay = 2 ** min(tries + 1, 6)
|
||||
_LOGGER.error("Error connecting to HomematicIP with HAP %s. "
|
||||
"Retrying in %d seconds.",
|
||||
"Retrying in %d seconds",
|
||||
self.config_entry.data.get(HMIPC_HAPID), retry_delay)
|
||||
try:
|
||||
self._retry_task = self.hass.async_add_job(asyncio.sleep(
|
||||
|
@ -227,7 +226,7 @@ class HomematicipHAP:
|
|||
if self._retry_task is not None:
|
||||
self._retry_task.cancel()
|
||||
self.home.disable_events()
|
||||
_LOGGER.info("Closed connection to HomematicIP cloud server.")
|
||||
_LOGGER.info("Closed connection to HomematicIP cloud server")
|
||||
for component in COMPONENTS:
|
||||
await self.hass.config_entries.async_forward_entry_unload(
|
||||
self.config_entry, component)
|
||||
|
|
|
@ -3,16 +3,16 @@
|
|||
"title": "HomematicIP Cloud",
|
||||
"step": {
|
||||
"init": {
|
||||
"title": "Pick HomematicIP Accesspoint",
|
||||
"title": "Pick HomematicIP Access point",
|
||||
"data": {
|
||||
"hapid": "Accesspoint ID (SGTIN)",
|
||||
"hapid": "Access point ID (SGTIN)",
|
||||
"pin": "Pin Code (optional)",
|
||||
"name": "Name (optional, used as name prefix for all devices)"
|
||||
}
|
||||
},
|
||||
"link": {
|
||||
"title": "Link Accesspoint",
|
||||
"description": "Press the blue button on the accesspoint and the submit button to register HomematicIP with Home Assistant.\n\n"
|
||||
"title": "Link Access point",
|
||||
"description": "Press the blue button on the access point and the submit button to register HomematicIP with Home Assistant.\n\n"
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
|
@ -23,8 +23,8 @@
|
|||
},
|
||||
"abort": {
|
||||
"unknown": "Unknown error occurred.",
|
||||
"conection_aborted": "Could not connect to HMIP server",
|
||||
"already_configured": "Accesspoint is already configured"
|
||||
"connection_aborted": "Could not connect to HMIP server",
|
||||
"already_configured": "Access point is already configured"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,10 @@ For more details about this platform, please refer to the documentation at
|
|||
https://home-assistant.io/components/light.homematic/
|
||||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.components.homematic import ATTR_DISCOVER_DEVICES, HMDevice
|
||||
from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light)
|
||||
from homeassistant.components.homematic import HMDevice, ATTR_DISCOVER_DEVICES
|
||||
from homeassistant.const import STATE_UNKNOWN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
|
|
@ -1,37 +1,35 @@
|
|||
"""
|
||||
Support for HomematicIP light.
|
||||
Support for HomematicIP Cloud lights.
|
||||
|
||||
For more details about this component, please refer to the documentation at
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/light.homematicip_cloud/
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from homeassistant.components.light import (
|
||||
Light, ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS)
|
||||
from homeassistant.components.homematicip_cloud import (
|
||||
HomematicipGenericDevice, DOMAIN as HMIPC_DOMAIN,
|
||||
HMIPC_HAPID)
|
||||
HMIPC_HAPID, HomematicipGenericDevice)
|
||||
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
|
||||
from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light)
|
||||
|
||||
DEPENDENCIES = ['homematicip_cloud']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
ATTR_ENERGY_COUNTER = 'energy_counter_kwh'
|
||||
ATTR_POWER_CONSUMPTION = 'power_consumption'
|
||||
ATTR_ENERGIE_COUNTER = 'energie_counter_kwh'
|
||||
ATTR_PROFILE_MODE = 'profile_mode'
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_devices,
|
||||
discovery_info=None):
|
||||
"""Old way of setting up HomematicIP lights."""
|
||||
async def async_setup_platform(
|
||||
hass, config, async_add_devices, discovery_info=None):
|
||||
"""Old way of setting up HomematicIP Cloud lights."""
|
||||
pass
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_devices):
|
||||
"""Set up the HomematicIP lights from a config entry."""
|
||||
from homematicip.aio.device import (
|
||||
AsyncBrandSwitchMeasuring, AsyncDimmer)
|
||||
"""Set up the HomematicIP Cloud lights from a config entry."""
|
||||
from homematicip.aio.device import AsyncBrandSwitchMeasuring, AsyncDimmer
|
||||
|
||||
home = hass.data[HMIPC_DOMAIN][config_entry.data[HMIPC_HAPID]].home
|
||||
devices = []
|
||||
|
@ -46,7 +44,7 @@ async def async_setup_entry(hass, config_entry, async_add_devices):
|
|||
|
||||
|
||||
class HomematicipLight(HomematicipGenericDevice, Light):
|
||||
"""MomematicIP light device."""
|
||||
"""Representation of a HomematicIP Cloud light device."""
|
||||
|
||||
def __init__(self, home, device):
|
||||
"""Initialize the light device."""
|
||||
|
@ -67,7 +65,7 @@ class HomematicipLight(HomematicipGenericDevice, Light):
|
|||
|
||||
|
||||
class HomematicipLightMeasuring(HomematicipLight):
|
||||
"""MomematicIP measuring light device."""
|
||||
"""Representation of a HomematicIP Cloud measuring light device."""
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
|
@ -79,13 +77,13 @@ class HomematicipLightMeasuring(HomematicipLight):
|
|||
round(self._device.currentPowerConsumption, 2)
|
||||
})
|
||||
attr.update({
|
||||
ATTR_ENERGIE_COUNTER: round(self._device.energyCounter, 2)
|
||||
ATTR_ENERGY_COUNTER: round(self._device.energyCounter, 2)
|
||||
})
|
||||
return attr
|
||||
|
||||
|
||||
class HomematicipDimmer(HomematicipGenericDevice, Light):
|
||||
"""MomematicIP dimmer light device."""
|
||||
"""Representation of HomematicIP Cloud dimmer light device."""
|
||||
|
||||
def __init__(self, home, device):
|
||||
"""Initialize the dimmer light device."""
|
||||
|
@ -109,8 +107,7 @@ class HomematicipDimmer(HomematicipGenericDevice, Light):
|
|||
async def async_turn_on(self, **kwargs):
|
||||
"""Turn the light on."""
|
||||
if ATTR_BRIGHTNESS in kwargs:
|
||||
await self._device.set_dim_level(
|
||||
kwargs[ATTR_BRIGHTNESS]/255.0)
|
||||
await self._device.set_dim_level(kwargs[ATTR_BRIGHTNESS]/255.0)
|
||||
else:
|
||||
await self._device.set_dim_level(1)
|
||||
|
||||
|
|
|
@ -5,10 +5,10 @@ For more details about this platform, please refer to the documentation at
|
|||
https://home-assistant.io/components/lock.homematic/
|
||||
"""
|
||||
import logging
|
||||
from homeassistant.components.lock import LockDevice, SUPPORT_OPEN
|
||||
from homeassistant.components.homematic import HMDevice, ATTR_DISCOVER_DEVICES
|
||||
from homeassistant.const import STATE_UNKNOWN
|
||||
|
||||
from homeassistant.components.homematic import ATTR_DISCOVER_DEVICES, HMDevice
|
||||
from homeassistant.components.lock import SUPPORT_OPEN, LockDevice
|
||||
from homeassistant.const import STATE_UNKNOWN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@ For more details about this platform, please refer to the documentation at
|
|||
https://home-assistant.io/components/sensor.homematic/
|
||||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.components.homematic import ATTR_DISCOVER_DEVICES, HMDevice
|
||||
from homeassistant.const import STATE_UNKNOWN
|
||||
from homeassistant.components.homematic import HMDevice, ATTR_DISCOVER_DEVICES
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -70,7 +71,7 @@ HM_ICON_HA_CAST = {
|
|||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Set up the HomeMatic platform."""
|
||||
"""Set up the HomeMatic sensor platform."""
|
||||
if discovery_info is None:
|
||||
return
|
||||
|
||||
|
@ -83,7 +84,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
|
||||
|
||||
class HMSensor(HMDevice):
|
||||
"""Represents various HomeMatic sensors in Home Assistant."""
|
||||
"""Representation of a HomeMatic sensor."""
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
|
@ -111,4 +112,4 @@ class HMSensor(HMDevice):
|
|||
if self._state:
|
||||
self._data.update({self._state: STATE_UNKNOWN})
|
||||
else:
|
||||
_LOGGER.critical("Can't initialize sensor %s", self._name)
|
||||
_LOGGER.critical("Unable to initialize sensor: %s", self._name)
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
"""
|
||||
Support for HomematicIP sensors.
|
||||
Support for HomematicIP Cloud sensors.
|
||||
|
||||
For more details about this component, please refer to the documentation at
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.homematicip_cloud/
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from homeassistant.components.homematicip_cloud import (
|
||||
HomematicipGenericDevice, DOMAIN as HMIPC_DOMAIN,
|
||||
HMIPC_HAPID)
|
||||
HMIPC_HAPID, HomematicipGenericDevice)
|
||||
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
|
||||
from homeassistant.const import (
|
||||
TEMP_CELSIUS, DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_ILLUMINANCE)
|
||||
DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_ILLUMINANCE, DEVICE_CLASS_TEMPERATURE,
|
||||
TEMP_CELSIUS)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -25,14 +24,14 @@ ATTR_TEMPERATURE_OFFSET = 'temperature_offset'
|
|||
ATTR_HUMIDITY = 'humidity'
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_devices,
|
||||
discovery_info=None):
|
||||
"""Set up the HomematicIP sensors devices."""
|
||||
async def async_setup_platform(
|
||||
hass, config, async_add_devices, discovery_info=None):
|
||||
"""Set up the HomematicIP Cloud sensors devices."""
|
||||
pass
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_devices):
|
||||
"""Set up the HomematicIP sensors from a config entry."""
|
||||
"""Set up the HomematicIP Cloud sensors from a config entry."""
|
||||
from homematicip.device import (
|
||||
HeatingThermostat, TemperatureHumiditySensorWithoutDisplay,
|
||||
TemperatureHumiditySensorDisplay, MotionDetectorIndoor)
|
||||
|
@ -54,7 +53,7 @@ async def async_setup_entry(hass, config_entry, async_add_devices):
|
|||
|
||||
|
||||
class HomematicipAccesspointStatus(HomematicipGenericDevice):
|
||||
"""Representation of an HomeMaticIP access point."""
|
||||
"""Representation of an HomeMaticIP Cloud access point."""
|
||||
|
||||
def __init__(self, home):
|
||||
"""Initialize access point device."""
|
||||
|
@ -82,7 +81,7 @@ class HomematicipAccesspointStatus(HomematicipGenericDevice):
|
|||
|
||||
|
||||
class HomematicipHeatingThermostat(HomematicipGenericDevice):
|
||||
"""MomematicIP heating thermostat representation."""
|
||||
"""Represenation of a HomematicIP heating thermostat device."""
|
||||
|
||||
def __init__(self, home, device):
|
||||
"""Initialize heating thermostat device."""
|
||||
|
@ -115,7 +114,7 @@ class HomematicipHeatingThermostat(HomematicipGenericDevice):
|
|||
|
||||
|
||||
class HomematicipHumiditySensor(HomematicipGenericDevice):
|
||||
"""MomematicIP humidity device."""
|
||||
"""Represenation of a HomematicIP Cloud humidity device."""
|
||||
|
||||
def __init__(self, home, device):
|
||||
"""Initialize the thermometer device."""
|
||||
|
@ -138,7 +137,7 @@ class HomematicipHumiditySensor(HomematicipGenericDevice):
|
|||
|
||||
|
||||
class HomematicipTemperatureSensor(HomematicipGenericDevice):
|
||||
"""MomematicIP the thermometer device."""
|
||||
"""Representation of a HomematicIP Cloud thermometer device."""
|
||||
|
||||
def __init__(self, home, device):
|
||||
"""Initialize the thermometer device."""
|
||||
|
@ -161,7 +160,7 @@ class HomematicipTemperatureSensor(HomematicipGenericDevice):
|
|||
|
||||
|
||||
class HomematicipIlluminanceSensor(HomematicipGenericDevice):
|
||||
"""MomematicIP the thermometer device."""
|
||||
"""Represenation of a HomematicIP Illuminance device."""
|
||||
|
||||
def __init__(self, home, device):
|
||||
"""Initialize the device."""
|
||||
|
|
|
@ -5,8 +5,9 @@ For more details about this platform, please refer to the documentation at
|
|||
https://home-assistant.io/components/switch.homematic/
|
||||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.components.homematic import ATTR_DISCOVER_DEVICES, HMDevice
|
||||
from homeassistant.components.switch import SwitchDevice
|
||||
from homeassistant.components.homematic import HMDevice, ATTR_DISCOVER_DEVICES
|
||||
from homeassistant.const import STATE_UNKNOWN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
"""
|
||||
Support for HomematicIP switch.
|
||||
Support for HomematicIP Cloud switch.
|
||||
|
||||
For more details about this component, please refer to the documentation at
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/switch.homematicip_cloud/
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from homeassistant.components.switch import SwitchDevice
|
||||
from homeassistant.components.homematicip_cloud import (
|
||||
HomematicipGenericDevice, DOMAIN as HMIPC_DOMAIN,
|
||||
HMIPC_HAPID)
|
||||
HMIPC_HAPID, HomematicipGenericDevice)
|
||||
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
|
||||
from homeassistant.components.switch import SwitchDevice
|
||||
|
||||
DEPENDENCIES = ['homematicip_cloud']
|
||||
|
||||
|
@ -21,17 +20,16 @@ ATTR_ENERGIE_COUNTER = 'energie_counter'
|
|||
ATTR_PROFILE_MODE = 'profile_mode'
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_devices,
|
||||
discovery_info=None):
|
||||
"""Set up the HomematicIP switch devices."""
|
||||
async def async_setup_platform(
|
||||
hass, config, async_add_devices, discovery_info=None):
|
||||
"""Set up the HomematicIP Cloud switch devices."""
|
||||
pass
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_devices):
|
||||
"""Set up the HomematicIP switch from a config entry."""
|
||||
from homematicip.device import (
|
||||
PlugableSwitch, PlugableSwitchMeasuring,
|
||||
BrandSwitchMeasuring)
|
||||
PlugableSwitch, PlugableSwitchMeasuring, BrandSwitchMeasuring)
|
||||
|
||||
home = hass.data[HMIPC_DOMAIN][config_entry.data[HMIPC_HAPID]].home
|
||||
devices = []
|
||||
|
@ -51,7 +49,7 @@ async def async_setup_entry(hass, config_entry, async_add_devices):
|
|||
|
||||
|
||||
class HomematicipSwitch(HomematicipGenericDevice, SwitchDevice):
|
||||
"""MomematicIP switch device."""
|
||||
"""representation of a HomematicIP Cloud switch device."""
|
||||
|
||||
def __init__(self, home, device):
|
||||
"""Initialize the switch device."""
|
||||
|
@ -72,7 +70,7 @@ class HomematicipSwitch(HomematicipGenericDevice, SwitchDevice):
|
|||
|
||||
|
||||
class HomematicipSwitchMeasuring(HomematicipSwitch):
|
||||
"""MomematicIP measuring switch device."""
|
||||
"""Representation of a HomematicIP measuring switch device."""
|
||||
|
||||
@property
|
||||
def current_power_w(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue