Custom Off/Closed Value: multiple values

Running OH4.2.1-release on openHABian.

my Nuki smartlock has three states:

  • unlocked
  • unlatched
  • locked

The first two should result in a “door locked”: ON State, the last in a “door locked”: OFF.

I tried an enum as config:

  - id: lockState
    channelTypeUID: mqtt:switch
    label: Smartlock Status
    description: Status Nuki Smartlock
    configuration:
      stateTopic: devices/NukiHub/lock/state
      off: "[unlocked, unlatched]"
      on: locked

but results in:

2024-09-12 09:34:08.641 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command 'unlatched' from channel 'mqtt:topic:synology:nukiHub:lockState' not supported by type 'OnOffValue': No enum constant org.openhab.core.library.types.OnOffType.unlatched

or is it simply not possible to add more than one “condition” :wink:

I use profile ‚map‘ for this. The Window sensor just sends numbers.

5632=offen
22=offen
23=zu

Try this:

      off: [unlocked, unlatched]

I’m using UI-configuration. and regardless if I insert the enum in the “configure Channel” dialogue or directly in code - afters “Save”-ing the quotes are added.

that’s a good idea for item values, for my use case this would be enough. thanks!
I’d still like to know, if there’s a possibility to throw in multiple values for additional ON/OFF configuration! :wink:

Try this then (with proper indentation):

off:
  - unlocked
  - unlatched
``

funnily enough, if I save this in the “code”-section, it will automagically change into:

  - id: lockState
    channelTypeUID: mqtt:switch
    label: Smartlock Status
    description: Status Nuki Smartlock
    configuration:
      stateTopic: devices/NukiHub/lock/state
      off: "[unlocked, unlatched]"
      on: locked

and thus resulting into:

2024-09-13 11:13:57.704 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command 'unlatched' from channel 'mqtt:topic:synology:nukiHub:lockState' not supported by type 'OnOffValue': No enum constant org.openhab.core.library.types.OnOffType.unlatched

is this considered a bug then?

Hmm I think using array hasn’t yet been fully implemented, sorry. Hopefully it’ll make it into 4.3

ok. Thanks for the help, I can wait. “Unlatch” is not a really long state, as it only applies to like 3secs. My inner Monk™ desires to reduce WARNings and be as smooth as possible! :wink:

There’s an open PR for this actually [mqtt] Support multiple, comma-separated values for on/off param of switch/contact channels by florian-h05 · Pull Request #17242 · openhab/openhab-addons · GitHub

cool, I’ll mark this as solution then in expection it’ll go live in an upcoming release!

bringing it up again with 4.3.2:

2025-01-13 15:24:22.617 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command 'unlatch' from channel 'mqtt:topic:synology:nukiHub:lockState' not supported by type 'OnOffValue': No enum constant org.openhab.core.library.types.OnOffType.unlatch

my channel is:

  - id: lockState
    channelTypeUID: mqtt:switch
    label: Smartlock Status
    description: Status Nuki Smartlock
    configuration:
      stateTopic: devices/NukiHub/lock/state
      off: unlocked
      on: [unlocked, unlatched, stateUnknown]

was the PR declined? don’t know how the branches are organized, but one got deleted?

The PR was closed. I’ll try to create a new PR in the next few weeks. I’m a bit uncertain about it though.

Right now it’s quite nice with

on: something
off: somethingelse

If they’re to be changed into arrays:

on:
  - something
off:
  - somethingelse

In other words, even with just one value, it’ll still need to be defined as a list.

@binderth to solve your need using the current version, why don’t you use transformationPattern with a MAP transform. You can even do it inline now in 4.3.x. You can use file based map (or managed map transform) in 4.2.x I think.

- id: lockState
    channelTypeUID: mqtt:switch
    label: Smartlock Status
    description: Status Nuki Smartlock
    configuration:
      stateTopic: devices/NukiHub/lock/state
      transformationPattern: "MAP(|unlocked=OFF;unlatched=OFF;locked=ON)"

If you want to use a MAP file:

unlocked=OFF
unlatched=OFF
locked=ON