[jsonConfig]: type: state - some properties are not working as expected or documentation needs improvement
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,
},
};
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
},
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",
}
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" }
]
Thanks. Will test it.
For the text I mean - to only have the option, to display as text only - without the surrounding input field.
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)
Thanks a lot!
Sounds good!