Modbus writing (int16 format, value0)

Hello community.

I have created widget (OpenHAB 3) and there is the button for mode selection. When I click on it, writing of value 0 to appropriate register should be done. Widget fragment:

      - component: oh-button
        config:
          text: Switched Off
          outline: true
          action: command
          actionItem: =props.item
          actionCommand: 0
          actionCommandAlt: 0
          color-theme: blue
          active: "=(items[props.item].state == 0) ? true : false"
          style:
            width: 250px
            margin-bottom: 5px
            margin-up: 5px
            margin-right: 5px

After button clicking writing didn’t execute. But I have other button (other mode activation and writing other value - 1). There are no problems with writing number 1.

thing configuration of register:
Thing data Holding108 [ readStart=“108”, readValueType=“int16”, writeStart=“108”, writeValueType=“int16”, writeType=“holding”, updateUnchangedValuesEveryMillis=50000 ]

configuration of item:
Number test_mode_sel “Mode selection” [“Setpoint”] { channel=“modbus:data:localhostTCP:Holdings10:Holding108:number” }

Thus. I cannot only write value 0, with other values (1, 2, 3, 4) I have no problems with writing.

It seems to me the problem is with widget, because I can do it (write 0 value) via others OH visualisations (OpenHAB BasicUI).

Any ideas ?

So, you can forget the Modbus stuff altogether, and concentrate on what command gets sent to your Item from the UI.
You can see that in your events.log or developer sidebar.
What do you see? What is the pre-existing state of the Item?

I did’t see any useful information in events.log or developer sidebar. It seems to me OpenHAB system “does not see” button click when “actionCommand: 0”.

All widget code is listed below:

uid: selection_test
tags: []
props:
  parameters:
    - context: item
      description: heating pump mode
      label: Item
      name: item
      required: true
      groupName: general
  parameterGroups:
    - name: general
      label: Display options
timestamp: May 14, 2021, 7:43:01 PM
component: f7-card
config:
  title: "Heating pump mode:"
slots:
  default:
    - component: f7-block
      config:
        class: bog
        style:
          display: flex
          flex-wrap: wrap
          justify-content: center
          align-content: space-between
          padding: 5px
      slots:
        default:
          - component: oh-button
            config:
              text: Switched Off
              outline: true
              action: command
              actionItem: =props.item
              actionCommand: 0
              actionCommandAlt: 0
              color-theme: blue
              active: "=(items[props.item].state == 0) ? true : false"
              style:
                width: 250px
                margin-bottom: 5px
                margin-up: 5px
                margin-right: 5px
          - component: oh-button
            config:
              text: Heating
              outline: true
              action: command
              actionItem: =props.item
              actionCommand: 2
              actionCommandAlt: 2
              color-theme: blue
              active: "=(items[props.item].state == 2) ? true : false"
              style:
                width: 250px
                margin-bottom: 5px
                margin-up: 5px
                margin-right: 5px
          - component: oh-button
            config:
              text: Cooling
              outline: true
              action: command
              actionItem: =props.item
              actionCommand: 3
              actionCommandAlt: 3
              color-theme: blue
              active: "=(items[props.item].state == 3) ? true : false"
              style:
                width: 250px
                margin-bottom: 5px
                margin-up: 5px
                margin-right: 5px
          - component: oh-button
            config:
              text: Defrost
              outline: true
              action: command
              actionItem: =props.item
              actionCommand: 4
              actionCommandAlt: 4
              color-theme: blue
              active: "=(items[props.item].state == 4) ? true : false"
              style:
                width: 250px
                margin-bottom: 5px
                margin-up: 5px
                margin-right: 5px

If I change value 0 to value 1 in first oh-button block, all work good, but when value 0 is actual (as in code above), command did’t execute.

Please use code fences to make your post read easier…

Done

I suspect that the YAML parser is interpreting actionCommand: 0 as a false value (i.e., one to ignore). The command action is probably smart enough to properly convert types if you use actionCommand: "0" instead.

Yes, it is. I changed <actionCommand: 0> with <actionCommand: “0”> and now it works. Thank you for your help.