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
@@ -2,18 +2,22 @@
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import CONF_ADDRESS, CONF_NAME, CONF_TYPE
|
||||
from homeassistant.const import CONF_NAME, CONF_TYPE
|
||||
from homeassistant.core import callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
from . import ATTR_DISCOVER_DEVICES, DATA_KNX
|
||||
|
||||
CONF_STATE_ADDRESS = 'state_address'
|
||||
CONF_SYNC_STATE = 'sync_state'
|
||||
DEFAULT_NAME = 'KNX Sensor'
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_ADDRESS): cv.string,
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
vol.Optional(CONF_TYPE): cv.string,
|
||||
vol.Optional(CONF_SYNC_STATE, default=True): cv.boolean,
|
||||
vol.Required(CONF_STATE_ADDRESS): cv.string,
|
||||
vol.Required(CONF_TYPE): cv.string,
|
||||
})
|
||||
|
||||
|
||||
@@ -42,9 +46,10 @@ def async_add_entities_config(hass, config, async_add_entities):
|
||||
import xknx
|
||||
sensor = xknx.devices.Sensor(
|
||||
hass.data[DATA_KNX].xknx,
|
||||
name=config.get(CONF_NAME),
|
||||
group_address=config.get(CONF_ADDRESS),
|
||||
value_type=config.get(CONF_TYPE))
|
||||
name=config[CONF_NAME],
|
||||
group_address_state=config[CONF_STATE_ADDRESS],
|
||||
sync_state=config[CONF_SYNC_STATE],
|
||||
value_type=config[CONF_TYPE])
|
||||
hass.data[DATA_KNX].xknx.devices.add(sensor)
|
||||
async_add_entities([KNXSensor(sensor)])
|
||||
|
||||
@@ -93,6 +98,11 @@ class KNXSensor(Entity):
|
||||
"""Return the unit this state is expressed in."""
|
||||
return self.device.unit_of_measurement()
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
"""Return the device class of the sensor."""
|
||||
return self.device.ha_device_class()
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
|
||||
Reference in new issue
Block a user