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

[Enhancement] Allow setState also with "states-Namens" from object definition

Open Apollon77 opened this issue 5 years ago • 5 comments

For States that have object definition with "states" (1->'ON', 2'OFF') it would be great if the value for "setState" could be also the string defined by the "states" object. This makes it more easy to use for not that experienced users. setState should detect that (via datatype mismatch) and if set value is a string AND matches to one of the defined "states" it should be mapped and the numeric value should be set

Apollon77 avatar May 29 '19 14:05 Apollon77

Question: Is it possible to have the following situation?

(state) -> (name)
"foo"   -> "bar"
"bar"   -> "baz"
"baz"   -> "foo"

I would guess not, but that could create some problems.

AlCalzone avatar May 29 '19 14:05 AlCalzone

According to specs "states" is only allowed for intager values to map to a "text to be shown in dropdown" https://github.com/ioBroker/ioBroker/blob/master/doc/SCHEMA.md#state

Apollon77 avatar May 29 '19 14:05 Apollon77

PS: Yes example also shown sstrings ('value2') but some time ago I asked and it should only by numbers allowed as base value

Apollon77 avatar May 29 '19 14:05 Apollon77

It should also boolean allowed as base value !

paul53 avatar Jul 13 '19 15:07 paul53

I would also like to set the string part to the datapoint. For example: 0:Alexa; 1:Marlene; 2:Vicki; 3:Hans

I would like to set one of these names to a datapoint called "AlexaVoice"

aleks-83 avatar Nov 12 '19 07:11 aleks-83