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?
Is there a way to set/change levelnames by script?
Moderator: leecollings
-
mgugu
- Posts: 226
- Joined: Friday 04 November 2016 12:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: France
- Contact:
Re: Is there a way to set/change levelnames by script?
Yes, with the JSON API check https://github.com/domoticz/domoticz/issues/3143.
Data for level names has to be base64 encoded.
Data for level names has to be base64 encoded.
Re: Is there a way to set/change levelnames by script?
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.
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.
- jvdz
- Posts: 2446
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Is there a way to set/change levelnames by script?
When you open the Web interface of Domoticz and do a update of a Selector switch, this JSON call is done at Save time:
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
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=trueThis 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?
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?
Do you know what should be in the levelname when I need a space: <space> or %20?
Edit:
Found it: just a space!
Edit:
Found it: just a space!
- jvdz
- Posts: 2446
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Is there a way to set/change levelnames by script?
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?
Who is online
Users browsing this forum: No registered users and 1 guest