Clean up kmtronic (#47537)
parent
07fd1b3b43
commit
13d4d7039e
|
@ -10,20 +10,12 @@ from pykmtronic.hub import KMTronicHubAPI
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigEntryNotReady
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
||||
from .const import (
|
||||
CONF_HOSTNAME,
|
||||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
DATA_COORDINATOR,
|
||||
DATA_HOST,
|
||||
DATA_HUB,
|
||||
DOMAIN,
|
||||
MANUFACTURER,
|
||||
)
|
||||
from .const import DATA_COORDINATOR, DATA_HOST, DATA_HUB, DOMAIN, MANUFACTURER
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema({DOMAIN: vol.Schema({})}, extra=vol.ALLOW_EXTRA)
|
||||
|
||||
|
@ -41,11 +33,10 @@ async def async_setup(hass: HomeAssistant, config: dict):
|
|||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||
"""Set up kmtronic from a config entry."""
|
||||
|
||||
session = aiohttp_client.async_get_clientsession(hass)
|
||||
auth = Auth(
|
||||
session,
|
||||
f"http://{entry.data[CONF_HOSTNAME]}",
|
||||
f"http://{entry.data[CONF_HOST]}",
|
||||
entry.data[CONF_USERNAME],
|
||||
entry.data[CONF_PASSWORD],
|
||||
)
|
||||
|
|
|
@ -7,23 +7,22 @@ from pykmtronic.hub import KMTronicHubAPI
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries, core, exceptions
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
|
||||
from .const import CONF_HOSTNAME, CONF_PASSWORD, CONF_USERNAME
|
||||
from .const import DOMAIN # pylint:disable=unused-import
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DATA_SCHEMA = vol.Schema({CONF_HOSTNAME: str, CONF_USERNAME: str, CONF_PASSWORD: str})
|
||||
DATA_SCHEMA = vol.Schema({CONF_HOST: str, CONF_USERNAME: str, CONF_PASSWORD: str})
|
||||
|
||||
|
||||
async def validate_input(hass: core.HomeAssistant, data):
|
||||
"""Validate the user input allows us to connect."""
|
||||
|
||||
session = aiohttp_client.async_get_clientsession(hass)
|
||||
auth = Auth(
|
||||
session,
|
||||
f"http://{data[CONF_HOSTNAME]}",
|
||||
f"http://{data[CONF_HOST]}",
|
||||
data[CONF_USERNAME],
|
||||
data[CONF_PASSWORD],
|
||||
)
|
||||
|
|
|
@ -2,10 +2,6 @@
|
|||
|
||||
DOMAIN = "kmtronic"
|
||||
|
||||
CONF_HOSTNAME = "host"
|
||||
CONF_USERNAME = "username"
|
||||
CONF_PASSWORD = "password"
|
||||
|
||||
DATA_HUB = "hub"
|
||||
DATA_HOST = "host"
|
||||
DATA_COORDINATOR = "coordinator"
|
||||
|
@ -13,4 +9,3 @@ DATA_COORDINATOR = "coordinator"
|
|||
MANUFACTURER = "KMtronic"
|
||||
ATTR_MANUFACTURER = "manufacturer"
|
||||
ATTR_IDENTIFIERS = "identifiers"
|
||||
ATTR_NAME = "name"
|
||||
|
|
Loading…
Reference in New Issue