Is there a way to set/change levelnames by script?

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Is there a way to set/change levelnames by script?

Post 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?
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?

Post by mgugu »

Yes, with the JSON API check https://github.com/domoticz/domoticz/issues/3143.
Data for level names has to be base64 encoded.
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Is there a way to set/change levelnames by script?

Post 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.
User avatar
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?

Post 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
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Is there a way to set/change levelnames by script?

Post by EddyG »

Yes, Tnx, that worked. Now I have to get my string for 18 levels. :)
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Is there a way to set/change levelnames by script?

Post 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!
User avatar
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?

Post 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?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest