Clean up kmtronic (#47537)

pull/47567/head
tkdrob 2021-03-07 08:15:43 -05:00 committed by GitHub
parent 07fd1b3b43
commit 13d4d7039e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 21 deletions

View File

@ -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],
)

View File

@ -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],
)

View File

@ -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"