Reading level names from selector switch Topic is solved

Python and python framework

Moderator: leecollings

Post Reply
User avatar
jorgh
Posts: 124
Joined: Friday 27 June 2014 23:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8224
Location: Netherlands
Contact:

Reading level names from selector switch

Post by jorgh »

Hi all,

I'm trying to find out if it's possible to read the level name associated with the levels of a selector switch. Up till now I've had no success and have not been able to find information on this. In the plugin onCommand, I do get the level value, but I need the corresponding level name.
Does anyone know if this is possible, and how it can be done from a Python plugin?

Kind regards,

Jorg
oohlaf
Posts: 21
Joined: Monday 06 February 2017 0:57
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Reading level names from selector switch

Post by oohlaf »

When my pull request is merged, you get access to the Options setting from within the Python plugin system. Have a look at the modified example script. Variable Options is a dict which contains the levelnames.

https://github.com/domoticz/domoticz/pull/1360
User avatar
jorgh
Posts: 124
Joined: Friday 27 June 2014 23:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8224
Location: Netherlands
Contact:

Re: Reading level names from selector switch

Post by jorgh »

@Oohlaf,

That would definitely solve my issue, I've already tried reading the options setting, but it could not be fetched.
Hope it gets accepted soon, it is a really useful addition, as it allows people to reorder, add, or delete items that can be processed by plugins as they are able to read the content.

Regards,

Jorg
oohlaf
Posts: 21
Joined: Monday 06 February 2017 0:57
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Reading level names from selector switch

Post by oohlaf »

Keep in mind that modifying the options after creation is not updated immediately in the webinterface. One needs to reload the page and/or switch to another page and come back. I'm not sure if (and how) a signal is send to the webbrowser to reload the control and if this can be initiated from a plugin.

I'm more or less testing the same functionality in my unreleased Pioneer plugin.
User avatar
jorgh
Posts: 124
Joined: Friday 27 June 2014 23:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8224
Location: Netherlands
Contact:

Re: Reading level names from selector switch

Post by jorgh »

@Oohlaf,

That should not be an issue in my case. I only want users to be able, to for instance delete inputs they don't use (eg Phono, AM), or reorder them without the plugin getting confused.
I looked at your code, and it seems you've also created some more convenient ways to submit options on device creation. That makes the code more readable. I'll change my plugin code to create the options in this fashion once it's available. I'm currently running a from source compiled Domoticz version from the plugin branch, is it going to be available there too?

Regards,

Jorg
oohlaf
Posts: 21
Joined: Monday 06 February 2017 0:57
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Reading level names from selector switch

Post by oohlaf »

That was the whole idea of the pull request. For C++, plugins did not need to base64 encode/decode options as the core already contained convenience methods for it. Now they are reused by the Python plugins also.

About the python branch, that's the playground of Dnpwwo. Up to him to merge it there also. I stopped submitting against his branch and only focus on master.
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Reading level names from selector switch

Post by Dnpwwo »

@jorgh,

You should be able to switch back to the master branch without losing any functionality. I don't have any outstanding updates in the Python-Plugins branch.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest