switchSelector bug?  [Solved]

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

Moderator: leecollings

Post Reply
darrepac
Posts: 142
Joined: Tuesday 04 February 2014 21:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Isère, France
Contact:

switchSelector bug?

Post by darrepac »

Hi

Trying to change a selector value through dzVents (beginner, was using directly LUA before), I read in the doc:
switchSelector(<[level]|[levelname]>): Function. Switches a selector switch to a specific level ( levelname or level(numeric) required ) levelname must be exact, for level the closest fit will be picked. See the edit page in Domoticz for such a switch to get a list of the values). Supports command options.
But either I am missunderstanding or it is not working as expected:
My selector has 4 values (Off is not activated):
Level 10: "20"
Level 20 : "30"
Level 30 : "45"
Level 40 : "50"

My understanding is that I have to give as parameter to switchSelector either a level (=integer) or levelname (= string) value.
so I used

Code: Select all

switchSelector('20')
So I thought using levelName and so putting my selector to the level named "20" (which correspond to the level 10).
But the result was level named "30" which correspond to the level 20.
So even if I pass a string to switchSelector in order to use levelName, it has used the value (from string ?) as the level...

Sounds strange to me but I might missunderstand the doc.
hoeby
Posts: 531
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: switchSelector bug?

Post by hoeby »

I run the selectie switch in dzvents, without problems.
Is running on the last stable.

Code: Select all

dz.devices('devicename').switchSelector(10)
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: switchSelector bug?  [Solved]

Post by waaren »

darrepac wrote: Saturday 24 August 2019 22:16 My understanding is that I have to give as parameter to switchSelector either a level (=integer) or levelname (= string) value.
so I used

Code: Select all

switchSelector('20')
Sounds strange to me but I might misunderstand the doc.
Using the levelname is only working correctly if you have not removed the 0 = "Off" level. Will update the wiki accoridingly.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
darrepac
Posts: 142
Joined: Tuesday 04 February 2014 21:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Isère, France
Contact:

Re: switchSelector bug?

Post by darrepac »

waaren wrote: Saturday 24 August 2019 22:43
Using the levelname is only working correctly if you have not removed the 0 = "Off" level. Will update the wiki accoridingly.
Ok! Here is the reason, thanks!
darrepac
Posts: 142
Joined: Tuesday 04 February 2014 21:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Isère, France
Contact:

Re: switchSelector bug?

Post by darrepac »

I kept the level 0 but I didn't name it "Off". Should I name it "Off" to make it works?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: switchSelector bug?

Post by waaren »

darrepac wrote:I kept the level 0 but I didn't name it "Off". Should I name it "Off" to make it works?
Cannot check right now but do think that if it has a levelname (any name) it should work.


Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
darrepac
Posts: 142
Joined: Tuesday 04 February 2014 21:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Isère, France
Contact:

Re: switchSelector bug?

Post by darrepac »

waaren wrote: Sunday 25 August 2019 12:18
darrepac wrote:I kept the level 0 but I didn't name it "Off". Should I name it "Off" to make it works?
Cannot check right now but do think that if it has a levelname (any name) it should work.
I gave a try but it doesn't seem to work. I fall back to use "level" instead of "levelName" even if I find it less convenient.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: switchSelector bug?

Post by waaren »

darrepac wrote: I gave a try but it doesn't seem to work. I fall back to use "level" instead of "levelName" even if I find it less convenient.
Can you please do a dump() of your device ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
darrepac
Posts: 142
Joined: Tuesday 04 February 2014 21:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Isère, France
Contact:

Re: switchSelector bug?

Post by darrepac »

Code: Select all

