Page 1 of 1
wild-char
Posted: Monday 13 January 2020 19:45
by yazul
Hi, everybody !
i don't understand why this sample script fails : user variable "presence_globale" doesn't matches the pattern "presence-*" ?
Code: Select all
return {
active= true,
on = {
variables= {
"presence-*"
}
},
logging= {
level= domoticz.LOG_DEBUG
},
execute = function(domoticz, variable)
domoticz.log("trigger variable "..variable.name.." = "..tostring(variable.value).." changed "..tostring(variable.changedalue));
end
}
here is the log :
2020-01-13 07:56:32.830 Status: dzVents: Info: Handling variable-events for: "presence_globale", value: "1"
2020-01-13 07:56:32.830 Status: dzVents: Info: ------ Start external script: essai.lua: Variable: "presence_globale" Index: 29
2020-01-13 07:56:32.830 Status: dzVents: Info: trigger variable presence_globale = 1 changed nil
2020-01-13 07:56:32.830 Status: dzVents: Info: ------ Finished essai.lua
My version :
Version: 4.10717
Build Hash: b38b49e
Compile Date: 2019-05-09 13:04:08
dzVents Version: 2.4.19
Re: wild-char
Posted: Monday 13 January 2020 20:05
by waaren
yazul wrote: ↑Monday 13 January 2020 19:45
i don't understand why this sample script fails : user variable "presence_globale" doesn't matches the pattern "presence-*" ?
From the script I cannot determine what it should print but changedalue does not exist as a valid method or attribute of an object of type variable. That is why you see nil.
See below script and some output of it. It might point you in the right direction.
Code: Select all
--[[
dz Essai
--]]
return {
active= true,
on = {
variables= {
"presence-*"
}
},
logging= {
level= domoticz.LOG_DEBUG
},
execute = function(domoticz, variable)
-- changedalue does not exist as a valid method or attribute of an objkect of type variable
-- domoticz.log("trigger variable "..variable.name.." = "..tostring(variable.value).." changed " .. tostring(variable.changedalue));
domoticz.utils.dumpTable(variable)
domoticz.log("trigger variable "..variable.name.." = ".. tostring(variable.value).." changed ",domoticz.LOG_DEBUG)
end
}
log when triggered by setting variable to integer 6
- Spoiler: show
Code: Select all
2020-01-13 09:19:19.808 Status: dzVents: Info: Handling variable-events for: "presence-test", value: "6"
2020-01-13 09:19:19.808 Status: dzVents: Info: ------ Start internal script: dz Essai : Variable: "presence-test" Index: 2
2020-01-13 09:19:19.808 Status: dzVents: > nValue: 6
2020-01-13 09:19:19.808 Status: dzVents: > set()
2020-01-13 09:19:19.808 Status: dzVents: > isHTTPResponse: false
2020-01-13 09:19:19.808 Status: dzVents: > isGroup: false
2020-01-13 09:19:19.808 Status: dzVents: > lastUpdate:
2020-01-13 09:19:19.810 Status: dzVents: > name: presence-test
2020-01-13 09:19:19.810 Status: dzVents: > value: 6
2020-01-13 09:19:19.810 Status: dzVents: > isVariable: true
2020-01-13 09:19:19.810 Status: dzVents: > rename()
2020-01-13 09:19:19.810 Status: dzVents: > isTimer: false
2020-01-13 09:19:19.810 Status: dzVents: > type: integer
2020-01-13 09:19:19.810 Status: dzVents: > id: 2
2020-01-13 09:19:19.810 Status: dzVents: > isSecurity: false
2020-01-13 09:19:19.810 Status: dzVents: > changed: true
2020-01-13 09:19:19.810 Status: dzVents: > isScene: false
2020-01-13 09:19:19.810 Status: dzVents: > baseType: variable
2020-01-13 09:19:19.810 Status: dzVents: > isDevice: false
2020-01-13 09:19:19.810 Status: dzVents: Debug: trigger variable presence-test = 6 changed
2020-01-13 09:19:19.810 Status: dzVents: Info: ------ Finished dz Essai
log when triggered by setting variable to string 'present'
- Spoiler: show
Code: Select all
2020-01-13 09:22:19.358 Status: dzVents: Info: Handling variable-events for: "presence-test string", value: "present"
2020-01-13 09:22:19.358 Status: dzVents: Info: ------ Start internal script: dz Essai: Variable: "presence-test string" Index: 3
2020-01-13 09:22:19.358 Status: dzVents: > value: present
2020-01-13 09:22:19.359 Status: dzVents: > isSecurity: false
2020-01-13 09:22:19.359 Status: dzVents: > id: 3
2020-01-13 09:22:19.359 Status: dzVents: > type: string
2020-01-13 09:22:19.359 Status: dzVents: > isTimer: false
2020-01-13 09:22:19.359 Status: dzVents: > isVariable: true
2020-01-13 09:22:19.361 Status: dzVents: > set()
2020-01-13 09:22:19.361 Status: dzVents: > isDevice: false
2020-01-13 09:22:19.361 Status: dzVents: > isScene: false
2020-01-13 09:22:19.361 Status: dzVents: > isHTTPResponse: false
2020-01-13 09:22:19.361 Status: dzVents: > isGroup: false
2020-01-13 09:22:19.361 Status: dzVents: > rename()
2020-01-13 09:22:19.361 Status: dzVents: > name: presence-test string
2020-01-13 09:22:19.361 Status: dzVents: > baseType: variable
2020-01-13 09:22:19.361 Status: dzVents: > changed: true
2020-01-13 09:22:19.361 Status: dzVents: Debug: trigger variable presence-test string = present changed
2020-01-13 09:22:19.361 Status: dzVents: Info: ------ Finished dz Essai
Re: wild-char
Posted: Wednesday 15 January 2020 17:21
by yazul
waaren wrote: ↑Monday 13 January 2020 20:05
yazul wrote: ↑Monday 13 January 2020 19:45
i don't understand why this sample script fails : user variable "presence_globale" doesn't matches the pattern "presence-*" ?
From the script I cannot determine what it should print but changedalue does not exist as a valid method or attribute of an object of type variable. That is why you see nil.
Thanks for your answer...
The problem (except changedalue, sorry for that) is :
i want to select only variables beginning with "presence-".
But the script is triggered for "presence_globale" wich doesn't begin with the search pattern...
hyphen is not underscore !
what did i missed ?
Re: wild-char
Posted: Wednesday 15 January 2020 17:42
by waaren
yazul wrote: ↑Wednesday 15 January 2020 17:21
The problem (except changedalue, sorry for that) is : i want to select only variables beginning with "presence-".
But the script is triggered for "presence_globale" wich doesn't begin with the search pattern... what did i missed ?
You did not miss anything. This is a bug that existed in the code until some months ago. It was corrected in a recent beta
Re: wild-char [Solved]
Posted: Thursday 16 January 2020 11:26
by yazul
Thanks