Page 1 of 1
What is the correct way to update a selector switch
Posted: Friday 17 November 2017 18:21
by Barberousse
Hello,
I see in some plugins that to update a selector switch device, nValue must be 1 and sValue must contain the text to be selected (cf.
https://github.com/gerard33/sony-bravia ... /plugin.py for instance). But it doesn't work for the plugin I'm writing (on beta v3.8740), it is only working when I set a level (for instance, nValue 30 and sValue "30" for third option). Is there any documentation somewhere, or could you point me the code where to find the correct implementation ?
Thank you.
Re: What is the correct way to update a selector switch
Posted: Friday 17 November 2017 19:23
by jvdz
In a plugin I am using for an Itho ventilation system I use a selector switch and use this statement in the plugin to update the selector switch:
Where nsvalue is the numeric level defined in the switch (0,10,20,30 etc)
the device is created with these statements:
Code: Select all
SelectorNames="|Lo|Me|Hi|T1|T2|T3"
SelectorOptions="||||||"
if Parameters["Mode6"] == "Debug":
Domoticz.Debugging(1)
Options={"LevelNames":SelectorNames,
"LevelActions":SelectorOptions,
"LevelOffHidden": "true",
"SelectorStyle": "0"}
if (len(Devices) == 0):
Domoticz.Device(Name="Ventilator", Used=1, Unit=1, TypeName="Selector Switch", Switchtype=18, Image=7, Options=Options).Create()
Domoticz.Log("Devices created.")
else:
Devices[1].Update(nValue=Devices[1].nValue, sValue=Devices[1].sValue, Options=Options)
Domoticz.Log("Devices updated.")
Jos
Re: What is the correct way to update a selector switch
Posted: Saturday 18 November 2017 10:25
by Barberousse
Thank you ! LevelOffHidden and SelectorStyle are new to me, where did you find these parameters ? It seems that only the svalue matters to select the value, from ten to ten starting at 0. Does it mean 10 values max ?
Re: What is the correct way to update a selector switch
Posted: Saturday 18 November 2017 12:31
by jvdz
Barberousse wrote: ↑Saturday 18 November 2017 10:25
Thank you ! LevelOffHidden and SelectorStyle are new to me, where did you find these parameters ?
I normally use developer mode in Chrome and then edit the device, in this case the Selector switch, then set the options as I wish and look at the settings as being send to Domoticz.
The below options are the SelectorStyle & LevelOffHidden options:

- Knipsel.PNG (3.14 KiB) Viewed 1929 times
ps: the &options= is encoded in base64, so to make that readable, you need to decode that first. Just use any base64 online decode and then a URLDecode to get to: "LevelNames:|Lo|Me|Hi|T1|T2|T3;LevelActions:||||||;SelectorStyle:;LevelOffHidden:true;"
Jos
Re: What is the correct way to update a selector switch
Posted: Tuesday 28 November 2017 20:33
by Barberousse
Hello,
Thank you for your support, it was really helpful. I have another question: is there any sensor that let the user enter a number, except for Thermostat setpoint ? I'm looking for general number input.
Thank you.