Update KNX component to xknx 0.11 (#24738)
* update component for xknx 0.11.0 - expose sensor state is not casted to float anymore - climate mode operation list has no more None values - light supports white_value (rgbw) - sensor expects `group_address_state` now instead of `group_address` - sensor forwards device_class if available * update manifest to use xknx 0.11.0 * update requirements_all for xknx 0.11.0 * update for xknx 0.11.1 - require xknx 0.11.1 - use 'state_address' instead of 'address' in sensor and binary_sensor configuration - optional 'sync_state' for sensors and binary_sensors * remove questionable `del kwargs`
This commit is contained in:
1 parent
78a5dc71ac
commit
e299d7b3d6
11 files changed
+108
-66
No files matched your search
@@ -3,14 +3,16 @@ import voluptuous as vol
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
PLATFORM_SCHEMA, BinarySensorDevice)
|
||||
from homeassistant.const import CONF_ADDRESS, CONF_DEVICE_CLASS, CONF_NAME
|
||||
from homeassistant.const import CONF_DEVICE_CLASS, CONF_NAME
|
||||
from homeassistant.core import callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
from . import ATTR_DISCOVER_DEVICES, DATA_KNX, KNXAutomation
|
||||
|
||||
CONF_STATE_ADDRESS = 'state_address'
|
||||
CONF_SIGNIFICANT_BIT = 'significant_bit'
|
||||
CONF_DEFAULT_SIGNIFICANT_BIT = 1
|
||||
CONF_SYNC_STATE = 'sync_state'
|
||||
CONF_AUTOMATION = 'automation'
|
||||
CONF_HOOK = 'hook'
|
||||
CONF_DEFAULT_HOOK = 'on'
|
||||
@@ -31,11 +33,12 @@ AUTOMATION_SCHEMA = vol.Schema({
|
||||
AUTOMATIONS_SCHEMA = vol.All(cv.ensure_list, [AUTOMATION_SCHEMA])
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_ADDRESS): cv.string,
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
vol.Optional(CONF_DEVICE_CLASS): cv.string,
|
||||
vol.Optional(CONF_SIGNIFICANT_BIT, default=CONF_DEFAULT_SIGNIFICANT_BIT):
|
||||
cv.positive_int,
|
||||
vol.Optional(CONF_SYNC_STATE, default=True): cv.boolean,
|
||||
vol.Required(CONF_STATE_ADDRESS): cv.string,
|
||||
vol.Optional(CONF_DEVICE_CLASS): cv.string,
|
||||
vol.Optional(CONF_RESET_AFTER): cv.positive_int,
|
||||
vol.Optional(CONF_AUTOMATION): AUTOMATIONS_SCHEMA,
|
||||
})
|
||||
@@ -63,14 +66,15 @@ def async_add_entities_discovery(hass, discovery_info, async_add_entities):
|
||||
@callback
|
||||
def async_add_entities_config(hass, config, async_add_entities):
|
||||
"""Set up binary senor for KNX platform configured within platform."""
|
||||
name = config.get(CONF_NAME)
|
||||
name = config[CONF_NAME]
|
||||
import xknx
|
||||
binary_sensor = xknx.devices.BinarySensor(
|
||||
hass.data[DATA_KNX].xknx,
|
||||
name=name,
|
||||
group_address=config.get(CONF_ADDRESS),
|
||||
group_address_state=config[CONF_STATE_ADDRESS],
|
||||
sync_state=config[CONF_SYNC_STATE],
|
||||
device_class=config.get(CONF_DEVICE_CLASS),
|
||||
significant_bit=config.get(CONF_SIGNIFICANT_BIT),
|
||||
significant_bit=config[CONF_SIGNIFICANT_BIT],
|
||||
reset_after=config.get(CONF_RESET_AFTER))
|
||||
hass.data[DATA_KNX].xknx.devices.add(binary_sensor)
|
||||
|
||||
@@ -78,9 +82,9 @@ def async_add_entities_config(hass, config, async_add_entities):
|
||||
automations = config.get(CONF_AUTOMATION)
|
||||
if automations is not None:
|
||||
for automation in automations:
|
||||
counter = automation.get(CONF_COUNTER)
|
||||
hook = automation.get(CONF_HOOK)
|
||||
action = automation.get(CONF_ACTION)
|
||||
counter = automation[CONF_COUNTER]
|
||||
hook = automation[CONF_HOOK]
|
||||
action = automation[CONF_ACTION]
|
||||
entity.automations.append(KNXAutomation(
|
||||
hass=hass, device=binary_sensor, hook=hook,
|
||||
action=action, counter=counter))
|
||||
|
||||
Reference in new issue
Block a user