Page 1 of 1

triggerInfo.type nil when callback

Posted: Monday 06 April 2020 13:49
by hestia
Hi

It seems that dzVents 3 introduce that "triggerInfo.type" is null when the script is triggered by a callback

Code: Select all

local LMS_player= "b8:27:eb:7d:00:36"  -- LMS Player MAC Address for json commands
local LMS_serverPort='erato:9000'  -- LMS Server Hostname and HTTP Port Number

local TESTTIMER_IDX = 207 -- dummy device to triger the script w/o waiting the script timer ; for testing

return {
    logging = {
	level = domoticz.LOG_DEBUG, -- Select one of LOG_DEBUG, LOG_INFO, LOG_ERROR, LOG_FORCE to override system log level -- normal = LOG_ERROR
	     },
    on = {
        devices = {TESTTIMER_IDX},
    httpResponses = {'TEST'}
		},

 execute = function(dz, item, triggerInfo)
    _G.logMarker =  dz.moduleLabel -- set logmarker to scriptname
    local LOG_LEVEL = dz.LOG_DEBUG -- LOG_INFO, LOG_DEBUG, LOG_ERRORLOG_FORCE,   - normal = LOG_INFO
    
    if triggerInfo.type == nil then
        dz.log(dz.moduleLabel .. ' triggered by triggerInfo.type = nil !!!', LOG_LEVEL)        
    else
        dz.log(dz.moduleLabel .. ' triggered by ' ..  triggerInfo.type, LOG_LEVEL)
    end

    if item.isHTTPResponse then -- the callback to check error code and player status
        dz.log('HTTPResponse', LOG_LEVEL)
    else   
        local httpLMS='http://'..LMS_serverPort..'/status.html?'
        local shufflePlaylist='p0=playlist&p1=shuffle&p2=0&player='..LMS_player
        dz.openURL({url = httpLMS .. shufflePlaylist, callback = 'TEST'})
    end

end
} 

Code: Select all

2020-04-06 13:44:36.637 Status: dzVents: Info: Handling events for: "test detecteur 207", value: "On"
2020-04-06 13:44:36.637 Status: dzVents: Info: ------ Start internal script: zTriger: Device: "test detecteur 207 (Dummy1)", Index: 207
2020-04-06 13:44:36.637 Status: dzVents: Debug: zTriger: zTriger triggered by device
2020-04-06 13:44:36.638 Status: dzVents: Debug: zTriger: OpenURL: url = http://erato:9000/status.html?p0=playlist&p1=shuffle&p2=0&player=b8:27:eb:7d:00:36
2020-04-06 13:44:36.638 Status: dzVents: Debug: zTriger: OpenURL: method = GET
2020-04-06 13:44:36.638 Status: dzVents: Debug: zTriger: OpenURL: post data = nil
2020-04-06 13:44:36.638 Status: dzVents: Debug: zTriger: OpenURL: headers = nil
2020-04-06 13:44:36.638 Status: dzVents: Debug: zTriger: OpenURL: callback = TEST
2020-04-06 13:44:36.638 Status: dzVents: Info: zTriger: ------ Finished zTriger
2020-04-06 13:44:36.639 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-04-06 13:44:37.347 Status: dzVents: Info: Handling httpResponse-events for: "TEST"
2020-04-06 13:44:37.347 Status: dzVents: Info: ------ Start internal script: zTriger: HTTPResponse: "TEST"
2020-04-06 13:44:37.347 Status: dzVents: Debug: zTriger: zTriger triggered by triggerInfo.type = nil !!!
2020-04-06 13:44:37.347 Status: dzVents: Debug: zTriger: HTTPResponse
2020-04-06 13:44:37.347 Status: dzVents: Info: zTriger: ------ Finished zTriger
Version: 2020.1 (build 11875)
Build Hash: 8c5c9826f-modified
Compile Date: 2020-04-03 08:25:18
dzVents Version: 3.0.2

Re: triggerInfo.type nil when callback

Posted: Monday 06 April 2020 14:35
by waaren
hestia wrote: Monday 06 April 2020 13:49 It seems that dzVents 3 introduce that "triggerInfo.type" is null when the script is triggered by a callback
Thx for reporting. Is indeed a bug.
Will be fixed in one of the next beta's. Until then you can add this yourself in <domoticz dir>/dzVents/runtime/constants.lua or use
the method with isHTTPResponse as described in this example

Re: triggerInfo.type nil when callback

Posted: Monday 06 April 2020 21:37
by hestia
Thanks waaren
I've change my script. Fortunately I've only one in that case - and few scripts anyway;-)