Is there a built-in definition for values for a items, wich only allow inputs in interval steps, like percentage only in 10%-steps: 10-20-30-40-50-60-70-80-90-100?
I’d like to send only values in 10-step via MQTT. So I configured the MQTT-channel:
- id: cmdSetChargingLimitAC
channelTypeUID: mqtt:number
label: cmdSetChargingLimitAC
description: Ladelimit AC
configuration:
min: 10
max: 100
qos: 2
commandTopic: openHAB/master/Kia/cmdSetChargingLimitAC
step: 10
off: OFF
on: ON
But I could send values outside of this:
2022-01-27 09:52:38.589 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'MQTTKia_cmdSetChargingLimitAC' received command 5
2022-01-27 09:52:38.591 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'MQTTKia_cmdSetChargingLimitAC' predicted to become 5
2022-01-27 09:52:38.596 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'MQTTKia_cmdSetChargingLimitAC' changed from 90 to 5
Is there a ootb-way to make sure, the value is only send in 10-intervals?
And there I could say: “Alexa, set Charging Limit Wallbox to 55 percent” → and that would lead to an error in the end, as the car only accepts 10-interval steps:
2022-01-27 10:40:36.753 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'MQTTKia_cmdSetChargingLimitDC' received command 55
2022-01-27 10:40:36.755 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'MQTTKia_cmdSetChargingLimitDC' predicted to become 55
2022-01-27 10:40:36.763 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'MQTTKia_cmdSetChargingLimitDC' changed from NULL to 55
of course, this is an edge-case, but nevertheless I’m curious on how to approach this.
OK, understood. Not sure there is a simple way, other than processing everything through a rule first, or maybe a JS transform on the way out of the Channel.
hmm… yes, I think, that’ll do the trick adding some round() in the channel, the item will stay “false”, but at least the intention will work with the endpoint.
You can set supportedRange=10:100:10 with the last value being the precision to achieve what you want on the Alexa side. Also, you can set the Closed state mapping to just 10.
Alternatively, the skill automatically populates the supported range values if it is configured in the state description of a given item.