ioBroker.admin icon indicating copy to clipboard operation
ioBroker.admin copied to clipboard

[jsonConfig]: type: state - some properties are not working as expected or documentation needs improvement

Open SKB-CGN opened this issue 9 months ago • 4 comments

No existing issues.

  • [x] There is no existing issue for my request.

Problem location

Other

Warning message

No warning message!

Source link

No link!

Additional information

The property type: state (https://github.com/ioBroker/ioBroker.admin/blob/master/packages/jsonConfig/README.md#state) is not working as documented.

Problem 1: A state of type number has a states list in it - control: select shows this box as a number field, with up and down arrows. Syntax:

{
    mode: {
        type: 'state',
        label: 'tab_mode',
        control: 'select',
        options: [
            {
                label: 'tab_mode_deactivated',
                value: 0,
            },
            {
                label: 'tab_mode_manual',
                value: 1,
            },
        ],
        oid: 'control.mode',
        xs: 12,
        sm: 12,
        md: 12,
        lg: 12,
        xl: 12,
    },
};

Image

Problem 2: A writeable state of type number should be displayed as text - but is displayed as a number box. Even with property readOnly: true. Only states, which are readonly are displayed as normal text.

Syntax:

"chargeModeDisplay": {
         "newLine": true,
         "type": "state",
         "variant": "text",
         "label": "tab_mode",
         "oid": "control.mode",
         "narrow": true,
         "addColon": true,
         "readOnly": true,
         "highlight": true,
         "xs": 12,
         "sm": 12,
         "md": 6,
         "lg": 6,
         "xl": 6
      },

Image

Thoughts: Perhaps not only trueText and falseText can be used, if a state can have several states. Maybe something like: statesText:

{
    "0": "This is for value 0",
    "1": "This is for value 1",
    "2": "This is for value 2",
}

SKB-CGN avatar May 27 '25 15:05 SKB-CGN

Select was not implemented yet. Please test 7.9.19. Writable state of type number (without max) should be shown as number field. To force text field, set control to input

It is now implemented options attribute, with that you can provide the mapping for values:

"options": [
  {"value": 0, "label": "stopped", "color": "#FF0000" },
  {"value": 1, "label": "running", "color": "#00FF00" }
] 

GermanBluefox avatar Jun 07 '25 13:06 GermanBluefox

Thanks. Will test it.

For the text I mean - to only have the option, to display as text only - without the surrounding input field.

SKB-CGN avatar Jun 07 '25 13:06 SKB-CGN

Thanks. Will test it.

For the text I mean - to only have the option, to display as text only - without the surrounding input field.

Ok. You can set the control to text to show it. (in the coming version)

GermanBluefox avatar Jun 07 '25 14:06 GermanBluefox

Thanks a lot!

Sounds good!

SKB-CGN avatar Jun 07 '25 14:06 SKB-CGN