mirror of
https://github.com/home-assistant/core.git
synced 2025-08-04 13:15:18 +02:00
Move imports in luftdaten component (#27929)
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
"""Support for Luftdaten stations."""
|
"""Support for Luftdaten stations."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from luftdaten import Luftdaten
|
||||||
|
from luftdaten.exceptions import LuftdatenError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT
|
from homeassistant.config_entries import SOURCE_IMPORT
|
||||||
@@ -114,8 +116,6 @@ async def async_setup(hass, config):
|
|||||||
|
|
||||||
async def async_setup_entry(hass, config_entry):
|
async def async_setup_entry(hass, config_entry):
|
||||||
"""Set up Luftdaten as config entry."""
|
"""Set up Luftdaten as config entry."""
|
||||||
from luftdaten import Luftdaten
|
|
||||||
from luftdaten.exceptions import LuftdatenError
|
|
||||||
|
|
||||||
if not isinstance(config_entry.data[CONF_SENSOR_ID], int):
|
if not isinstance(config_entry.data[CONF_SENSOR_ID], int):
|
||||||
_async_fixup_sensor_id(hass, config_entry, config_entry.data[CONF_SENSOR_ID])
|
_async_fixup_sensor_id(hass, config_entry, config_entry.data[CONF_SENSOR_ID])
|
||||||
@@ -191,8 +191,6 @@ class LuftDatenData:
|
|||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Update sensor/binary sensor data."""
|
"""Update sensor/binary sensor data."""
|
||||||
from luftdaten.exceptions import LuftdatenError
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.client.get_data()
|
await self.client.get_data()
|
||||||
|
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
"""Config flow to configure the Luftdaten component."""
|
"""Config flow to configure the Luftdaten component."""
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
|
from luftdaten import Luftdaten
|
||||||
|
from luftdaten.exceptions import LuftdatenConnectionError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
@@ -60,7 +62,6 @@ class LuftDatenFlowHandler(config_entries.ConfigFlow):
|
|||||||
|
|
||||||
async def async_step_user(self, user_input=None):
|
async def async_step_user(self, user_input=None):
|
||||||
"""Handle the start of the config flow."""
|
"""Handle the start of the config flow."""
|
||||||
from luftdaten import Luftdaten, exceptions
|
|
||||||
|
|
||||||
if not user_input:
|
if not user_input:
|
||||||
return self._show_form()
|
return self._show_form()
|
||||||
@@ -75,7 +76,7 @@ class LuftDatenFlowHandler(config_entries.ConfigFlow):
|
|||||||
try:
|
try:
|
||||||
await luftdaten.get_data()
|
await luftdaten.get_data()
|
||||||
valid = await luftdaten.validate_sensor()
|
valid = await luftdaten.validate_sensor()
|
||||||
except exceptions.LuftdatenConnectionError:
|
except LuftdatenConnectionError:
|
||||||
return self._show_form({CONF_SENSOR_ID: "communication_error"})
|
return self._show_form({CONF_SENSOR_ID: "communication_error"})
|
||||||
|
|
||||||
if not valid:
|
if not valid:
|
||||||
|
Reference in New Issue
Block a user