* Remove unnecessary pylint exceptions
* Move up some change to binary_sensors and switch. Fix program d.s.a's.
* ISY994 Basic support for PyISYv2
- Bare minimum changes to be able to support PyISYv2.
- Renaming imports and functions to new names.
- Use necessary constants from module.
- **BREAKING CHANGE** Remove ISY Climate Module support.
- Climate module was retired on 3/30/2020: [UDI Annoucement](https://www.universal-devices.com/byebyeclimatemodule/)
- **BREAKING CHANGE** Device State Attributes use NodeProperty
- Some attributes names and types will have changed as part of the changes to PyISY. If a user relied on a device state attribute for a given entity, they should check that it is still there and formatted the same. In general, *more* state attributes should be getting picked up now that the underlying changes have been made.
- **BREAKING CHANGE** `isy994_control` event changes (using NodeProperty)
- Control events now return an object with additional information. Control events are now parsed to the friendly names and will need to be updated in automations.
Remove cast
* PyISY v2.0.2, add extra UOMs, omit EMPTY_TIME attributes
* Fix typo in function doc string.
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: J. Nick Koston <nick@koston.org>
111 lines
3.1 KiB
Python
111 lines
3.1 KiB
Python
"""Support the ISY-994 controllers."""
|
|
from urllib.parse import urlparse
|
|
|
|
from pyisy import ISY
|
|
import voluptuous as vol
|
|
|
|
from homeassistant.const import (
|
|
CONF_HOST,
|
|
CONF_PASSWORD,
|
|
CONF_USERNAME,
|
|
EVENT_HOMEASSISTANT_STOP,
|
|
)
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers import config_validation as cv, discovery
|
|
from homeassistant.helpers.typing import ConfigType
|
|
|
|
from .const import (
|
|
_LOGGER,
|
|
CONF_IGNORE_STRING,
|
|
CONF_SENSOR_STRING,
|
|
CONF_TLS_VER,
|
|
DEFAULT_IGNORE_STRING,
|
|
DEFAULT_SENSOR_STRING,
|
|
DOMAIN,
|
|
ISY994_NODES,
|
|
ISY994_PROGRAMS,
|
|
SUPPORTED_PLATFORMS,
|
|
SUPPORTED_PROGRAM_PLATFORMS,
|
|
)
|
|
from .helpers import _categorize_nodes, _categorize_programs
|
|
|
|
CONFIG_SCHEMA = vol.Schema(
|
|
{
|
|
DOMAIN: vol.Schema(
|
|
{
|
|
vol.Required(CONF_HOST): cv.url,
|
|
vol.Required(CONF_USERNAME): cv.string,
|
|
vol.Required(CONF_PASSWORD): cv.string,
|
|
vol.Optional(CONF_TLS_VER): vol.Coerce(float),
|
|
vol.Optional(
|
|
CONF_IGNORE_STRING, default=DEFAULT_IGNORE_STRING
|
|
): cv.string,
|
|
vol.Optional(
|
|
CONF_SENSOR_STRING, default=DEFAULT_SENSOR_STRING
|
|
): cv.string,
|
|
}
|
|
)
|
|
},
|
|
extra=vol.ALLOW_EXTRA,
|
|
)
|
|
|
|
|
|
def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|
"""Set up the ISY 994 platform."""
|
|
hass.data[ISY994_NODES] = {}
|
|
for platform in SUPPORTED_PLATFORMS:
|
|
hass.data[ISY994_NODES][platform] = []
|
|
|
|
hass.data[ISY994_PROGRAMS] = {}
|
|
for platform in SUPPORTED_PROGRAM_PLATFORMS:
|
|
hass.data[ISY994_PROGRAMS][platform] = []
|
|
|
|
isy_config = config.get(DOMAIN)
|
|
|
|
user = isy_config.get(CONF_USERNAME)
|
|
password = isy_config.get(CONF_PASSWORD)
|
|
tls_version = isy_config.get(CONF_TLS_VER)
|
|
host = urlparse(isy_config.get(CONF_HOST))
|
|
ignore_identifier = isy_config.get(CONF_IGNORE_STRING)
|
|
sensor_identifier = isy_config.get(CONF_SENSOR_STRING)
|
|
|
|
if host.scheme == "http":
|
|
https = False
|
|
port = host.port or 80
|
|
elif host.scheme == "https":
|
|
https = True
|
|
port = host.port or 443
|
|
else:
|
|
_LOGGER.error("isy994 host value in configuration is invalid")
|
|
return False
|
|
|
|
# Connect to ISY controller.
|
|
isy = ISY(
|
|
host.hostname,
|
|
port,
|
|
username=user,
|
|
password=password,
|
|
use_https=https,
|
|
tls_ver=tls_version,
|
|
log=_LOGGER,
|
|
)
|
|
if not isy.connected:
|
|
return False
|
|
|
|
_categorize_nodes(hass, isy.nodes, ignore_identifier, sensor_identifier)
|
|
_categorize_programs(hass, isy.programs)
|
|
|
|
def stop(event: object) -> None:
|
|
"""Stop ISY auto updates."""
|
|
isy.auto_update = False
|
|
|
|
# Listen for HA stop to disconnect.
|
|
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop)
|
|
|
|
# Load platforms for the devices in the ISY controller that we support.
|
|
for platform in SUPPORTED_PLATFORMS:
|
|
discovery.load_platform(hass, platform, DOMAIN, {}, config)
|
|
|
|
isy.auto_update = True
|
|
return True
|