Create and populate Selector switch with Json
Moderator: leecollings
- lonebaggie
- Posts: 86
- Joined: Tuesday 31 January 2017 13:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: England
- Contact:
Create and populate Selector switch with Json
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
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
- lonebaggie
- Posts: 86
- Joined: Tuesday 31 January 2017 13:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: England
- Contact:
Re: Create and populate Selector switch with Json
Just discovered 10 is the maximum number of selector items. Thre goes that idea 

- Egregius
- Posts: 2589
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Create and populate Selector switch with Json
I would suggest to create a page with all your tv channels. No way you can get this in a nice way into domoticz.
- lonebaggie
- Posts: 86
- Joined: Tuesday 31 January 2017 13:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: England
- Contact:
Re: Create and populate Selector switch with Json
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
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
Last edited by lonebaggie on Tuesday 14 March 2017 20:22, edited 2 times in total.
Re: Create and populate Selector switch with Json
+1
better selector switch with more slots would be great....
better selector switch with more slots would be great....
- lonebaggie
- Posts: 86
- Joined: Tuesday 31 January 2017 13:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: England
- Contact:
Re: Create and populate Selector switch with Json
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.
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.
-
- Posts: 722
- Joined: Friday 02 October 2015 12:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Finland
- Contact:
Re: Create and populate Selector switch with Json
Something likelonebaggie 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.
Code: Select all
http://url:port/json.htm?type=createvirtualsensor&idx=IDX&sensorname=NAME&sensortype=1002

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==
- lonebaggie
- Posts: 86
- Joined: Tuesday 31 January 2017 13:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: England
- Contact:
Re: Create and populate Selector switch with Json
Nautilus
Thank you
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
Thank you

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
Last edited by lonebaggie on Thursday 16 March 2017 8:36, edited 1 time in total.
- lonebaggie
- Posts: 86
- Joined: Tuesday 31 January 2017 13:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: England
- Contact:
Re: Create and populate Selector switch with Json
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 ?
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 ?
- lonebaggie
- Posts: 86
- Joined: Tuesday 31 January 2017 13:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: England
- Contact:
Re: Create and populate Selector switch with Json
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
So I can create Selector switches and levels , script going to be interesting

-
- Posts: 2
- Joined: Monday 28 February 2022 10:22
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Create and populate Selector switch with Json
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.
Who is online
Users browsing this forum: No registered users and 0 guests