Page 1 of 1
Is there a way to set/change levelnames by script?
Posted: Sunday 16 January 2022 18:26
by EddyG
I am looking for a way to set/change levelnames of a selector switch by script or API.
Does anyone now how to do that?
Re: Is there a way to set/change levelnames by script?
Posted: Monday 17 January 2022 0:22
by mgugu
Yes, with the JSON API check
https://github.com/domoticz/domoticz/issues/3143.
Data for level names has to be base64 encoded.
Re: Is there a way to set/change levelnames by script?
Posted: Monday 17 January 2022 10:13
by EddyG
That old issue is about ADDING levels, and as far as I read it still not resolved.
I tried the examples, but it did not work.
I would like to change the levelnames.
Also this item
viewtopic.php?t=16555 is about create and populate a selectorswitch.
Re: Is there a way to set/change levelnames by script?
Posted: Monday 17 January 2022 11:05
by jvdz
When you open the Web interface of Domoticz and do a update of a Selector switch, this JSON call is done at Save time:
Code: Select all
http://IP-Address:8080/json.htm?addjvalue=0&addjvalue2=0&customimage=2&description=&idx=514&name=TV&options=BASE64-ENCODED-STRING&protected=false&strparam1=&strparam2=&switchtype=18&type=setused&used=true
Where BASE64-ENCODED-STRING = LevelNames:LVL0|LVL10|LVL20|LVL30|LVL40;LevelActions:A0|A10|A20|A30|A40;SelectorStyle:0;LevelOffHidden:true
This selector switch has 4 levels defined with 0 disabled. A0-A40 are empty as I do not use actions in the Selector..
So, just put your browser in DEBUG Mode (F12) and update the Selector Switch and check the captured JSON rest call and use that as a base to build your code for.
Jos
Re: Is there a way to set/change levelnames by script?
Posted: Monday 17 January 2022 11:35
by EddyG
Yes, Tnx, that worked. Now I have to get my string for 18 levels.

Re: Is there a way to set/change levelnames by script?
Posted: Monday 17 January 2022 11:38
by EddyG
Do you know what should be in the levelname when I need a space: <space> or %20?
Edit:
Found it: just a space!
Re: Is there a way to set/change levelnames by script?
Posted: Monday 17 January 2022 11:52
by jvdz
Not sure but assume you just do LevelNames:|LVL10|| (So leave empty between the ||, but have you tried in Developer mode (F12) to see what is happening?