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

1 Like

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

1 Like

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