Page 1 of 1
for i in pairs and groups
Posted: Monday 01 July 2019 17:56
by Gravityz
this script runs perfect when devices are used in the lookup table
if i want to use it with groups/scenes it does not work.
so if lookup contains devices and i use domoticz.devices it works
if lookup contains groups and i use domoticz.groups it does not work and the log complains about scenes/groups not existing but they do
Code: Select all
2019-07-01 17:52:30.048 Error: dzVents: Error: (2.4.24) There is no group or scene with that name or id: Woonkamerlampen. If you just created the scene or group you may have to restart Domoticz to make it become visible to dzVents.
2019-07-01 17:52:30.049 Error: dzVents: Error: (2.4.24) There is no group or scene with that name or id: WoonkamerlampenSfeervol. If you just created the scene or group you may have to restart Domoticz to make it become visible to dzVents.
i have read somewhere that the new foreach functionality is needed for this but i can not seem to find examples who use double data entries
@waaren, can you see what is wrong
Code: Select all
local lookup = {
Woonkamerlampen = "109" ,
WoonkamerlampenSfeervol = "114" ,
}
return {
active = true,
on = {
-- de devices die dit script triggeren
devices = {
'Vitrinekast' ,
},
},
execute = function(domoticz, trigger)
for naam, id in pairs(lookup) do
local device = domoticz.groups(naam)
local devicestatus = '10'
domoticz.log(device)
domoticz.log(devicestatus)
end
end
}
Re: for i in pairs and groups
Posted: Monday 01 July 2019 20:14
by waaren
Gravityz wrote: Monday 01 July 2019 17:56
if i want to use it with groups/scenes it does not work.
so if lookup contains devices and i use domoticz.devices it works
if lookup contains groups and i use domoticz.groups it does not work and the log complains about scenes/groups not existing but they do
what is wrong ?
do not see an immediate problem but hard to check without being able to check your config.
Can you check this and see if you find something in the log ?
Code: Select all
local lookup = {
Woonkamerlampen = 109 ,
WoonkamerlampenSfeervol = 114 ,
Zolder = 120,
}
return {
active = true,
on = {
-- de devices die dit script triggeren
devices = {
'Vitrinekast' , 'XB*'
},
},
execute = function( dz )
for name, id in pairs(lookup) do
local item = dz.groups(name)
if item then
dz.log('status of ' .. item.name .. ' (' .. id ..') is ' .. item.state)
else
dz.log('none existing Group')
end
end
end
}
Re: for i in pairs and groups
Posted: Monday 01 July 2019 20:42
by Gravityz
Weird, that seems to work
error is correct since Zolder is not existing
the only thing different is that you skipped the "" in the lookup table
Code: Select all
2019-07-01 20:18:45.762 Status: dzVents: Info: ------ Start internal script: test2: Device: "Vitrinekast (Aeonlabs Z-wave stick Gen5)", Index: 208
2019-07-01 20:18:45.763 Status: dzVents: Info: status of WoonkamerlampenSfeervol (114) is Off
2019-07-01 20:18:45.763 Status: dzVents: Info: status of Woonkamerlampen (109) is Off
2019-07-01 20:18:45.763 Status: dzVents: Info: none existing Group
2019-07-01 20:18:45.764 Status: dzVents: Info: ------ Finished test2
2019-07-01 20:18:45.763 Error: dzVents: Error: (2.4.24) There is no group or scene with that name or id: Zolder. If you just created the scene or group you may have to restart Domoticz to make it become visible to dzVents.
i made my script a lot smaller and adjusted it to make it look almost like yours.
this is still crashing, i really can not see the problem
Code: Select all
local lookup = {
Woonkamerlampen = 109 ,
WoonkamerlampenSfeervol = 114 ,
}
return {
active = true,
on = {
-- de devices die dit script triggeren
devices = {
'Vitrinekast' ,
},
},
execute = function( dz )
for name, id in pairs(lookup) do
local item = dz.groups(name)
dz.log(item)
end
end
}
Code: Select all
2019-07-01 20:39:51.534 Error: dzVents: Error: (2.4.24) An error occurred when calling event handler test
2019-07-01 20:39:51.535 Error: dzVents: Error: (2.4.24) ...omoticz/dzVents/runtime/device-adapters/group_device.lua:65: attempt to concatenate a nil value
Re: for i in pairs and groups
Posted: Monday 01 July 2019 20:45
by Gravityz
and these errors
looks like dzvents is acting up
Code: Select all
2019-07-01 20:44:01.107 Error: dzVents: Error: (2.4.24) No value given for 'repeatAfterXXX' command
2019-07-01 20:44:01.107 Error: dzVents: Error: (2.4.24) No value given for 'repeatAfterXXX' command
2019-07-01 20:44:01.107 Error: dzVents: Error: (2.4.24) No value given for 'repeatAfterXXX' command
2019-07-01 20:44:01.107 Error: dzVents: Error: (2.4.24) No value given for 'repeatAfterXXX' command
2019-07-01 20:44:01.107 Error: dzVents: Error: (2.4.24) No value given for 'repeatAfterXXX' command
2019-07-01 20:44:01.107 Error: dzVents: Error: (2.4.24) No value given for 'repeatAfterXXX' command
2019-07-01 20:44:01.107 Error: dzVents: Error: (2.4.24) No value given for 'forXXX' command
2019-07-01 20:44:01.107 Error: dzVents: Error: (2.4.24) An error occurred when calling event handler test
2019-07-01 20:44:01.107 Error: dzVents: Error: (2.4.24) /usr/local/domoticz/dzVents/runtime/TimedCommand.lua:190: attempt to perform arithmetic on local 'value' (a nil
Re: for i in pairs and groups
Posted: Monday 01 July 2019 20:53
by waaren
Gravityz wrote: Monday 01 July 2019 20:42
i made my script a lot smaller and adjusted it to make it look almost like yours.
this is still crashing, i really can not see the problem
Code: Select all
local lookup = {
local item = dz.groups(name) -- you make item the group object with all its attributes and functions
dz.log(item) -- What do you want to display ?? if you want the name then dz.log(item.name) is a better choice
Re: for i in pairs and groups
Posted: Monday 01 July 2019 21:03
by Gravityz
i think that is the problem
item gives errors but item.name only the name
still it is strange that it does not need the .name when i use this on dz.devices(name)
is this done intentionally
group
no .name gives everything about the group(but the name)
.name give the name
device
no .name gives the name of the device
.name probalbly also gives the name
also it is perhaps better to skip name as a variable because it gets confusing name.name ????
Re: for i in pairs and groups
Posted: Monday 01 July 2019 22:10
by waaren
Gravityz wrote: Monday 01 July 2019 21:03
still it is strange that it does not need the .name when i use this on dz.devices(name)
I don't understand what you mean with this.
I see the similar type of problems if you use something like
or
Re: for i in pairs and groups [Solved]
Posted: Tuesday 02 July 2019 15:35
by Gravityz
i meant i thought
for group
local item = dz.groups(name)
dz.log(item.name)
but for item this works (but it is not)
local item = dz.devices(name)
dz.log(item)
anyway it is fixed now and i can read the groups also.