Virtual Switch with 3 states in OpenHAB 3

Hello,

I have created a virtual switch with 3 states (“on”, “off”, “additional interaction”) as a settings menu in OpenHAB 3. But when clicked in the MainUI it doesn’t work and I get the following Error: [ERROR] [org.apache.cxf.jaxrs.utils.JAXRSUtils] - No message body reader has been found for class java.lang.String, ContentType: application/octet-stream

Can someone explain to me, how to fix this?

//items

Number adlSetting "ADL Setting"
Switch adlSwitch "ADL Switch"
Switch amazonEcho "Amazon Echo"

//sitemap

Switch item=adlSetting icon="smiley" mappings=[ 0="On", 1="Additional interaction", 2="Off" ]
Switch item=amazonEcho icon="microphone"
Switch item=adlSwitch icon="smiley"

//rules

rule "Abfrage ADL Status"
    when
        Item adlSetting received update
    then
        if (adlSetting.state == 0){
            adlSwitch.sendCommand(ON)
            amazonEcho.sendCommand(OFF)
        } else if (adlSetting.state == 2){
            adlSwitch.sendCommand(OFF)
            amazonEcho.sendCommand(OFF)
        } else {
            amazonEcho.sendCommand(ON)
        }

end

A switch in typical use cases is ON or OFF, have you tried using a string item?

Using a Number as a multi way switch is fine, common practice.

When what is clicked?

You’ve used your sitemap to make your Number look like a multi way switch for other UIs. Does that work, have you tried in BasicUI?

But MainUI takes no notice of sitemaps. You’d need to fiddle with Item metadata to fool MainUI to treat it like a switch.
See

For the rule, you would generally trigger from received command if it is supposed to respond to UI clicks.

I have seen the entry you linked and created a widget in my MainUI so that I can click “Buttons” on my created page.

uid: 3-way-switch
tags: []
props:
  parameters:
    - description: ADL Setting
      label: adlSetting
      name: ADL Setting
      required: false
      type: TEXT
    - context: adlSetting
      description: An item to control
      label: adlSetting
      name: ADL Setting
      required: false
      type: TEXT
  parameterGroups: []
timestamp: Apr 15, 2021, 12:35:30 PM
component: oh-list-item
config:
  icon: f7:gear_alt
  title: ADL Setting
slots:
  after:
    - component: f7-block
      config:
        style:
          margin-top: 0px
      slots:
        default:
          - component: f7-segmented
            config:
              raisedAurora: true
              style:
                min-width: 150px
            slots:
              default:
                - component: oh-button
                  config:
                    action: command
                    actionItem: =props.item
                    actionCommand: 0
                    text: On
                - component: oh-button
                  config:
                    action: command
                    actionItem: =props.item
                    actionCommand: 1
                    text: Additional interaction
                - component: oh-button
                  config:
                    action: command
                    actionItem: =props.item
                    actionCommand: 2
                    text: Off

When one of the three options is clicked I receive the error that I described in the original post in my log.

The message isn’t very helpful about telling you where it came from. Often it’s about some external script.
Try disabling/removing the rule, so that thetarget Item doesn’t interact with anything else. What does your events.log tell you arrives at this Item?
You didn’t answer if you tried with your sitemap and BasicUI, what results there.

Okay you’re right. I forgot to test it in the BasicUI. There the rule is working.

Thank you!

I will try to find a solution that works in the MainUI too, but for now the BasicUI is all I need.

Okay, so that seems to show it’s UI related. In some circumstances I think this message can arise if an Item is say NULL state to begin with.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.