Configuration meta data for 1.x bindings

Hi.

I tried to add the file ESH-INF/binding/binding.xml for my Powermax 1.x binding.
In my OH2 distro (downloaded the 26th of March), I uninstalled the Powermax bundle, then put my new compiled jar file in the addons directory and restarted OH. Then I discovered as expected in Paper UI / Configuration / Bindings a new entry foir my binding with two buttons “CONFIGURE” and “MORE”. Clicking on “MORE” delivers what is expected but when I click on “CONFIGURE”, nothing at all happens.

Here is my binding.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<binding:binding id="powermax" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:binding="http://eclipse.org/smarthome/schemas/binding/v1.0.0"
    xsi:schemaLocation="http://eclipse.org/smarthome/schemas/binding/v1.0.0 http://eclipse.org/smarthome/schemas/binding-1.0.0.xsd">

    <name>Visonic PowerMax Binding</name>
    <description>The Visonic PowerMax binding interfaces with Visonic PowerMax and PowerMaster alarm panel series.</description>
    <author>lolodomo</author>

    <config-description>
        <parameter name="serialPort" type="text" required="false">
            <context>network_address</context>
            <label>Serial port</label>
            <description>The serial port to use for connecting to the serial interface of the PowerMax alarm system e.g. COM1 for Windows and /dev/ttyS0 or /dev/ttyUSB0 for Linux.</description>
        </parameter>
        <parameter name="ip" type="text" required="false">
            <context>network_address</context>
            <label>IP address</label>
            <description>The IP address to use for connecting to the Ethernet interface of the PowerMax alarm system.</description>
        </parameter>
        <parameter name="tcpPort" type="integer" min="0" required="false">
            <label>TCP port</label>
            <description>The TCP port to use for connecting to the Ethernet interface of the PowerMax alarm system.</description>
        </parameter>
        <parameter name="motionOffDelay" type="integer" min="1" unit="min" required="false">
            <label>Motion reset delay</label>
            <description>The delay in minutes to reset a motion detection.</description>
            <default>3</default>
            <advanced>true</advanced>
        </parameter>
        <parameter name="allowArming" type="boolean" required="false">
            <label>Allow arming</label>
            <description>Enable or disable arming the PowerMax alarm system from openHAB.</description>
            <default>false</default>
            <advanced>true</advanced>
        </parameter>
        <parameter name="allowDisarming" type="boolean" required="false">
            <label>Allow disarming</label>
            <description>Enable or disable disarming the PowerMax alarm system from openHAB.</description>
            <default>false</default>
            <advanced>true</advanced>
        </parameter>
        <parameter name="pinCode" type="text" required="false">
            <context>password</context>
            <label>PIN code</label>
            <description>The PIN code to use for arming/disarming the PowerMax alarm system from openHAB. Not required except when Powerlink mode cannot be used.</description>
            <advanced>true</advanced>
        </parameter>
        <parameter name="forceStandardMode" type="boolean" required="false">
            <label>Force standard mode</label>
            <description>Force the standard mode rather than trying using the Powerlink mode.</description>
            <default>false</default>
            <advanced>true</advanced>
        </parameter>
        <parameter name="panelType" type="text" required="false">
            <label>Panel type</label>
            <description>Define the panel type. Only required when forcing the standard mode.</description>
            <limitToOptions>true</limitToOptions>
            <options>
                <option value="PowerMax">PowerMax</option>
                <option value="PowerMax+">PowerMax+</option>
                <option value="PowerMaxPro">PowerMax Pro</option>
                <option value="PowerMaxComplete">PowerMax Complete</option>
                <option value="PowerMaxProPart">PowerMax Pro Part</option>
                <option value="PowerMaxCompletePart">PowerMax Complete Part</option>
                <option value="PowerMaxExpress">PowerMax Express</option>
                <option value="PowerMaster10">PowerMaster 10</option>
                <option value="PowerMaster30">PowerMaster 30</option>
            </options>
            <default>PowerMaxPro</default>
            <advanced>true</advanced>
        </parameter>
        <parameter name="autoSyncTime" type="boolean" required="false">
            <label>Sync time</label>
            <description>Automatic sync time at openHAB startup.</description>
            <default>false</default>
            <advanced>true</advanced>
        </parameter>
    </config-description>
