1 """Support for KNX/IP numeric values."""
3 from __future__
import annotations
5 from typing
import cast
8 from xknx.devices
import NumericValue
10 from homeassistant
import config_entries
25 from .
import KNXModule
26 from .const
import CONF_RESPOND_TO_READ, CONF_STATE_ADDRESS, KNX_ADDRESS, KNX_MODULE_KEY
27 from .entity
import KnxYamlEntity
28 from .schema
import NumberSchema
34 async_add_entities: AddEntitiesCallback,
36 """Set up number(s) for KNX platform."""
37 knx_module = hass.data[KNX_MODULE_KEY]
38 config: list[ConfigType] = knx_module.config_yaml[Platform.NUMBER]
44 """Return a KNX NumericValue to be used within XKNX."""
47 name=config[CONF_NAME],
48 group_address=config[KNX_ADDRESS],
49 group_address_state=config.get(CONF_STATE_ADDRESS),
50 respond_to_read=config[CONF_RESPOND_TO_READ],
51 value_type=config[CONF_TYPE],
56 """Representation of a KNX number."""
60 def __init__(self, knx_module: KNXModule, config: ConfigType) ->
None:
61 """Initialize a KNX number."""
63 knx_module=knx_module,
67 NumberSchema.CONF_MAX,
68 self.
_device_device.sensor_value.dpt_class.value_max,
71 NumberSchema.CONF_MIN,
72 self.
_device_device.sensor_value.dpt_class.value_min,
76 NumberSchema.CONF_STEP,
77 self.
_device_device.sensor_value.dpt_class.resolution,
85 """Restore last state."""
88 not self.
_device_device.sensor_value.readable
92 if last_state.state
not in (STATE_UNKNOWN, STATE_UNAVAILABLE):
93 self.
_device_device.sensor_value.value = last_number_data.native_value
97 """Return the entity value to represent the entity state."""
99 return cast(float, self.
_device_device.resolve_state())
103 await self.
_device_device.set(value)
_attr_native_unit_of_measurement
None __init__(self, KNXModule knx_module, ConfigType config)
None async_set_native_value(self, float value)
None async_added_to_hass(self)
str|None unit_of_measurement(self)
NumberExtraStoredData|None async_get_last_number_data(self)
State|None async_get_last_state(self)
None async_setup_entry(HomeAssistant hass, config_entries.ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
NumericValue _create_numeric_value(XKNX xknx, ConfigType config)