2019-08-25 13:33:00.728 Status: dzVents: > LOG_MODULE_EXEC_INFO: 2
2019-08-25 13:33:00.728 Status: dzVents: > hsbToRGB()
2019-08-25 13:33:00.728 Status: dzVents: > DZVERSION: 2.4.19
2019-08-25 13:33:00.728 Status: dzVents: > osExecute()
2019-08-25 13:33:00.728 Status: dzVents: > fileExists()
2019-08-25 13:33:00.728 Status: dzVents: > log()
2019-08-25 13:33:00.728 Status: dzVents: > toJSON()
2019-08-25 13:33:00.728 Status: dzVents: > LOG_FORCE: 0.5
2019-08-25 13:33:00.728 Status: dzVents: > LOG_DEBUG: 4
2019-08-25 13:33:00.728 Status: dzVents: > hour: 12
2019-08-25 13:33:00.729 Status: dzVents: > isUTC: false
2019-08-25 13:33:00.729 Status: dzVents: > raw: 2019-08-25 12:23:00
2019-08-25 13:33:00.729 Status: dzVents: > day: 25
2019-08-25 13:33:00.729 Status: dzVents: > ruleIsBeforeCivilTwilightStart()
2019-08-25 13:33:00.729 Status: dzVents: > ruleIsAtCivilDayTime()
2019-08-25 13:33:00.729 Status: dzVents: > millisecondsAgo: 4200517
2019-08-25 13:33:00.729 Status: dzVents: > msAgo: 4200517
2019-08-25 13:33:00.729 Status: dzVents: > ruleIsAtCivilNight()
2019-08-25 13:33:00.729 Status: dzVents: > ruleIsAfterSunset()
2019-08-25 13:33:00.729 Status: dzVents: > ruleIsAfterCivilTwilightEnd()
2019-08-25 13:33:00.729 Status: dzVents: > rawTime: 12:23:00
2019-08-25 13:33:00.729 Status: dzVents: > ruleIsAfterSunrise()
2019-08-25 13:33:00.729 Status: dzVents: > wday: 1
2019-08-25 13:33:00.729 Status: dzVents: > isdst: true
2019-08-25 13:33:00.729 Status: dzVents: > ruleIsAtSunrise()
2019-08-25 13:33:00.729 Status: dzVents: > ruleIsBeforeSunset()
2019-08-25 13:33:00.729 Status: dzVents: > ruleIsAtNight()
2019-08-25 13:33:00.729 Status: dzVents: > ruleIsAfterCivilTwilightStart()
2019-08-25 13:33:00.729 Status: dzVents: > yday: 237
2019-08-25 13:33:00.730 Status: dzVents: > compare()
2019-08-25 13:33:00.730 Status: dzVents: > ruleIsAtCivilTwilightStart()
2019-08-25 13:33:00.730 Status: dzVents: > rawDate: 2019-08-25
2019-08-25 13:33:00.730 Status: dzVents: > dDate: 1566728580
2019-08-25 13:33:00.730 Status: dzVents: > ruleIsInWeek()
2019-08-25 13:33:00.730 Status: dzVents: > ruleIsBeforeCivilTwilightEnd()
2019-08-25 13:33:00.730 Status: dzVents: > getISO()
2019-08-25 13:33:00.730 Status: dzVents: > sec: 0
2019-08-25 13:33:00.730 Status: dzVents: > secondsSinceMidnight: 44580
2019-08-25 13:33:00.730 Status: dzVents: > dayAbbrOfWeek: sun
2019-08-25 13:33:00.730 Status: dzVents: > ruleIsOnDate()
2019-08-25 13:33:00.730 Status: dzVents: > week: 34
2019-08-25 13:33:00.730 Status: dzVents: > ruleIsOnDay()
2019-08-25 13:33:00.730 Status: dzVents: > ruleIsAtSunset()
2019-08-25 13:33:00.730 Status: dzVents: > min: 23
2019-08-25 13:33:00.731 Status: dzVents: > secondsAgo: 4200
2019-08-25 13:33:00.731 Status: dzVents: > isToday: true
2019-08-25 13:33:00.731 Status: dzVents: > minutesAgo: 70
2019-08-25 13:33:00.731 Status: dzVents: > milliseconds: 0
2019-08-25 13:33:00.731 Status: dzVents: > year: 2019
2019-08-25 13:33:00.731 Status: dzVents: > month: 8
2019-08-25 13:33:00.731 Status: dzVents: > unit: 1
2019-08-25 13:33:00.731 Status: dzVents: > hardwareType: Dummy (Does nothing, use for virtual switches only)
2019-08-25 13:33:00.731 Status: dzVents: > setState()
2019-08-25 13:33:00.731 Status: dzVents: > stop()
2019-08-25 13:33:00.731 Status: dzVents: > updateWetness()
2019-08-25 13:33:00.731 Status: dzVents: > disarm()
2019-08-25 13:33:00.731 Status: dzVents: > updateTempHum()
2019-08-25 13:33:00.731 Status: dzVents: > updateRain()
2019-08-25 13:33:00.731 Status: dzVents: > state: 45
2019-08-25 13:33:00.731 Status: dzVents: > isGroup: false
2019-08-25 13:33:00.731 Status: dzVents: > switchSelector()
2019-08-25 13:33:00.731 Status: dzVents: > updateSetPoint()
2019-08-25 13:33:00.731 Status: dzVents: > updateAlertSensor()
2019-08-25 13:33:00.731 Status: dzVents: > pause()
2019-08-25 13:33:00.732 Status: dzVents: > levelOffHidden: false
2019-08-25 13:33:00.732 Status: dzVents: > hardwareId: 8
2019-08-25 13:33:00.732 Status: dzVents: > name: Ballon ECS Bas
2019-08-25 13:33:00.732 Status: dzVents: > switchTypeValue: 18
2019-08-25 13:33:00.732 Status: dzVents: Info: ------ Finished Script #1
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: switchSelector bug?

Post by waaren »

darrepac wrote: Sunday 25 August 2019 12:24 I gave a try but it doesn't seem to work. I fall back to use "level" instead of "levelName" even if I find it less convenient.
You are on dzVents version 2.4.19. The use of levelName in switchSelector command is supported from dzVents 2.4.22 onwards. It was already in the (wiki) history but it seems that is was overwritten in the wiki in the description of the command itself. Re-added it now.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
darrepac
Posts: 142
Joined: Tuesday 04 February 2014 21:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Isère, France
Contact:

Re: switchSelector bug?

Post by darrepac »

ok.. since 2 years I am no more playing with domoticz beta version and running on stable, so I would need to wait for the next stable version?
(Note: it works well with level for me and could interest others)
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: switchSelector bug?

Post by waaren »

darrepac wrote: Sunday 25 August 2019 18:32 ok.. since 2 years I am no more playing with domoticz beta version and running on stable, so I would need to wait for the next stable version?
(Note: it works well with level for me and could interest others)
Yes that is how the domoticz releases (including the integrated stuff like Open Zwave, dzVents and the likes) work. New features and bugfixes are not rolled into stable versions but will only make it to the next and future beta's and next and future stables
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest