Minor updates (#16106)

This commit is contained in:
Fabian Affolter 2018-08-21 21:25:16 +02:00 committed by GitHub
parent 1ce51bfbd6
commit 0e1fb74e1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 172 additions and 180 deletions

View file

@ -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/ https://home-assistant.io/components/alarm_control_panel.homematicip_cloud/
""" """
import logging 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 ( from homeassistant.const import (
STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED, STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED,
STATE_ALARM_TRIGGERED) 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__) _LOGGER = logging.getLogger(__name__)
DEPENDENCIES = ['homematicip_cloud']
HMIP_ZONE_AWAY = 'EXTERNAL' HMIP_ZONE_AWAY = 'EXTERNAL'
HMIP_ZONE_HOME = 'INTERNAL' HMIP_ZONE_HOME = 'INTERNAL'
async def async_setup_platform(hass, config, async_add_devices, async def async_setup_platform(
discovery_info=None): hass, config, async_add_devices, discovery_info=None):
"""Set up the HomematicIP alarm control devices.""" """Set up the HomematicIP Cloud alarm control devices."""
pass pass
@ -45,7 +44,7 @@ async def async_setup_entry(hass, config_entry, async_add_devices):
class HomematicipSecurityZone(HomematicipGenericDevice, AlarmControlPanel): class HomematicipSecurityZone(HomematicipGenericDevice, AlarmControlPanel):
"""Representation of an HomematicIP security zone group.""" """Representation of an HomematicIP Cloud security zone group."""
def __init__(self, home, device): def __init__(self, home, device):
"""Initialize the security zone group.""" """Initialize the security zone group."""

View file

@ -5,27 +5,28 @@ For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/binary_sensor.homematic/ https://home-assistant.io/components/binary_sensor.homematic/
""" """
import logging import logging
from homeassistant.const import STATE_UNKNOWN
from homeassistant.components.binary_sensor import BinarySensorDevice 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__) _LOGGER = logging.getLogger(__name__)
DEPENDENCIES = ['homematic'] DEPENDENCIES = ['homematic']
SENSOR_TYPES_CLASS = { SENSOR_TYPES_CLASS = {
'Remote': None,
'ShutterContact': 'opening',
'MaxShutterContact': 'opening',
'IPShutterContact': 'opening', 'IPShutterContact': 'opening',
'Smoke': 'smoke', 'MaxShutterContact': 'opening',
'SmokeV2': 'smoke',
'Motion': 'motion', 'Motion': 'motion',
'MotionV2': 'motion', 'MotionV2': 'motion',
'RemoteMotion': None,
'WeatherSensor': None,
'TiltSensor': None,
'PresenceIP': 'motion', 'PresenceIP': 'motion',
'Remote': None,
'RemoteMotion': None,
'ShutterContact': 'opening',
'Smoke': 'smoke',
'SmokeV2': 'smoke',
'TiltSensor': None,
'WeatherSensor': None,
} }

View file

@ -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/ https://home-assistant.io/components/binary_sensor.homematicip_cloud/
""" """
import logging import logging
from homeassistant.components.binary_sensor import BinarySensorDevice from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.homematicip_cloud import ( from homeassistant.components.homematicip_cloud import (
HomematicipGenericDevice, DOMAIN as HMIPC_DOMAIN, HMIPC_HAPID, HomematicipGenericDevice)
HMIPC_HAPID) from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
DEPENDENCIES = ['homematicip_cloud'] DEPENDENCIES = ['homematicip_cloud']
@ -19,14 +18,14 @@ _LOGGER = logging.getLogger(__name__)
STATE_SMOKE_OFF = 'IDLE_OFF' STATE_SMOKE_OFF = 'IDLE_OFF'
async def async_setup_platform(hass, config, async_add_devices, async def async_setup_platform(
discovery_info=None): hass, config, async_add_devices, discovery_info=None):
"""Set up the binary sensor devices.""" """Set up the HomematicIP Cloud binary sensor devices."""
pass pass
async def async_setup_entry(hass, config_entry, async_add_devices): 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 ( from homematicip.aio.device import (
AsyncShutterContact, AsyncMotionDetectorIndoor, AsyncSmokeDetector) AsyncShutterContact, AsyncMotionDetectorIndoor, AsyncSmokeDetector)
@ -45,7 +44,7 @@ async def async_setup_entry(hass, config_entry, async_add_devices):
class HomematicipShutterContact(HomematicipGenericDevice, BinarySensorDevice): class HomematicipShutterContact(HomematicipGenericDevice, BinarySensorDevice):
"""HomematicIP shutter contact.""" """Representation of a HomematicIP Cloud shutter contact."""
@property @property
def device_class(self): def device_class(self):
@ -65,7 +64,7 @@ class HomematicipShutterContact(HomematicipGenericDevice, BinarySensorDevice):
class HomematicipMotionDetector(HomematicipGenericDevice, BinarySensorDevice): class HomematicipMotionDetector(HomematicipGenericDevice, BinarySensorDevice):
"""HomematicIP motion detector.""" """Representation of a HomematicIP Cloud motion detector."""
@property @property
def device_class(self): def device_class(self):
@ -81,7 +80,7 @@ class HomematicipMotionDetector(HomematicipGenericDevice, BinarySensorDevice):
class HomematicipSmokeDetector(HomematicipGenericDevice, BinarySensorDevice): class HomematicipSmokeDetector(HomematicipGenericDevice, BinarySensorDevice):
"""HomematicIP smoke detector.""" """Representation of a HomematicIP Cloud smoke detector."""
@property @property
def device_class(self): def device_class(self):

