Create and populate Selector switch with Json

Post Reply
User avatar
lonebaggie
Posts: 107
Joined: Tuesday 31 January 2017 14:21
Target OS: Raspberry Pi
Domoticz version: beta
Location: England
Contact:

Create and populate Selector switch with Json

Post by lonebaggie » Saturday 11 March 2017 10:50

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

User avatar
lonebaggie
Posts: 107
Joined: Tuesday 31 January 2017 14:21
Target OS: Raspberry Pi
Domoticz version: beta
Location: England
Contact:

Re: Create and populate Selector switch with Json

Post by lonebaggie » Saturday 11 March 2017 19:07

Just discovered 10 is the maximum number of selector items. Thre goes that idea :roll:

User avatar
Egregius
Posts: 2691
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: Beta
Location: Beitem, BE
Contact:

Re: Create and populate Selector switch with Json

Post by Egregius » Tuesday 14 March 2017 3:56

I would suggest to create a page with all your tv channels. No way you can get this in a nice way into domoticz.

User avatar
lonebaggie
Posts: 107
Joined: Tuesday 31 January 2017 14:21
Target OS: Raspberry Pi
Domoticz version: beta
Location: England
Contact:

Re: Create and populate Selector switch with Json

Post by lonebaggie » Tuesday 14 March 2017 15:37

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
Last edited by lonebaggie on Tuesday 14 March 2017 21:22, edited 2 times in total.

devros
Posts: 175
Joined: Saturday 29 October 2016 20:55
Target OS: -
Domoticz version:
Contact:

Re: Create and populate Selector switch with Json

Post by devros » Tuesday 14 March 2017 15:47

+1
better selector switch with more slots would be great....

User avatar
lonebaggie
Posts: 107
Joined: Tuesday 31 January 2017 14:21
Target OS: Raspberry Pi
Domoticz version: beta
Location: England
Contact:

Re: Create and populate Selector switch with Json

Post by lonebaggie » Tuesday 14 March 2017 21:14

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.

Nautilus
Posts: 756
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi
Domoticz version: beta
Location: Finland
Contact:

Re: Create and populate Selector switch with Json

Post by Nautilus » Wednesday 15 March 2017 0:24

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...

User avatar
lonebaggie
Posts: 107
Joined: Tuesday 31 January 2017 14:21
Target OS: Raspberry Pi
Domoticz version: beta
Location: England
Contact:

Re: Create and populate Selector switch with Json

Post by lonebaggie » Wednesday 15 March 2017 23:46

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
Last edited by lonebaggie on Thursday 16 March 2017 9:36, edited 1 time in total.

User avatar
lonebaggie
Posts: 107
Joined: Tuesday 31 January 2017 14:21
Target OS: Raspberry Pi
Domoticz version: beta
Location: England
Contact:

Re: Create and populate Selector switch with Json

Post by lonebaggie » Thursday 16 March 2017 0:53

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 ?

User avatar
lonebaggie
Posts: 107
Joined: Tuesday 31 January 2017 14:21
Target OS: Raspberry Pi
Domoticz version: beta
Location: England
Contact:

Re: Create and populate Selector switch with Json

Post by lonebaggie » Thursday 16 March 2017 13:57

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

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests