Page 1 of 1

Create and populate Selector switch with Json

Posted: Saturday 11 March 2017 9:50
by lonebaggie
Is it possible to create a selector switch with Json.

I know I can create a standard on/off switch with :-

json.htm?type=createvirtualsensor&idx=2&sensorname=test&sensortype=6

I cannot find any documentation on creating Selector switches

I want to auto create a selector switch and create the levels and triggers with TV stations information I can obtain from my Enigma2 Set-top box

I can create the switch manually but there are 300+ TV channels . Is this possible , is there a limit to the size of a selector switch ?

thanks

Re: Create and populate Selector switch with Json

Posted: Saturday 11 March 2017 18:07
by lonebaggie
Just discovered 10 is the maximum number of selector items. Thre goes that idea :roll:

Re: Create and populate Selector switch with Json

Posted: Tuesday 14 March 2017 2:56
by Egregius
I would suggest to create a page with all your tv channels. No way you can get this in a nice way into domoticz.

Re: Create and populate Selector switch with Json

Posted: Tuesday 14 March 2017 14:37
by lonebaggie
Thanks. I will look at the options , but I would also like to operate the switch via HA-Bridge and Amazon Echo

A selector switch is very nice , I have a script which acts as a feed back-loop so when a channel is changed on the TV the switch updates with the correct channel in Domoticz.

Some research the selector switch is just a dimmer switch with fixed intervals of 10% therefore 10 levels plus an off .
The selector switch dialog will allow you to add more than 10 levels , but will only work with the first 10 which makes it so frustrating.

I have read seen somewhere you can change the source code to change the dim intervals , even a dim interval of 5% rather than 10% would make all the difference as I could create 3 or 4 switches for entertainment, news, sports , movies etc .

Hopefully it will be updated in the future

Re: Create and populate Selector switch with Json

Posted: Tuesday 14 March 2017 14:47
by devros
+1
better selector switch with more slots would be great....

Re: Create and populate Selector switch with Json

Posted: Tuesday 14 March 2017 20:14
by lonebaggie
Even after my frustration with the limitation of the selector switch , is it possible to create this switch type with a Json call ?

If so I maybe able to make a top ten channels switch and amend the entries automatically by integrating the set-top box and the switch history.

Re: Create and populate Selector switch with Json

Posted: Tuesday 14 March 2017 23:24
by Nautilus
lonebaggie wrote:Even after my frustration with the limitation of the selector switch , is it possible to create this switch type with a Json call ?

If so I maybe able to make a top ten channels switch and amend the entries automatically by integrating the set-top box and the switch history.
Something like

Code: Select all

http://url:port/json.htm?type=createvirtualsensor&idx=IDX&sensorname=NAME&sensortype=1002
Have to say I'm not sure what the IDX there refers to, not the true idx of the switch as that will be the next in line. For me the idx was 25 (open the debug/inspect panel in your browser and watch the network tab for what happens when you add stuff...:))

If I add one level for the switch I get:

Code: Select all

http://url:port/json.htm?type=setused&idx=IDX&name=NAME&description=&strparam1=&strparam2=&protected=false&switchtype=18&customimage=0&used=true&addjvalue=0&addjvalue2=0&options=TGV2ZWxOYW1lcyUzQU9mZiU3Q0xldmVsMSU3Q0xldmVsMiU3Q0xldmVsMyU3Q2xldmVsNCUzQkxldmVsQWN0aW9ucyUzQSU3QyU3QyU3QyU3QyUzQlNlbGVjdG9yU3R5bGUlM0EwJTNCTGV2ZWxPZmZIaWRkZW4lM0FmYWxzZSUzQg==
here IDX is the real IDX, no idea about the rest. Based on this it does not look like an easy task to populate it fully with json calls...

Re: Create and populate Selector switch with Json

Posted: Wednesday 15 March 2017 22:46
by lonebaggie
Nautilus

Thank you :D

The IDX number is the IDX of the hardware related to the switch in my case dummy hardware. This works perfectly creating the switch. That is genius looking at the debug. Of course the Web GUI is using Json calls to create the switches, i been searching for this info for weeks. I feel stupid for not figuring this out

Just got to work out how to add levels, looks complex and encrypted

Thanks again

Re: Create and populate Selector switch with Json

Posted: Wednesday 15 March 2017 23:53
by lonebaggie
OK

it is base64-encoded text for level options

Using https://www.opinionatedgeek.com/codecs/base64decoder

From Nautilus Json example

TGV2ZWxOYW1lcyUzQU9mZiU3Q0xldmVsMSU3Q0xldmVsMiU3Q0xldmVsMyU3Q2xldmVsNCUzQkxldmVsQWN0aW9ucyUzQSU3QyU3QyU3QyU3QyUzQlNlbGVjdG9yU3R5bGUlM0EwJTNCTGV2ZWxPZmZIaWRkZW4lM0FmYWxzZSUzQg==

we get

LevelNames%3AOff%7CLevel1%7CLevel2%7CLevel3%7Clevel4%3BLevelActions%3A%7C%7C%7C%7C%3BSelectorStyle%3A0%3BLevelOffHidden%3Afalse%3B

ASCII 3a is : 7c is |3b is ;

LevelNames:Off|Level1|Level2|Level3|level4;LevelActions:||||;SelectorStyle:0;LevelOffHidden:false;

Tried the above and it deletes all my levels. Tired going to bed if any one can help ?

Re: Create and populate Selector switch with Json

Posted: Thursday 16 March 2017 12:57
by lonebaggie
It only works when you send the Json level options re-coded back into base64.

So I can create Selector switches and levels , script going to be interesting :D

Re: Create and populate Selector switch with Json

Posted: Monday 28 February 2022 10:55
by joshu
I'm modifying selector switches (after manually creating them) to select internet stations, please have a look at https://github.com/joshuisken/domoradio. It als has a lua script to activate playing music.