Retrieving all supported levels

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
dzdm
Posts: 12
Joined: Monday 05 February 2018 14:24
Target OS: Linux
Domoticz version:
Contact:

Retrieving all supported levels

Post by dzdm »

Hi :)

I'm looking for a way to retrieve all supported levels (numeric!) for a specific switch,
so I can use the number in the switchSelector function. It is possible to get all level names
with:

local levels = dz.devices('Beacon').levelNames

But the switchSelector function only supports the numeric values and I did not find
a way to get a list of this numbers.

Does anyone have a solution for this?


Thank you!
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Retrieving all supported levels

Post by emme »

use:
local levels = #dz.devices('Beacon').levelNames
to get the levels count (off included)
the result starts from 1 while levels start from 0 so to use it try with

maxLevel = (levels-1) * 10
The most dangerous phrase in any language is:
"We always done this way"
dzdm
Posts: 12
Joined: Monday 05 February 2018 14:24
Target OS: Linux
Domoticz version:
Contact:

Re: Retrieving all supported levels

Post by dzdm »

Hi,

yes this seems to work, but I have another issue regarding the levels. I have levels from 0 to 200 (in steps of 10), but I cannot change levels > 100 with the switchSelector function (levels > 100 are always set to 100 when using switchSelector). Is there any other way to set levels > 100?
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Retrieving all supported levels

Post by emme »

I think you should NOT be allowed to add more than 10 levels... that's a GUI error
at level 100 the Add button looks like it is disable while it dosen't
The most dangerous phrase in any language is:
"We always done this way"
dzdm
Posts: 12
Joined: Monday 05 February 2018 14:24
Target OS: Linux
Domoticz version:
Contact:

Re: Retrieving all supported levels

Post by dzdm »

Hi,

well I did not add them by hand, I just added a IKEA light bulb device (tradfri) and the levels were preset.

But the question is, why is it not allowed? I understand, that levels are usually in percent, but switchSelector is more than a switch with multiple different states, so why shouldn't it be possible to have more than 10 different states? For example, you have a radio device with multiple pre-programmed radio stations you want to switch. And even in case the level is in percent, maybe devices with special parameters exists which can be set to > 100%?
Post Reply

Who is online

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