lockEditing not working when setting it via console

Hello,

I tried to set the lockEditing config property via the console instead of the PaperUI. (I don’t use PaperUI because all the config is held in a git repository)

I performed the following commands to set the value:

config:edit org.openhab.habpanel
config:property-set lockEditing true
config:update

Unfortunatly the editing elements are still visible at HABpanel. For experimental reasons I also installed PaperUI and had a look at the setting via the GUI. It’s shown as enabled. If I just disable and enable it via the GUI the editing elements are gone. The configuration looks the same. Is there a difference between editing the configuration via PaperUI and console?

Thank you in advance.

Thomas

Hi, I can reproduce this, took me a while to understand what’s going on… if you retrieve the config using the API afterwards you’ll see:

"lockEditing": "true"

(a string value)
where it should be:

"lockEditing": true

(a boolean value)

I checked the Karaf docs and haven’t seen a way to explicitely set boolean values :disappointed:

I ran into this same problem when wanting to run OH with only the HabPanel ui installed and with editing disabled. I ended up having to (temporarily) install Paper so I could determine how it behaved differently than the console. Here are my findings:

HabPanel UI

HabPanel is fed its configuration from the following file:

$USERDATA/config/org/openhab/habpanel.config

The correct property for locking the editor is:

lockEditing=B"true"

NOTE: The 'B' - This is how the value is determined to be a json boolean (true) vs a string ("true")

Paper UI

Paper UI’s HabPanel configuration updates habpanel.config directly, and with the appropriate B prefix

Console

Although config:edit org.openhab.habpanel can read settings from habpanel.config, config:update actually writes the configuration (even if no modifications are made) to a different file:

$USERDATA/etc/org.openhab.habpanel.cfg

This file stores data in a different format. The edit locking configuration is stored as:

lockEditing = true

The data in this new file is then re-synced over to original habpanel.config

NOTE: The following property is also added to habpanel.config :

felix.fileinstall.filename="file:/$USERDATA/etc/org.openhab.habpanel.cfg"

I’m guessing this is related to the process that does the syncing, marking the file as being derived by habpanel.cfg

NOTE: You can no longer make changes to habpanel.config It is always resynced from habpanel.cfg so any changes will be overridden (well, see below)

The Bug

Now to the bug. The reason the console change doesn’t work is because the process that does the syncing codes booleans incorrectly. Here’s what the value looks like after updating from the console:

lockEditing="true"

This ends up being sent to the HabPanel UI as string "true" instead of boolean true.

The Quick Fix

Until the syncing process is fixed to properly encode booleans, you can manually fix this as follows:

  1. Stop OpenHab
  2. Remove the habpanel.cfg file
  3. Remove the felix.fileinstall.filename property from habpanel.config
  4. Set the lockEditing property to either B"true" or B"false"
  5. Restart OpenHab

I tested this multiple times before posting. Let me know if it helps you.

I’ll also try to submit a ticket sometime soon and maybe even dive into the code and see if I help find a solution.

Just thinking out loud: Although the syncing technique is broken, a quick look into the habpanel github suggests the field is only used by the front-end browser code. A quick fix could be to let the code be more relaxed and cast a string to boolean …

1 Like