</binding:binding>

I have an additional question; what is exactly “network_address” as parameter context ? Shall I use it for a serial port ?

@Kai @watou can you help me please ?

Ok, with the last OH2 snapshot, I have now a configuration screen that opens with all my configuration parameters.
The problem I have now is that my parameters are not set in this screen. I was expecting that they would have been read from my powermax.cfg file. Isn’t it what is expected ?

Other thing: all my parameters are displayed in expert mode; when I switch to normal mode, I have no parameter displayed. I was expecting that it could depend on the tag “advanced” but it looks it is not.

No, it is meant to be an IP/hostname and help UIs to potentially render this nicely.[quote=“Lolodomo, post:2, topic:9824”]

The problem I have now is that my parameters are not set in this screen. I was expecting that they would have been read from my powermax.cfg file. Isn’t it what is expected ?
[/quote]

Yes, I would expect this. If they appear in expert mode, it seems to prove that they are correctly available.
I cannot tell, why they do not show up on the standard UI screen - is this even the case for text parameters? Could you try again on the latest build, since quite some fixes have been done in the Paper UI in the past week?

@Kai, I tried again with offline distro 256 with no better success. The configuration parameters are not set with my configuration defined in my powermax.cfg file. It looks like I just have default values.
When I open the screen, I guess that this is the normal mode. All my parameters are present, even the ones with the tag “advanced”. When I click on button “Expert”, no parameters are present in the screen, only a button to add a new parameter.

I have to tell you, in case it would be important, that in Paper UI extensions, my binding is not shown as installed because of course I have not installed the binding packaged with the distro but I used a new jar put in my addons folder. The bundle is installed and active (the binding is working).

PS: thanks for the explanation regarding “network_address” context, I suppressed it for my serial port parameter.

I have done few additional tests. I can update/save my settings through this dialog box and they are really saved because they are restored after a OH2 restart but I don’t know where (maybe in mapdb ?). I can also confirm that my powermax.cfg file is neither read at startup nor updated when I change settings from this dialog box and the settings managed by this dialog box are not considered by my binding (the considered settings are the ones from the cfg file).

@kai @watou help needed or I will just forgive and not implement this feature…

There are two ways to do configuration in OH2:

  1. Statically through cfg files
  2. Dynamically through ConfigAdmin (to which the Paper UI passes the settings)

If (1) defines something, this has precedence over (2).

Usually, users should either do (1) or (2), but not a mix (unless they know what they are doing).

Your observations seem to match this, so I do not see any reason to worry.

Ok, so to test this new feature I should delete my cfg file ?

But the cfg file is automatically created in conf/services folder when installing the binding. So except if you delete manually this file, the user will never be able to use ConfigAdmin ?

All this will add lot of confusion to any “normal” user. Even for me it was not clear at all.

The config file can be there, but by default, all lines should be commented out.
This is the normal situation for all cfg files that are in https://github.com/openhab/openhab/tree/master/features/openhab-addons-external/src/main/resources/conf.

Yes, you’re right.
So I just have to re-comment the entries in my cfg file.

Still no success. I will do a last try starting from scratch without any mapdb or cfg file.

Is it expected that when I push the expert mode button, all setting are disappearing ? In the normal mode, all settings are displayed.
What is the role of the “advanced” tag ?

It is definitevely not working. Even after an install from scratch, I can see that my binding is not considering the serial port I specify in this dialog box. The binding does not start until I specify the serial port directly inside the powermax.cfg file.

FTR: https://github.com/eclipse/smarthome/issues/1438

Ah OK, so you confirm there is a bug. Will wait for a fix and test again when the fix is available.
I will produce a PR with my meta data today or tomorrow.