View file

@ -5,12 +5,13 @@ For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/climate.homematic/ https://home-assistant.io/components/climate.homematic/
""" """
import logging import logging
from homeassistant.components.climate import ( from homeassistant.components.climate import (
ClimateDevice, STATE_AUTO, SUPPORT_TARGET_TEMPERATURE, STATE_AUTO, SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE,
SUPPORT_OPERATION_MODE) ClimateDevice)
from homeassistant.components.homematic import ( from homeassistant.components.homematic import (
HMDevice, ATTR_DISCOVER_DEVICES, HM_ATTRIBUTE_SUPPORT) ATTR_DISCOVER_DEVICES, HM_ATTRIBUTE_SUPPORT, HMDevice)
from homeassistant.const import TEMP_CELSIUS, STATE_UNKNOWN, ATTR_TEMPERATURE from homeassistant.const import ATTR_TEMPERATURE, STATE_UNKNOWN, TEMP_CELSIUS
DEPENDENCIES = ['homematic'] DEPENDENCIES = ['homematic']

View file

@ -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/ https://home-assistant.io/components/climate.homematicip_cloud/
""" """
import logging import logging
from homeassistant.components.climate import ( from homeassistant.components.climate import (
ClimateDevice, SUPPORT_TARGET_TEMPERATURE, ATTR_TEMPERATURE, ATTR_TEMPERATURE, STATE_AUTO, STATE_MANUAL, SUPPORT_TARGET_TEMPERATURE,
STATE_AUTO, STATE_MANUAL) ClimateDevice)
from homeassistant.const import TEMP_CELSIUS
from homeassistant.components.homematicip_cloud import ( from homeassistant.components.homematicip_cloud import (
HomematicipGenericDevice, DOMAIN as HMIPC_DOMAIN, HMIPC_HAPID, HomematicipGenericDevice)
HMIPC_HAPID) from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
from homeassistant.const import TEMP_CELSIUS
_LOGGER = logging.getLogger(__name__) _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()} 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, async def async_setup_platform(
discovery_info=None): hass, config, async_add_devices, discovery_info=None):
"""Set up the HomematicIP climate devices.""" """Set up the HomematicIP Cloud climate devices."""
pass pass
@ -48,7 +47,7 @@ async def async_setup_entry(hass, config_entry, async_add_devices):
class HomematicipHeatingGroup(HomematicipGenericDevice, ClimateDevice): class HomematicipHeatingGroup(HomematicipGenericDevice, ClimateDevice):
"""Representation of a MomematicIP heating group.""" """Representation of a HomematicIP heating group."""
def __init__(self, home, device): def __init__(self, home, device):
"""Initialize heating group.""" """Initialize heating group."""

View file

@ -6,9 +6,9 @@ https://home-assistant.io/components/cover.homematic/
""" """
import logging import logging
from homeassistant.components.cover import CoverDevice, ATTR_POSITION,\ from homeassistant.components.cover import (
ATTR_TILT_POSITION ATTR_POSITION, ATTR_TILT_POSITION, CoverDevice)
from homeassistant.components.homematic import HMDevice, ATTR_DISCOVER_DEVICES from homeassistant.components.homematic import ATTR_DISCOVER_DEVICES, HMDevice
from homeassistant.const import STATE_UNKNOWN from homeassistant.const import STATE_UNKNOWN
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View file

