Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Home Connect integration #29214

Merged
merged 61 commits into from
May 5, 2020
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
95aca52
Initial commit for the Home Connect integrationq
DavidMStraub Nov 29, 2019
1156161
Necessary changes in global files
DavidMStraub Nov 29, 2019
ddb2492
Correct homeconnect version number
DavidMStraub Nov 29, 2019
d177e5f
Fix unit test for homeconnect config flow
DavidMStraub Nov 30, 2019
fca5e1e
Fix pylint error
DavidMStraub Nov 30, 2019
99fea5f
Fix failing unit test
DavidMStraub Nov 30, 2019
8ac3fdf
Correct documentation links
DavidMStraub Dec 1, 2019
9f96de5
Move import to top level
DavidMStraub Dec 1, 2019
7218095
Limit try to single line
DavidMStraub Dec 1, 2019
cbd8b75
Expand doc strings
DavidMStraub Dec 4, 2019
8f11c29
Move device list to ConfigEntryAuth property
DavidMStraub Dec 4, 2019
7071bbf
Include fix to on/off switch
DavidMStraub Dec 11, 2019
088e7d4
Bump homeconnect version to 0.3.2
DavidMStraub Jan 6, 2020
ce07c98
Use homeconnect 0.3.3
DavidMStraub Jan 6, 2020
0aad963
Move device initialization out of init
DavidMStraub Jan 6, 2020
61492c5
isort fixes
DavidMStraub Jan 6, 2020
5d31710
Bump homeconnect version in requirements*.txt
DavidMStraub Jan 6, 2020
5c46295
Additional coffee programs (https://github.com/DavidMStraub/homeassis…
DavidMStraub Feb 28, 2020
35e155d
Bump homeconnect dependency
DavidMStraub Feb 28, 2020
c36fd86
Fix codespell typos
DavidMStraub Feb 28, 2020
f4f0913
Get rid of format_key
DavidMStraub Feb 28, 2020
deff55f
Allow multiple config entries
DavidMStraub Feb 28, 2020
ef71535
Fix pylint error
DavidMStraub Feb 29, 2020
c77a194
Bump homeconnect to 0.5
DavidMStraub Apr 5, 2020
ffc555f
Convert elapsed/remaining time to timestamp sensors
DavidMStraub Apr 5, 2020
21c2131
Fix typo
DavidMStraub Apr 5, 2020
405ec7c
Fix sign error
DavidMStraub Apr 5, 2020
4c4c617
Fix JSON lint error
DavidMStraub Apr 6, 2020
9fe20db
Remove elapsed program time sensor, fix for remaining program time
DavidMStraub May 2, 2020
0efcdcb
Remove title from strings
DavidMStraub May 2, 2020
9823f24
Fix remaining program timestamp sensor
DavidMStraub May 2, 2020
c83072a
Minor changes
DavidMStraub May 2, 2020
e417c5a
Move HomeConnectEntity to separate module
DavidMStraub May 2, 2020
927ae8b
Remove state attributes
DavidMStraub May 2, 2020
43ffb1a
Make turn_on/off async
DavidMStraub May 2, 2020
80c3b5a
Put reused string constants into .const
DavidMStraub May 2, 2020
f7a4dac
Use dispatcher for updating entities
DavidMStraub May 2, 2020
45a0147
Update homeassistant/components/homeconnect/entity.py
DavidMStraub May 2, 2020
8c0ea15
Update homeassistant/components/homeconnect/entity.py
DavidMStraub May 2, 2020
fcb8e5e
Update homeassistant/components/homeconnect/entity.py
DavidMStraub May 2, 2020
eced930
Make door entity update async
DavidMStraub May 2, 2020
6d9d626
Do not use device name in unique ID
DavidMStraub May 3, 2020
6a93786
Rename power switch
DavidMStraub May 3, 2020
8bd0f01
Rename method
DavidMStraub May 4, 2020
266a0c4
Capitalize class attribute
DavidMStraub May 4, 2020
9e7151e
Use BinarySensorEntity
DavidMStraub May 4, 2020
53524c6
Explicit None not needed
DavidMStraub May 4, 2020
697cd0e
Unneeded decorator
DavidMStraub May 4, 2020
cc29353
Rename integration to home_connect
DavidMStraub May 4, 2020
105fc02
Use isoformat for timestamp sensor
DavidMStraub May 4, 2020
658b036
Remove unneeded DEPENDENCIES
DavidMStraub May 4, 2020
164b7a7
Do not store entities on device
DavidMStraub May 4, 2020
3cb95c0
Update requirements_test_all.txt
DavidMStraub May 4, 2020
36a0af8
Rename also test directory
DavidMStraub May 4, 2020
338c50e
Typo
DavidMStraub May 4, 2020
a6cd1f4
Update homeassistant/components/home_connect/sensor.py
DavidMStraub May 5, 2020
9acc067
Update homeassistant/components/home_connect/switch.py
DavidMStraub May 5, 2020
0b656f6
Update homeassistant/components/home_connect/switch.py
DavidMStraub May 5, 2020
875ef66
Update homeassistant/components/home_connect/switch.py
DavidMStraub May 5, 2020
02a9045
Update homeassistant/components/home_connect/switch.py
DavidMStraub May 5, 2020
eefd0c5
Make update methods async
DavidMStraub May 5, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ omit =
homeassistant/components/hitron_coda/device_tracker.py
homeassistant/components/hive/*
homeassistant/components/hlk_sw16/*
homeassistant/components/home_connect/*
homeassistant/components/homematic/*
homeassistant/components/homematic/climate.py
homeassistant/components/homematic/cover.py
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ homeassistant/components/hikvisioncam/* @fbradyirl
homeassistant/components/hisense_aehw4a1/* @bannhead
homeassistant/components/history/* @home-assistant/core
homeassistant/components/hive/* @Rendili @KJonline
homeassistant/components/home_connect/* @DavidMStraub
homeassistant/components/homeassistant/* @home-assistant/core
homeassistant/components/homekit/* @bdraco
homeassistant/components/homekit_controller/* @Jc2k
Expand Down
106 changes: 106 additions & 0 deletions homeassistant/components/home_connect/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
"""Support for BSH Home Connect appliances."""

import asyncio
from datetime import timedelta
import logging

from requests import HTTPError
import voluptuous as vol

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_entry_oauth2_flow, config_validation as cv
from homeassistant.util import Throttle

from . import api, config_flow
from .const import DOMAIN, OAUTH2_AUTHORIZE, OAUTH2_TOKEN

_LOGGER = logging.getLogger(__name__)

SCAN_INTERVAL = timedelta(minutes=1)

CONFIG_SCHEMA = vol.Schema(
{
DOMAIN: vol.Schema(
{
vol.Required(CONF_CLIENT_ID): cv.string,
vol.Required(CONF_CLIENT_SECRET): cv.string,
}
)
},
extra=vol.ALLOW_EXTRA,
)

PLATFORMS = ["binary_sensor", "sensor", "switch"]


async def async_setup(hass: HomeAssistant, config: dict) -> bool:
"""Set up Home Connect component."""
hass.data[DOMAIN] = {}

if DOMAIN not in config:
return True

config_flow.OAuth2FlowHandler.async_register_implementation(
hass,
config_entry_oauth2_flow.LocalOAuth2Implementation(
hass,
DOMAIN,
config[DOMAIN][CONF_CLIENT_ID],
config[DOMAIN][CONF_CLIENT_SECRET],
OAUTH2_AUTHORIZE,
OAUTH2_TOKEN,
),
)

return True


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Home Connect from a config entry."""
implementation = await config_entry_oauth2_flow.async_get_config_entry_implementation(
hass, entry
)

hc_api = api.ConfigEntryAuth(hass, entry, implementation)

hass.data[DOMAIN][entry.entry_id] = hc_api

await update_all_devices(hass, entry)

for component in PLATFORMS:
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component)
)

return True


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in PLATFORMS
]
)
)
if unload_ok:
hass.data[DOMAIN].pop(entry.entry_id)

return unload_ok


@Throttle(SCAN_INTERVAL)
async def update_all_devices(hass, entry):
"""Update all the devices."""
data = hass.data[DOMAIN]
hc_api = data[entry.entry_id]
try:
await hass.async_add_executor_job(hc_api.get_devices)
for device_dict in hc_api.devices:
await hass.async_add_executor_job(device_dict["device"].initialize)
except HTTPError as err:
_LOGGER.warning("Cannot update devices: %s", err.response.status_code)
Loading