What is the correct way to update a selector switch

Python and python framework

Moderator: leecollings

Post Reply
Barberousse
Posts: 140
Joined: Wednesday 02 December 2015 21:47
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

What is the correct way to update a selector switch

Post 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.
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: What is the correct way to update a selector switch

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

Code: Select all

 Devices[1].Update(2,nsvalue)
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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Barberousse
Posts: 140
Joined: Wednesday 02 December 2015 21:47
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

Re: What is the correct way to update a selector switch

Post 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 ?
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: What is the correct way to update a selector switch

Post 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
Knipsel.PNG (3.14 KiB) Viewed 1924 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Barberousse
Posts: 140
Joined: Wednesday 02 December 2015 21:47
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

Re: What is the correct way to update a selector switch

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

Who is online

Users browsing this forum: Bing [Bot] and 1 guest