OH3 Parameters defaultValue

I want to populate an actionOption with a list of different variable Parameters.
If no parameter is entered in the Widget Props dialog, then a default value should be used.

I tried to use a condition for actionOptions.

"=(props.propsWP1 === undefined) ? 'Profile 1' : '1=' + props.propsWP1"

However I could make the condition work only for the first actionOption Parameter.

Then I found the defaultValue Parameter. In the Props Dialog the values are shown, however, they are not assigned to the props itself when the Dialog is closed. The actionOptions are always “undefined”. Only when a defaultValue was modified, the value is assigned.
I suppose this is a bug, but not sure.

Any hint?

actionOptions: =('1=' + props.propsWP1)  + ',' + ('2=' + props.propsWP2) + ',' + ('3=' + props.propsWP3) + ',' + ('4=' + props.propsWP4) + ',' + ('5=' + props.propsWP5) + ',' + ('6=' + props.propsWP6)
    - description: Profile 1 Name
      label: Profile 1 Name
      name: propsWP1
      required: false
      type: TEXT
      advanced: true
      defaultValue: Wochenprofil 1
    - description: Profile 2 Name
      label: Profile 2 Name
      name: propsWP2
      required: false
      type: TEXT
      advanced: true
      defaultValue: Wochenprofil 2
    - description: Profile 3 Name
      label: Profile 3 Name
      name: propsWP3
      required: false
      type: TEXT
      advanced: true
      defaultValue: Wochenprofil 3

in the example below I “edit” the defaultValue with the same text for the 1. option.

I can confirm this. You can force that default values are being saved by deleting the last character and re-adding it again.
However, why are you using a prop for each value instead of 1 for all?
defaultValue: 1=Wochenprogramm1,2=Wochenprogramm2,3=Wochenprogramm3
This way you can define elements with less actionOptions without getting undefined i.e. empty list items.

Thanks for the hint @Oliver2. Just not sure I got you correctly - sorry, but not yet experienced with YAML and OH3.

You recommend to use a single props with 1 defaultValue? That’s fine as well and would also fit the requirements.
However I’m not clear in one point. Also with this approach, its required to delete/re-add at least the last character of the defaultValue in the dialog in order to get this value assigned to the prop - am I correct?

I defined this for testing now:

    - defaultValue: 1=Wochenprofil 1,2=Wochenprofil 2,3=Wochenprofil 3,4=Wochenprofil 4,5=Wochenprofil 5,6=Wochenprofil 6
      description: Define up to 6 Profiles
      label: Profiles Names
      name: propsProfiles
      required: false
      type: TEXT

with the following actionOption

 actionOptions: "=(props.propsProfiles === undefined) ? '1=Wochenprofil 1,2=Wochenprofil 2,3=Wochenprofil 3,4=Wochenprofil 4,5=Wochenprofil 5,6=Wochenprofil 6' : props.propsProfiles"

This approach does work, however now the defaultValue is somehow obsolete, as I had to add a parameter for the undefined true condition as well. Without the check for undefined, the actionOptions are still undefined if the defaultValue wasn’t edited, as not assigned to the prop.

Is this understanding correct, or do I miss something ?



true. This is redundant. You either pre-define your values under defaultValue or actionOptions. Well, if you want to use it for yourself you instantly see that the value is not saved. You don’t really need the specification under actionOptions. This only makes sense if you want to give your widget to somebody else and want to make it less error prone.
However, I am using defaultValues, too just because I am lazy and need default Value as a template for editing.