Selector dzvents
Moderator: leecollings
-
- Posts: 36
- Joined: Monday 02 February 2015 15:50
- Target OS: Linux
- Domoticz version:
- Location: Cheshire England
- Contact:
Selector dzvents
I am struggling with a selector switch
I am trying to change my heating zones with a selector switch. I can do with separate switches
Do I have to use the value it has created i.e. 10 20 30 etc
if so what is the correct syntax to read the various buttons of the selector switch
Thanks
I am trying to change my heating zones with a selector switch. I can do with separate switches
Do I have to use the value it has created i.e. 10 20 30 etc
if so what is the correct syntax to read the various buttons of the selector switch
Thanks
- emme
- Posts: 909
- Joined: Monday 27 June 2016 11:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Milano, Italy
- Contact:
Re: Selector dzvents
domoticz.device('myHeatSelector').switchSelector(10)
domoticz.devices('mySetPoint').updateSetPoint(domoticz.device('myHeatSelector').levelName)
domoticz.devices('mySetPoint').updateSetPoint(domoticz.device('myHeatSelector').levelName)
The most dangerous phrase in any language is:
"We always done this way"
"We always done this way"
-
- Posts: 36
- Joined: Monday 02 February 2015 15:50
- Target OS: Linux
- Domoticz version:
- Location: Cheshire England
- Contact:
Re: Selector dzvents
Thanks for reply
my test code
return {
active = true,
on = {
devices = {
'boost test 126', -- name of switch
'selector', -- name of selector switch
},
timer = {'every 1 minutes'}
},
execute = function(domoticz, device, triggerInfo)
domoticz.log('trigger == > '..triggerInfo.type)
if triggerInfo.type == domoticz.EVENT_TYPE_TIMER then
-- do timer event stuff
domoticz.log(' tttttt Hey! timer ttttttttttttttttttt')
elseif triggerInfo.type == domoticz.EVENT_TYPE_DEVICE then
-- do device event stuff
if (device.state == 'On') then
domoticz.log('Hey! I am on! xxxxxxx Switch On xxxxxxxxxxxxxxxxxxxxxxx')
print " on "
else
domoticz.log('Hey! I am off! yyyyyyyy Switch Off Off Off Switch Off Off Off ')
end
if domoticz.device('selector').switchSelector(10) then
domoticz.log('its 10 ')
elseif domoticz.device('selector').switchSelector(20) then
domoticz.log('its 20 ')
end
domoticz.log(domoticz.devices('selector').value)
end
end
}
log
2018-02-08 12:37:08.159 dzVents: Info: ------ Start internal script: selector: Device: "selector (dummy1)", Index: 871
2018-02-08 12:37:08.159 Error: dzVents: Error: An error occured when calling event handler selector
2018-02-08 12:37:08.159 Error: dzVents: Error: .../domoticz/scripts/dzVents/generated_scripts/selector.lua:19: attempt to index global 'domoticz' (a nil value)
2018-02-08 12:37:08.159 dzVents: Info: ------ Finished selector
thanks
my test code
return {
active = true,
on = {
devices = {
'boost test 126', -- name of switch
'selector', -- name of selector switch
},
timer = {'every 1 minutes'}
},
execute = function(domoticz, device, triggerInfo)
domoticz.log('trigger == > '..triggerInfo.type)
if triggerInfo.type == domoticz.EVENT_TYPE_TIMER then
-- do timer event stuff
domoticz.log(' tttttt Hey! timer ttttttttttttttttttt')
elseif triggerInfo.type == domoticz.EVENT_TYPE_DEVICE then
-- do device event stuff
if (device.state == 'On') then
domoticz.log('Hey! I am on! xxxxxxx Switch On xxxxxxxxxxxxxxxxxxxxxxx')
print " on "
else
domoticz.log('Hey! I am off! yyyyyyyy Switch Off Off Off Switch Off Off Off ')
end
if domoticz.device('selector').switchSelector(10) then
domoticz.log('its 10 ')
elseif domoticz.device('selector').switchSelector(20) then
domoticz.log('its 20 ')
end
domoticz.log(domoticz.devices('selector').value)
end
end
}
log
2018-02-08 12:37:08.159 dzVents: Info: ------ Start internal script: selector: Device: "selector (dummy1)", Index: 871
2018-02-08 12:37:08.159 Error: dzVents: Error: An error occured when calling event handler selector
2018-02-08 12:37:08.159 Error: dzVents: Error: .../domoticz/scripts/dzVents/generated_scripts/selector.lua:19: attempt to index global 'domoticz' (a nil value)
2018-02-08 12:37:08.159 dzVents: Info: ------ Finished selector
thanks
- emme
- Posts: 909
- Joined: Monday 27 June 2016 11:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Milano, Italy
- Contact:
Re: Selector dzvents
need to know exactely where is line 19 but I assume is on the if statement
as per dzvents 2.4.1 the triggerInfo is depreciated (but still valid)
try to replace
elseif triggerInfo.type == domoticz.EVENT_TYPE_DEVICE then
with
elseif device.isDevice then
as per dzvents 2.4.1 the triggerInfo is depreciated (but still valid)
try to replace
elseif triggerInfo.type == domoticz.EVENT_TYPE_DEVICE then
with
elseif device.isDevice then
The most dangerous phrase in any language is:
"We always done this way"
"We always done this way"
-
- Posts: 36
- Joined: Monday 02 February 2015 15:50
- Target OS: Linux
- Domoticz version:
- Location: Cheshire England
- Contact:
Re: Selector dzvents
Thanks
changed elseif and its now working OK
was --elseif triggerInfo.type == domoticz.EVENT_TYPE_DEVICE then
now elseif device.isDevice then
Thanks for your fast help been struggling for nearly a week and you fixed in minutes.
Out of interest where do I find information for these types of situations
Thanks again
changed elseif and its now working OK
was --elseif triggerInfo.type == domoticz.EVENT_TYPE_DEVICE then
now elseif device.isDevice then
Thanks for your fast help been struggling for nearly a week and you fixed in minutes.
Out of interest where do I find information for these types of situations
Thanks again
-
- Posts: 36
- Joined: Monday 02 February 2015 15:50
- Target OS: Linux
- Domoticz version:
- Location: Cheshire England
- Contact:
Re: Selector dzvents
Hi
I think I spoke too soon it's not working now don't know what is happening
errors
2018-02-08 14:02:26.462 Error: dzVents: Error: An error occured when calling event handler hall
2018-02-08 14:02:26.462 Error: dzVents: Error: ...e/pi/domoticz/scripts/dzVents/generated_scripts/hall.lua:28: attempt to call field 'device' (a nil value)
Code
return {
active = true,
on = {
devices = {
'boost test 126', -- name of switch
'selector', -- name of selector switch
},
timer = {'every 1 minutes'}
},
execute = function(domoticz, device, triggerInfo)
domoticz.log('trigger == > '..triggerInfo.type)
if triggerInfo.type == domoticz.EVENT_TYPE_TIMER then
-- do timer event stuff
domoticz.log(' tttttt Hey! timer ttttttttttttttttttt')
--elseif triggerInfo.type == domoticz.EVENT_TYPE_DEVICE then
elseif device.isDevice then
-- do device event stuff
if (device.state == 'On') then
domoticz.log('Hey! I am on! xxxxxxx Switch On xxxxxxxxxxxxxxxxxxxxxxx')
print " on "
else
domoticz.log('Hey! I am off! yyyyyyyy Switch Off Off Off Switch Off Off Off ')
end
if domoticz.device('selector').switchSelector(10) then -- THIS IS LINE 28
domoticz.log('its 10 ')
elseif domoticz.device('selector').switchSelector(20) then
domoticz.log('its 20 ')
end
domoticz.log(domoticz.devices('selector').value)
end
end
}
Note the error is now line 28 - indicated in code above
Thanks
I think I spoke too soon it's not working now don't know what is happening
errors
2018-02-08 14:02:26.462 Error: dzVents: Error: An error occured when calling event handler hall
2018-02-08 14:02:26.462 Error: dzVents: Error: ...e/pi/domoticz/scripts/dzVents/generated_scripts/hall.lua:28: attempt to call field 'device' (a nil value)
Code
return {
active = true,
on = {
devices = {
'boost test 126', -- name of switch
'selector', -- name of selector switch
},
timer = {'every 1 minutes'}
},
execute = function(domoticz, device, triggerInfo)
domoticz.log('trigger == > '..triggerInfo.type)
if triggerInfo.type == domoticz.EVENT_TYPE_TIMER then
-- do timer event stuff
domoticz.log(' tttttt Hey! timer ttttttttttttttttttt')
--elseif triggerInfo.type == domoticz.EVENT_TYPE_DEVICE then
elseif device.isDevice then
-- do device event stuff
if (device.state == 'On') then
domoticz.log('Hey! I am on! xxxxxxx Switch On xxxxxxxxxxxxxxxxxxxxxxx')
print " on "
else
domoticz.log('Hey! I am off! yyyyyyyy Switch Off Off Off Switch Off Off Off ')
end
if domoticz.device('selector').switchSelector(10) then -- THIS IS LINE 28
domoticz.log('its 10 ')
elseif domoticz.device('selector').switchSelector(20) then
domoticz.log('its 20 ')
end
domoticz.log(domoticz.devices('selector').value)
end
end
}
Note the error is now line 28 - indicated in code above
Thanks
-
- Posts: 36
- Joined: Monday 02 February 2015 15:50
- Target OS: Linux
- Domoticz version:
- Location: Cheshire England
- Contact:
Re: Selector dzvents
Update errors have disappeared but the if section line 28 is not doing anything
also tried
if domoticz.devices('selector').value == "Breakfast" then
domoticz.log('its Breakfast')
end
the following line returns Breakfast
domoticz.log(domoticz.devices('selector').value)
following copied from switch
Selector Levels:
Level Level name Order
0 Off
10 Breakfast [Rename] [Delete]
20 Snug [Rename] [Delete]
30 Hall [Rename] [Delete]
40 Lounge [Rename] [Delete]
50 Dinning [Rename] [Delete]
Thanks
also tried
if domoticz.devices('selector').value == "Breakfast" then
domoticz.log('its Breakfast')
end
the following line returns Breakfast
domoticz.log(domoticz.devices('selector').value)
following copied from switch
Selector Levels:
Level Level name Order
0 Off
10 Breakfast [Rename] [Delete]
20 Snug [Rename] [Delete]
30 Hall [Rename] [Delete]
40 Lounge [Rename] [Delete]
50 Dinning [Rename] [Delete]
Thanks
- emme
- Posts: 909
- Joined: Monday 27 June 2016 11:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Milano, Italy
- Contact:
Re: Selector dzvents
uh.. this is a wired behavior.... it should be not supposed to act like this...
first of all.. what version are you running?
as per dzVents 2.4 ( https://www.domoticz.com/wiki/DzVents:_ ... _scripting ) your script should look like:
first of all.. what version are you running?
as per dzVents 2.4 ( https://www.domoticz.com/wiki/DzVents:_ ... _scripting ) your script should look like:
Code: Select all
return {
active = true,
on = {
devices = {
'boost test 126', -- name of switch
'selector', -- name of selector switch
},
timer = {'every 1 minutes'}
},
execute = function(domoticz, device )
domoticz.log('trigger == > '..device.trigger)
if device.isTimer then
-- do timer event stuff
domoticz.log(' tttttt Hey! timer ttttttttttttttttttt')
--elseif triggerInfo.type == domoticz.EVENT_TYPE_DEVICE then
elseif device.isDevice then
-- do device event stuff
if (device.state ~= 'Off') then
domoticz.log('Hey! Not sure I\'m on.. anyhow, if I am a selector, I\'m NOT off!! xxxxxxx Switch On xxxxxxxxxxxxxxxxxxxxxxx')
else
domoticz.log('Hey! I am off! yyyyyyyy Switch Off Off Off Switch Off Off Off ')
end
if domoticz.device('selector').level == 10 then -- THIS IS LINE 28
domoticz.log('its 10 ')
elseif domoticz.device('selector').level == 20 then
domoticz.log('its 20 ')
end
domoticz.log(domoticz.devices('selector').value)
domoticz.log(domoticz.devices('selector').levelName)
end
end
}
The most dangerous phrase in any language is:
"We always done this way"
"We always done this way"
-
- Posts: 36
- Joined: Monday 02 February 2015 15:50
- Target OS: Linux
- Domoticz version:
- Location: Cheshire England
- Contact:
Re: Selector dzvents
seem to have solve part of the problem an works for what I need at the moment
if domoticz.devices('selector').state == 'Breakfast' then --- this works OK
also domoticz.devices('selector').levelName) -- returns Breakfast
but domoticz.devices('selector').value -- or .Value Does Not work
at least I can get the name of selector but not the value but I can work around that.
Many Thanks again for all your help and hopefully I will be able to boost my heating in different zones now just using a single selector.
if domoticz.devices('selector').state == 'Breakfast' then --- this works OK
also domoticz.devices('selector').levelName) -- returns Breakfast
but domoticz.devices('selector').value -- or .Value Does Not work
at least I can get the name of selector but not the value but I can work around that.
Many Thanks again for all your help and hopefully I will be able to boost my heating in different zones now just using a single selector.
-
- Posts: 105
- Joined: Saturday 25 November 2017 17:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version: v3.8153
- Location: Czech Rep.
- Contact:
Re: Selector dzvents
Here is my way, how I send selector value ( 0, 10, 20,... ) to ESPEasy.
For inspiration part of code my "every minute" script, which send state of selector to ESPeasy every minute.
I think
".level" is what you looking for.
In my case I am sending:
http://192.168.1.105/control?cmd=event,modeSet=0
or
http://192.168.1.105/control?cmd=event,modeSet=10
or
http://192.168.1.105/control?cmd=event,modeSet=20
according selector state.
https://www.domoticz.com/wiki/DzVents:_ ... or_etc..29
For inspiration part of code my "every minute" script, which send state of selector to ESPeasy every minute.
Code: Select all
local mode = domoticz.devices('Filip_Control')
local url2= 'http://192.168.1.105/control?cmd=event,modeSet='..(mode.level)..''
print(url2)
domoticz.openURL(url2)
".level" is what you looking for.
In my case I am sending:
http://192.168.1.105/control?cmd=event,modeSet=0
or
http://192.168.1.105/control?cmd=event,modeSet=10
or
http://192.168.1.105/control?cmd=event,modeSet=20
according selector state.
https://www.domoticz.com/wiki/DzVents:_ ... or_etc..29
RPi2 Domoticz v 4.10717
10 x Sonoff Basic - ESPeasy
1 x Wemos D1 - ESPeasy
1 x Shelly Plus Plug S
1 x Sonoff S26 - ESPeasy
1 x Shelly 1
1 x MySensors HC-SR04
1 x MySenosrs wifi gateway
1 x RFLink
4x Cam IPC-T240H
10 x Sonoff Basic - ESPeasy
1 x Wemos D1 - ESPeasy
1 x Shelly Plus Plug S
1 x Sonoff S26 - ESPeasy
1 x Shelly 1
1 x MySensors HC-SR04
1 x MySenosrs wifi gateway
1 x RFLink
4x Cam IPC-T240H
Who is online
Users browsing this forum: No registered users and 1 guest