Allowed values in interval steps for items/channel definition

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
      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?

How are you commanding these values within openHAB? If it’s a slider then you can specify the step size in the slider too.

Note that your Channel is a number, so only the increase/decrease commands will respect the step size:

For decrease, increase commands the step needs to be known

Yes, I found that. Thing is, I want to make sure, there’s no other value possible.

in my specific use case, I use a slider

value: oh-slider-card
  min: 10
  scaleSteps: 9
  max: 100
  releaseOnly: true
  scale: true
  step: 10
  label: false

But I also use amazonEchoControl for it

value: Shutter.RangeValue
  name: Ladelimit Ladestation
    - Close=10
    - Open=100
    - Lower=(-10)
    - Rais=(+10)
  description: Setze das Ladelimit für Ladestationen
  inverted: false
    - Closed=0:10
    - Open=1:100

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.

Minor, but does this typo (raise) matter?

1 Like

It does! :wink: thanks for your keen eyes.

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.

1 Like

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.