@ -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 For more details about this component, please refer to the documentation at
https://home-assistant.io/components/homematicip_cloud/ https://home-assistant.io/components/homematicip_cloud/
""" """
import logging import logging
import voluptuous as vol import voluptuous as vol
import homeassistant.helpers.config_validation as cv
from homeassistant import config_entries 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 .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 .device import HomematicipGenericDevice # noqa: F401
from .hap import HomematicipAuth, HomematicipHAP # noqa: F401
REQUIREMENTS = ['homematicip==0.9.8'] REQUIREMENTS = ['homematicip==0.9.8']
@ -34,7 +33,7 @@ CONFIG_SCHEMA = vol.Schema({
async def async_setup(hass, config): async def async_setup(hass, config):
"""Set up the HomematicIP component.""" """Set up the HomematicIP Cloud component."""
hass.data[DOMAIN] = {} hass.data[DOMAIN] = {}
accesspoints = config.get(DOMAIN, []) accesspoints = config.get(DOMAIN, [])
@ -54,7 +53,7 @@ async def async_setup(hass, config):
async def async_setup_entry(hass, entry): 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) hap = HomematicipHAP(hass, entry)
hapid = entry.data[HMIPC_HAPID].replace('-', '').upper() hapid = entry.data[HMIPC_HAPID].replace('-', '').upper()
hass.data[DOMAIN][hapid] = hap hass.data[DOMAIN][hapid] = hap

View file

@ -1,25 +1,25 @@
"""Config flow to configure HomematicIP Cloud.""" """Config flow to configure the HomematicIP Cloud component."""
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries, data_entry_flow from homeassistant import config_entries, data_entry_flow
from homeassistant.core import callback from homeassistant.core import callback
from .const import ( from .const import DOMAIN as HMIPC_DOMAIN
DOMAIN as HMIPC_DOMAIN, _LOGGER, from .const import HMIPC_AUTHTOKEN, HMIPC_HAPID, HMIPC_NAME, HMIPC_PIN
HMIPC_HAPID, HMIPC_AUTHTOKEN, HMIPC_PIN, HMIPC_NAME) from .const import _LOGGER
from .hap import HomematicipAuth from .hap import HomematicipAuth
@callback @callback
def configured_haps(hass): 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 return set(entry.data[HMIPC_HAPID] for entry
in hass.config_entries.async_entries(HMIPC_DOMAIN)) in hass.config_entries.async_entries(HMIPC_DOMAIN))
@config_entries.HANDLERS.register(HMIPC_DOMAIN) @config_entries.HANDLERS.register(HMIPC_DOMAIN)
class HomematicipCloudFlowHandler(data_entry_flow.FlowHandler): class HomematicipCloudFlowHandler(data_entry_flow.FlowHandler):
"""Config flow HomematicIP Cloud.""" """Config flow for the HomematicIP Cloud component."""
VERSION = 1 VERSION = 1
@ -44,28 +44,28 @@ class HomematicipCloudFlowHandler(data_entry_flow.FlowHandler):
self.auth = HomematicipAuth(self.hass, user_input) self.auth = HomematicipAuth(self.hass, user_input)
connected = await self.auth.async_setup() connected = await self.auth.async_setup()
if connected: if connected:
_LOGGER.info("Connection established") _LOGGER.info("Connection to HomematicIP Cloud established")
return await self.async_step_link() return await self.async_step_link()
return self.async_show_form( return self.async_show_form(
step_id='init', step_id='init',
data_schema=vol.Schema({ data_schema=vol.Schema({
vol.Required(HMIPC_HAPID): str, vol.Required(HMIPC_HAPID): str,
vol.Optional(HMIPC_PIN): str,
vol.Optional(HMIPC_NAME): str, vol.Optional(HMIPC_NAME): str,
vol.Optional(HMIPC_PIN): str,
}), }),
errors=errors errors=errors
) )
async def async_step_link(self, user_input=None): 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 = {} errors = {}
pressed = await self.auth.async_checkbutton() pressed = await self.auth.async_checkbutton()
if pressed: if pressed:
authtoken = await self.auth.async_register() authtoken = await self.auth.async_register()
if authtoken: if authtoken:
_LOGGER.info("Write config entry") _LOGGER.info("Write config entry for HomematicIP Cloud")
return self.async_create_entry( return self.async_create_entry(
title=self.auth.config.get(HMIPC_HAPID), title=self.auth.config.get(HMIPC_HAPID),
data={ data={
@ -73,13 +73,13 @@ class HomematicipCloudFlowHandler(data_entry_flow.FlowHandler):
HMIPC_AUTHTOKEN: authtoken, HMIPC_AUTHTOKEN: authtoken,
HMIPC_NAME: self.auth.config.get(HMIPC_NAME) 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' errors['base'] = 'press_the_button'
return self.async_show_form(step_id='link', errors=errors) return self.async_show_form(step_id='link', errors=errors)
async def async_step_import(self, import_info): 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] hapid = import_info[HMIPC_HAPID]
authtoken = import_info[HMIPC_AUTHTOKEN] authtoken = import_info[HMIPC_AUTHTOKEN]
name = import_info[HMIPC_NAME] name = import_info[HMIPC_NAME]
@ -88,13 +88,13 @@ class HomematicipCloudFlowHandler(data_entry_flow.FlowHandler):
if hapid in configured_haps(self.hass): if hapid in configured_haps(self.hass):
return self.async_abort(reason='already_configured') 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( return self.async_create_entry(
title=hapid, title=hapid,
data={ data={
HMIPC_HAPID: hapid,
HMIPC_AUTHTOKEN: authtoken, HMIPC_AUTHTOKEN: authtoken,
HMIPC_NAME: name HMIPC_HAPID: hapid,
HMIPC_NAME: name,
} }
) )

View file

@ -14,7 +14,6 @@ COMPONENTS = [
'switch', 'switch',
] ]
CONF_NAME = 'name'
CONF_ACCESSPOINT = 'accesspoint' CONF_ACCESSPOINT = 'accesspoint'
CONF_AUTHTOKEN = 'authtoken' CONF_AUTHTOKEN = 'authtoken'

View file

@ -1,25 +1,25 @@
"""GenericDevice for the HomematicIP Cloud component.""" """Generic device for the HomematicIP Cloud component."""
import logging import logging
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
ATTR_HOME_ID = 'home_id' ATTR_CONNECTED = 'connected'
ATTR_HOME_NAME = 'home_name'
ATTR_DEVICE_ID = 'device_id' ATTR_DEVICE_ID = 'device_id'
ATTR_DEVICE_LABEL = 'device_label' 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_DEVICE_RSSI = 'device_rssi'
ATTR_DUTY_CYCLE = 'duty_cycle' ATTR_DUTY_CYCLE = 'duty_cycle'
ATTR_CONNECTED = 'connected' ATTR_FIRMWARE_STATE = 'firmware_state'
ATTR_SABOTAGE = 'sabotage' 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_OPERATION_LOCK = 'operation_lock'
ATTR_SABOTAGE = 'sabotage'
ATTR_STATUS_UPDATE = 'status_update'
ATTR_UNREACHABLE = 'unreachable'
class HomematicipGenericDevice(Entity): class HomematicipGenericDevice(Entity):
@ -30,8 +30,7 @@ class HomematicipGenericDevice(Entity):
self._home = home self._home = home
self._device = device self._device = device
self.post = post self.post = post
_LOGGER.info('Setting up %s (%s)', self.name, _LOGGER.info("Setting up %s (%s)", self.name, self._device.modelType)
self._device.modelType)
async def async_added_to_hass(self): async def async_added_to_hass(self):
"""Register callbacks.""" """Register callbacks."""
@ -39,16 +38,16 @@ class HomematicipGenericDevice(Entity):
def _device_changed(self, json, **kwargs): def _device_changed(self, json, **kwargs):
"""Handle device state changes.""" """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() self.async_schedule_update_ha_state()
@property @property
def name(self): def name(self):
"""Return the name of the generic device.""" """Return the name of the generic device."""
name = self._device.label 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) 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) name = "{} {}".format(name, self.post)
return name return name

View file

@ -1,21 +1,21 @@
"""Errors for the HomematicIP component.""" """Errors for the HomematicIP Cloud component."""
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
class HmipcException(HomeAssistantError): class HmipcException(HomeAssistantError):
"""Base class for HomematicIP exceptions.""" """Base class for HomematicIP Cloud exceptions."""
class HmipcConnectionError(HmipcException): class HmipcConnectionError(HmipcException):
"""Unable to connect to the HomematicIP cloud server.""" """Unable to connect to the HomematicIP Cloud server."""
class HmipcConnectionWait(HmipcException): class HmipcConnectionWait(HmipcException):
"""Wait for registration to the HomematicIP cloud server.""" """Wait for registration to the HomematicIP Cloud server."""
class HmipcRegistrationFailed(HmipcException): class HmipcRegistrationFailed(HmipcException):
"""Registration on HomematicIP cloud failed.""" """Registration on HomematicIP Cloud failed."""
class HmipcPressButton(HmipcException): class HmipcPressButton(HmipcException):

View file

@ -1,14 +1,13 @@
"""Accesspoint for the HomematicIP Cloud component.""" """Access point for the HomematicIP Cloud component."""
import asyncio import asyncio
import logging import logging
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import ( from .const import (
HMIPC_HAPID, HMIPC_AUTHTOKEN, HMIPC_PIN, HMIPC_NAME, COMPONENTS, HMIPC_AUTHTOKEN, HMIPC_HAPID, HMIPC_NAME, HMIPC_PIN)
COMPONENTS)
from .errors import HmipcConnectionError from .errors import HmipcConnectionError
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -74,10 +73,10 @@ class HomematicipAuth:
class HomematicipHAP: class HomematicipHAP:
"""Manages HomematicIP http and websocket connection.""" """Manages HomematicIP HTTP and WebSocket connection."""
def __init__(self, hass, config_entry): def __init__(self, hass, config_entry):
"""Initialize HomematicIP cloud connection.""" """Initialize HomematicIP Cloud connection."""
self.hass = hass self.hass = hass
self.config_entry = config_entry self.config_entry = config_entry
self.home = None self.home = None
@ -100,7 +99,7 @@ class HomematicipHAP:
except HmipcConnectionError: except HmipcConnectionError:
retry_delay = 2 ** min(tries + 1, 6) retry_delay = 2 ** min(tries + 1, 6)
_LOGGER.error("Error connecting to HomematicIP with HAP %s. " _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) self.config_entry.data.get(HMIPC_HAPID), retry_delay)
async def retry_setup(_now): async def retry_setup(_now):
@ -113,7 +112,7 @@ class HomematicipHAP:
return False 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)) self.config_entry.data.get(HMIPC_HAPID))
for component in COMPONENTS: for component in COMPONENTS:
@ -127,7 +126,7 @@ class HomematicipHAP:
def async_update(self, *args, **kwargs): def async_update(self, *args, **kwargs):
"""Async update the home device. """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. There are several occasions for this event to happen.
We are only interested to check whether the access point We are only interested to check whether the access point
is still connected. If not, device state changes cannot is still connected. If not, device state changes cannot
@ -147,7 +146,7 @@ class HomematicipHAP:
job.add_done_callback(self.get_state_finished) job.add_done_callback(self.get_state_finished)
async def get_state(self): async def get_state(self):
"""Update hmip state and tell hass.""" """Update HMIP state and tell Home Assistant."""
await self.home.get_current_state() await self.home.get_current_state()
self.update_all() self.update_all()
@ -161,11 +160,11 @@ class HomematicipHAP:
# Somehow connection could not recover. Will disconnect and # Somehow connection could not recover. Will disconnect and
# so reconnect loop is taking over. # so reconnect loop is taking over.
_LOGGER.error( _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()) self.hass.async_add_job(self.home.disable_events())
def set_all_to_unavailable(self): 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: for device in self.home.devices:
device.unreach = True device.unreach = True
self.update_all() self.update_all()
@ -190,7 +189,7 @@ class HomematicipHAP:
return return
async def async_connect(self): async def async_connect(self):
"""Start websocket connection.""" """Start WebSocket connection."""
from homematicip.base.base_connection import HmipConnectionError from homematicip.base.base_connection import HmipConnectionError
tries = 0 tries = 0
@ -210,7 +209,7 @@ class HomematicipHAP:
tries += 1 tries += 1
retry_delay = 2 ** min(tries + 1, 6) retry_delay = 2 ** min(tries + 1, 6)
_LOGGER.error("Error connecting to HomematicIP with HAP %s. " _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) self.config_entry.data.get(HMIPC_HAPID), retry_delay)
try: try:
self._retry_task = self.hass.async_add_job(asyncio.sleep( self._retry_task = self.hass.async_add_job(asyncio.sleep(
@ -227,7 +226,7 @@ class HomematicipHAP:
if self._retry_task is not None: if self._retry_task is not None:
self._retry_task.cancel() self._retry_task.cancel()
self.home.disable_events() self.home.disable_events()
_LOGGER.info("Closed connection to HomematicIP cloud server.") _LOGGER.info("Closed connection to HomematicIP cloud server")
for component in COMPONENTS: for component in COMPONENTS:
await self.hass.config_entries.async_forward_entry_unload( await self.hass.config_entries.async_forward_entry_unload(
self.config_entry, component) self.config_entry, component)

View file

@ -3,16 +3,16 @@
"title": "HomematicIP Cloud", "title": "HomematicIP Cloud",
"step": { "step": {
"init": { "init": {
"title": "Pick HomematicIP Accesspoint", "title": "Pick HomematicIP Access point",
"data": { "data": {
"hapid": "Accesspoint ID (SGTIN)", "hapid": "Access point ID (SGTIN)",
"pin": "Pin Code (optional)", "pin": "Pin Code (optional)",
"name": "Name (optional, used as name prefix for all devices)" "name": "Name (optional, used as name prefix for all devices)"
} }
}, },
"link": { "link": {
"title": "Link Accesspoint", "title": "Link Access point",
"description": "Press the blue button on the accesspoint and the submit button to register HomematicIP with Home Assistant.\n\n![Location of button on bridge](/static/images/config_flows/config_homematicip_cloud.png)" "description": "Press the blue button on the access point and the submit button to register HomematicIP with Home Assistant.\n\n![Location of button on bridge](/static/images/config_flows/config_homematicip_cloud.png)"
} }
}, },
"error": { "error": {
@ -23,8 +23,8 @@
}, },
"abort": { "abort": {
"unknown": "Unknown error occurred.", "unknown": "Unknown error occurred.",
"conection_aborted": "Could not connect to HMIP server", "connection_aborted": "Could not connect to HMIP server",
"already_configured": "Accesspoint is already configured" "already_configured": "Access point is already configured"
} }
} }
} }

View file

@ -5,9 +5,10 @@ For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/light.homematic/ https://home-assistant.io/components/light.homematic/
""" """
import logging import logging
from homeassistant.components.homematic import ATTR_DISCOVER_DEVICES, HMDevice
from homeassistant.components.light import ( from homeassistant.components.light import (
ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light) ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light)
from homeassistant.components.homematic import HMDevice, ATTR_DISCOVER_DEVICES
from homeassistant.const import STATE_UNKNOWN from homeassistant.const import STATE_UNKNOWN
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View file

@ -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/ https://home-assistant.io/components/light.homematicip_cloud/
""" """
import logging import logging
from homeassistant.components.light import (
Light, ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS)
from homeassistant.components.homematicip_cloud import ( from homeassistant.components.homematicip_cloud import (
HomematicipGenericDevice, DOMAIN as HMIPC_DOMAIN, HMIPC_HAPID, HomematicipGenericDevice)
HMIPC_HAPID) from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
from homeassistant.components.light import (
ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light)
DEPENDENCIES = ['homematicip_cloud'] DEPENDENCIES = ['homematicip_cloud']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
ATTR_ENERGY_COUNTER = 'energy_counter_kwh'
ATTR_POWER_CONSUMPTION = 'power_consumption' ATTR_POWER_CONSUMPTION = 'power_consumption'
ATTR_ENERGIE_COUNTER = 'energie_counter_kwh'
ATTR_PROFILE_MODE = 'profile_mode' ATTR_PROFILE_MODE = 'profile_mode'
async def async_setup_platform(hass, config, async_add_devices, async def async_setup_platform(
discovery_info=None): hass, config, async_add_devices, discovery_info=None):
"""Old way of setting up HomematicIP lights.""" """Old way of setting up HomematicIP Cloud lights."""
pass pass
async def async_setup_entry(hass, config_entry, async_add_devices): async def async_setup_entry(hass, config_entry, async_add_devices):
"""Set up the HomematicIP lights from a config entry.""" """Set up the HomematicIP Cloud lights from a config entry."""
from homematicip.aio.device import ( from homematicip.aio.device import AsyncBrandSwitchMeasuring, AsyncDimmer
AsyncBrandSwitchMeasuring, AsyncDimmer)
home = hass.data[HMIPC_DOMAIN][config_entry.data[HMIPC_HAPID]].home home = hass.data[HMIPC_DOMAIN][config_entry.data[HMIPC_HAPID]].home
devices = [] devices = []
@ -46,7 +44,7 @@ async def async_setup_entry(hass, config_entry, async_add_devices):
class HomematicipLight(HomematicipGenericDevice, Light): class HomematicipLight(HomematicipGenericDevice, Light):
"""MomematicIP light device.""" """Representation of a HomematicIP Cloud light device."""
def __init__(self, home, device): def __init__(self, home, device):
"""Initialize the light device.""" """Initialize the light device."""
@ -67,7 +65,7 @@ class HomematicipLight(HomematicipGenericDevice, Light):
class HomematicipLightMeasuring(HomematicipLight): class HomematicipLightMeasuring(HomematicipLight):
"""MomematicIP measuring light device.""" """Representation of a HomematicIP Cloud measuring light device."""
@property @property
def device_state_attributes(self): def device_state_attributes(self):
@ -79,13 +77,13 @@ class HomematicipLightMeasuring(HomematicipLight):
round(self._device.currentPowerConsumption, 2) round(self._device.currentPowerConsumption, 2)
}) })
attr.update({ attr.update({
ATTR_ENERGIE_COUNTER: round(self._device.energyCounter, 2) ATTR_ENERGY_COUNTER: round(self._device.energyCounter, 2)
}) })
return attr return attr
class HomematicipDimmer(HomematicipGenericDevice, Light): class HomematicipDimmer(HomematicipGenericDevice, Light):
"""MomematicIP dimmer light device.""" """Representation of HomematicIP Cloud dimmer light device."""
def __init__(self, home, device): def __init__(self, home, device):
"""Initialize the dimmer light device.""" """Initialize the dimmer light device."""
@ -109,8 +107,7 @@ class HomematicipDimmer(HomematicipGenericDevice, Light):
async def async_turn_on(self, **kwargs): async def async_turn_on(self, **kwargs):
"""Turn the light on.""" """Turn the light on."""
if ATTR_BRIGHTNESS in kwargs: if ATTR_BRIGHTNESS in kwargs:
await self._device.set_dim_level( await self._device.set_dim_level(kwargs[ATTR_BRIGHTNESS]/255.0)
kwargs[ATTR_BRIGHTNESS]/255.0)
else: else:
await self._device.set_dim_level(1) await self._device.set_dim_level(1)

View file

@ -5,10 +5,10 @@ For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/lock.homematic/ https://home-assistant.io/components/lock.homematic/
""" """
import logging 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__) _LOGGER = logging.getLogger(__name__)

View file

@ -5,8 +5,9 @@ For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.homematic/ https://home-assistant.io/components/sensor.homematic/
""" """
import logging import logging
from homeassistant.components.homematic import ATTR_DISCOVER_DEVICES, HMDevice
from homeassistant.const import STATE_UNKNOWN from homeassistant.const import STATE_UNKNOWN
from homeassistant.components.homematic import HMDevice, ATTR_DISCOVER_DEVICES
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -70,7 +71,7 @@ HM_ICON_HA_CAST = {
def setup_platform(hass, config, add_devices, discovery_info=None): 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: if discovery_info is None:
return return
@ -83,7 +84,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class HMSensor(HMDevice): class HMSensor(HMDevice):
"""Represents various HomeMatic sensors in Home Assistant.""" """Representation of a HomeMatic sensor."""
@property @property
def state(self): def state(self):
@ -111,4 +112,4 @@ class HMSensor(HMDevice):
if self._state: if self._state:
self._data.update({self._state: STATE_UNKNOWN}) self._data.update({self._state: STATE_UNKNOWN})
else: else:
_LOGGER.critical("Can't initialize sensor %s", self._name) _LOGGER.critical("Unable to initialize sensor: %s", self._name)

View file

@ -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/ https://home-assistant.io/components/sensor.homematicip_cloud/
""" """
import logging import logging
from homeassistant.components.homematicip_cloud import ( from homeassistant.components.homematicip_cloud import (
HomematicipGenericDevice, DOMAIN as HMIPC_DOMAIN, HMIPC_HAPID, HomematicipGenericDevice)
HMIPC_HAPID) from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
from homeassistant.const import ( from homeassistant.const import (
TEMP_CELSIUS, DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_ILLUMINANCE, DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_ILLUMINANCE) TEMP_CELSIUS)
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -25,14 +24,14 @@ ATTR_TEMPERATURE_OFFSET = 'temperature_offset'
ATTR_HUMIDITY = 'humidity' ATTR_HUMIDITY = 'humidity'
async def async_setup_platform(hass, config, async_add_devices, async def async_setup_platform(
discovery_info=None): hass, config, async_add_devices, discovery_info=None):
"""Set up the HomematicIP sensors devices.""" """Set up the HomematicIP Cloud sensors devices."""
pass pass
async def async_setup_entry(hass, config_entry, async_add_devices): 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 ( from homematicip.device import (
HeatingThermostat, TemperatureHumiditySensorWithoutDisplay, HeatingThermostat, TemperatureHumiditySensorWithoutDisplay,
TemperatureHumiditySensorDisplay, MotionDetectorIndoor) TemperatureHumiditySensorDisplay, MotionDetectorIndoor)
@ -54,7 +53,7 @@ async def async_setup_entry(hass, config_entry, async_add_devices):
class HomematicipAccesspointStatus(HomematicipGenericDevice): class HomematicipAccesspointStatus(HomematicipGenericDevice):
"""Representation of an HomeMaticIP access point.""" """Representation of an HomeMaticIP Cloud access point."""
def __init__(self, home): def __init__(self, home):
"""Initialize access point device.""" """Initialize access point device."""
@ -82,7 +81,7 @@ class HomematicipAccesspointStatus(HomematicipGenericDevice):
class HomematicipHeatingThermostat(HomematicipGenericDevice): class HomematicipHeatingThermostat(HomematicipGenericDevice):
"""MomematicIP heating thermostat representation.""" """Represenation of a HomematicIP heating thermostat device."""
def __init__(self, home, device): def __init__(self, home, device):
"""Initialize heating thermostat device.""" """Initialize heating thermostat device."""
@ -115,7 +114,7 @@ class HomematicipHeatingThermostat(HomematicipGenericDevice):
class HomematicipHumiditySensor(HomematicipGenericDevice): class HomematicipHumiditySensor(HomematicipGenericDevice):
"""MomematicIP humidity device.""" """Represenation of a HomematicIP Cloud humidity device."""
def __init__(self, home, device): def __init__(self, home, device):
"""Initialize the thermometer device.""" """Initialize the thermometer device."""
@ -138,7 +137,7 @@ class HomematicipHumiditySensor(HomematicipGenericDevice):
class HomematicipTemperatureSensor(HomematicipGenericDevice): class HomematicipTemperatureSensor(HomematicipGenericDevice):
"""MomematicIP the thermometer device.""" """Representation of a HomematicIP Cloud thermometer device."""
def __init__(self, home, device): def __init__(self, home, device):
"""Initialize the thermometer device.""" """Initialize the thermometer device."""
@ -161,7 +160,7 @@ class HomematicipTemperatureSensor(HomematicipGenericDevice):
class HomematicipIlluminanceSensor(HomematicipGenericDevice): class HomematicipIlluminanceSensor(HomematicipGenericDevice):
"""MomematicIP the thermometer device.""" """Represenation of a HomematicIP Illuminance device."""
def __init__(self, home, device): def __init__(self, home, device):
"""Initialize the device.""" """Initialize the device."""

View file

@ -5,8 +5,9 @@ For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/switch.homematic/ https://home-assistant.io/components/switch.homematic/
""" """
import logging import logging
from homeassistant.components.homematic import ATTR_DISCOVER_DEVICES, HMDevice
from homeassistant.components.switch import SwitchDevice from homeassistant.components.switch import SwitchDevice
from homeassistant.components.homematic import HMDevice, ATTR_DISCOVER_DEVICES
from homeassistant.const import STATE_UNKNOWN from homeassistant.const import STATE_UNKNOWN
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View file

@ -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/ https://home-assistant.io/components/switch.homematicip_cloud/
""" """
import logging import logging
from homeassistant.components.switch import SwitchDevice
from homeassistant.components.homematicip_cloud import ( from homeassistant.components.homematicip_cloud import (
HomematicipGenericDevice, DOMAIN as HMIPC_DOMAIN, HMIPC_HAPID, HomematicipGenericDevice)
HMIPC_HAPID) from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
from homeassistant.components.switch import SwitchDevice
DEPENDENCIES = ['homematicip_cloud'] DEPENDENCIES = ['homematicip_cloud']
@ -21,17 +20,16 @@ ATTR_ENERGIE_COUNTER = 'energie_counter'
ATTR_PROFILE_MODE = 'profile_mode' ATTR_PROFILE_MODE = 'profile_mode'
async def async_setup_platform(hass, config, async_add_devices, async def async_setup_platform(
discovery_info=None): hass, config, async_add_devices, discovery_info=None):
"""Set up the HomematicIP switch devices.""" """Set up the HomematicIP Cloud switch devices."""
pass pass
async def async_setup_entry(hass, config_entry, async_add_devices): async def async_setup_entry(hass, config_entry, async_add_devices):
"""Set up the HomematicIP switch from a config entry.""" """Set up the HomematicIP switch from a config entry."""
from homematicip.device import ( from homematicip.device import (
PlugableSwitch, PlugableSwitchMeasuring, PlugableSwitch, PlugableSwitchMeasuring, BrandSwitchMeasuring)
BrandSwitchMeasuring)
home = hass.data[HMIPC_DOMAIN][config_entry.data[HMIPC_HAPID]].home home = hass.data[HMIPC_DOMAIN][config_entry.data[HMIPC_HAPID]].home
devices = [] devices = []
@ -51,7 +49,7 @@ async def async_setup_entry(hass, config_entry, async_add_devices):
class HomematicipSwitch(HomematicipGenericDevice, SwitchDevice): class HomematicipSwitch(HomematicipGenericDevice, SwitchDevice):
"""MomematicIP switch device.""" """representation of a HomematicIP Cloud switch device."""
def __init__(self, home, device): def __init__(self, home, device):
"""Initialize the switch device.""" """Initialize the switch device."""
@ -72,7 +70,7 @@ class HomematicipSwitch(HomematicipGenericDevice, SwitchDevice):
class HomematicipSwitchMeasuring(HomematicipSwitch): class HomematicipSwitchMeasuring(HomematicipSwitch):
"""MomematicIP measuring switch device.""" """Representation of a HomematicIP measuring switch device."""
@property @property
def current_power_w(self): def current_power_w(self):