Channel made Switch Item read only in the UI

Hi All,

I am linking a Switch item to my DSC partition channel, in my OH3 setup. After doing so, there is no longer a switch toggle in the item UI?

Here is the Channel:

It make sense that it’s read only in this application. However, I would like to test out some rules based on this item. So without the ability to manually setting it, it would be difficult to test rules.

The only way it seems is to use API. As it shown on the second picture, I was able to manually set the state to ON via API.

Is there a way to manually disable this ready only and bring the toggle back temporarily?

Thanks,
Joe

On your Item:

  • Add Metadata
  • State Description
  • Read Only - switch off

It’s off, has always been off. First thing I checked.

Thanks,
Joe

Hmm. Maybe try turning out on, then back off to force it? What’s the YAML code for that Item’s metadata? Turning it on then back off should force readOnly: false in the YAML.

Hmmm, manually toggle it on and off again works. I deleted them item and tried again.

Newly linked item looks like:


value: ""
config: {}

After manually toggle on and off:

value: " "
config:
  readOnly: false

So, if by default if readOnly is not set, shouldn’t it be NOT read only?

At any rate it works now. Thank you!

Joe

What’s going on is the Binding gives hints that this Switch Item is read only. There is no way to override that default in MainUI. But there are several options you can use:

  1. Use the REST API, which you’ve already mentioned.

  2. Use the Karaf Console

  3. Use the --Scratchpad-- Script. From the Developer Sidebar (ALT-SHIFT-D or from the Developer Tools menu) bring up the third tab and click on “Open Scripting Scratchpad”. If it doesn’t already exist that will open a new Script called “–Scratchpad–” where you can enter and execute some Rules code. I find this particularly helpful when testing, especially complicated tests where more than one Item is involved.

  4. On the Item, define a new “default cell widget” and set an action to toggle the state of the Item when it’s clicked. Then in the Developer Sidebar go to the first column and search for your Item and pin it. When you click on the Item from there it will show the default card widget which will let you toggle the Item. (I’ve had this sometimes not work).

  5. On the Item, define a new “default stand alone widget” and select a toggle widget (or set an Action to toggle the Item on a label widget) and you can interact with the Item at the top of the Item’s page.

I mainly list these as knowing all the ways you can interact with Items while testing can be very useful in different circumstances.

The binding is saying it’s read only so that becomes the default for that Item. You need to override that default. It might be worth filing a bug report as you shouldn’t have to toggle it to get the metadata to override the default. Just setting the metadata to what you want should be sufficient.

Thanks @rlkoshak . The behaviour matches what you described, so I guess it’s not a bug.

Joe

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