1
mirror of https://github.com/home-assistant/core synced 2024-08-02 23:40:32 +02:00
ha-core/homeassistant/components/plum_lightpad/utils.py
Eugene Prystupa e3b90ea3f7
Add Plum Lightpad config flow (#36802)
* add support for config flow for Plum Lightpad integration

* add support for config flow for Plum Lightpad integration (remove unintended change to requirements_test_all.txt)

* add support for config flow for Plum Lightpad integration (fix lint issues)

* add support for config flow for Plum Lightpad integration (PR feedback)

* add support for config flow for Plum Lightpad integration (fix lint)

* Update homeassistant/components/plum_lightpad/__init__.py

use debug instead of info for logging

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

* Update homeassistant/components/plum_lightpad/strings.json

switch to use generated references instead of hard-coded strings

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

* Update homeassistant/components/plum_lightpad/strings.json

switch to use references instead of hard-coded string

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

* Update homeassistant/components/plum_lightpad/strings.json

removing translated title per suggestion

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

* Update homeassistant/components/plum_lightpad/strings.json

removing per suggestion

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

* remove unnecessary deepcopy

* remove unnecessary logging warning, since ignoring is expected for configuration.yaml scenario

* switch to hass.loop.create_task per PR feedback

* show login errors when configuring integration via UI (PR feedback)

* disable wrongly flag pylint violation

* add except handler to handle connection errors when setting up config flow entry

* address PR feedback regarding exception handling

* Update homeassistant/components/plum_lightpad/config_flow.py

use helper instead of custom code/message-id

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-06-23 20:40:11 -07:00

15 lines
539 B
Python

"""Reusable utilities for the Plum Lightpad component."""
from plumlightpad import Plum
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
async def load_plum(username: str, password: str, hass: HomeAssistant) -> Plum:
"""Initialize Plum Lightpad API and load metadata stored in the cloud."""
plum = Plum(username, password)
cloud_web_session = async_get_clientsession(hass, verify_ssl=True)
await plum.loadCloudData(cloud_web_session)
return plum