Page 1 of 1

item.ok no longer working?

Posted: Wednesday 08 May 2019 14:41
by doh
I've just upgraded Domoticz. I went to the new stable, but there were some issues (the CheckAuth issue), so I've gone to the latest Beta - v4.10705)

Previously I was using an HTTP callback and checking the result using .ok in the response object. Since the upgrade, it doesn't seem like .ok is being set, so as far as the script is concerned, all HTTP callbacks are failing (when, in fact, they aren't).

Anyone else seeing this?

How do I report this as a bug?

Re: item.ok no longer working?

Posted: Wednesday 08 May 2019 14:49
by doh
A bit more digging - it appears that .statusCode isn't being set (or, rather, is always 0), which is probably why .ok isn't being set properly either.

Re: item.ok no longer working?

Posted: Thursday 09 May 2019 0:44
by waaren
doh wrote: Wednesday 08 May 2019 14:49 A bit more digging - it appears that .statusCode isn't being set (or, rather, is always 0), which is probably why .ok isn't being set properly either.
Thx for reporting !

I did a quick check on this but cannot replicate with my test-set nor with my production scripts in version V4.10692 and version V4.10706
Can you please send me your script where you have this issue ?
Your profile states that you are on Linux. Can you also please elaborate a bit on what OS and which hardware ? It might help in identifying what happens.
To give some more info to work with, please add the line

Code: Select all

domoticz.utils.dumpTable(item)
in your script when you process the HTTPResponse.
Thx

Re: item.ok no longer working?

Posted: Thursday 09 May 2019 11:46
by gizmocuz
I added the dump table as you asked on the forum this is the result:
2019-05-09 08:12:16.215 Status: dzVents: Info: dumping item table:
2019-05-09 08:12:16.215 Status: dzVents: > ok: false
2019-05-09 08:12:16.215 Status: dzVents: > isDevice: false
2019-05-09 08:12:16.216 Status: dzVents: > protocol: HTTP/1.1
2019-05-09 08:12:16.216 Status: dzVents: > isScene: false
2019-05-09 08:12:16.216 Status: dzVents: > data:
2019-05-09 08:12:16.216 Status: dzVents: > isSecurity: false
2019-05-09 08:12:16.217 Status: dzVents: > trigger: mycallbackstring
2019-05-09 08:12:16.217 Status: dzVents: > isHTTPResponse: true
2019-05-09 08:12:16.217 Status: dzVents: > callback: mycallbackstring
2019-05-09 08:12:16.217 Status: dzVents: > isTimer: false
2019-05-09 08:12:16.217 Status: dzVents: > isGroup: false
2019-05-09 08:12:16.218 Status: dzVents: > baseType: httpResponse
2019-05-09 08:12:16.218 Status: dzVents: > isVariable: false
2019-05-09 08:12:16.218 Status: dzVents: > statusText: Couldn't connect to
2019-05-09 08:12:16.218 Status: dzVents: > statusCode: 7
2019-05-09 08:12:16.218 Status: dzVents: > headers:
2019-05-09 08:12:16.219 Status: dzVents: > _contentType:
2019-05-09 08:12:16.219 Status: dzVents: > isJSON: false
2019-05-09 08:12:16.220 Status: dzVents: Info: ------ Finished Script #1
Seems perfect here .... this is an internal curl error when i entered a wrong port number to connect to

Here is the dump when i push data to an influxDB:
2019-05-09 08:14:00.708 Status: dzVents: Info: dumping item table:
2019-05-09 08:14:00.708 Status: dzVents: > isTimer: false
2019-05-09 08:14:00.709 Status: dzVents: > data:
2019-05-09 08:14:00.709 Status: dzVents: > isScene: false
2019-05-09 08:14:00.710 Status: dzVents: > isGroup: false
2019-05-09 08:14:00.710 Status: dzVents: > isVariable: false
2019-05-09 08:14:00.711 Status: dzVents: > isDevice: false
2019-05-09 08:14:00.711 Status: dzVents: > ok: true
2019-05-09 08:14:00.712 Status: dzVents: > baseType: httpResponse
2019-05-09 08:14:00.712 Status: dzVents: > statusText: No Content
2019-05-09 08:14:00.713 Status: dzVents: > isHTTPResponse: true
2019-05-09 08:14:00.716 Status: dzVents: > _contentType: application/json
2019-05-09 08:14:00.717 Status: dzVents: > isJSON: false
2019-05-09 08:14:00.717 Status: dzVents: > isSecurity: false
2019-05-09 08:14:00.718 Status: dzVents: > trigger: mycallbackstring
2019-05-09 08:14:00.718 Status: dzVents: > callback: mycallbackstring
2019-05-09 08:14:00.719 Status: dzVents: > statusCode: 204
2019-05-09 08:14:00.719 Status: dzVents: > protocol: HTTP/1.1
2019-05-09 08:14:00.720 Status: dzVents: > headers:
2019-05-09 08:14:00.720 Status: dzVents: > X-Influxdb-Version: 1.5.3
2019-05-09 08:14:00.720 Status: dzVents: > Request-Id: a4e6275d-7221-11e9-acd7-000000000000
2019-05-09 08:14:00.721 Status: dzVents: > Content-Type: application/json
2019-05-09 08:14:00.721 Status: dzVents: > X-Request-Id: a4e6275d-7221-11e9-acd7-000000000000
2019-05-09 08:14:00.722 Status: dzVents: > Date: Thu, 09 May 2019 06:14:03 GMT
2019-05-09 08:14:00.722 Status: dzVents: > X-Influxdb-Build: OSS
2019-05-09 08:14:00.724 Status: dzVents: Info: ------ Finished Script #1

Re: item.ok no longer working?

Posted: Thursday 09 May 2019 11:49
by doh
Running on a Raspberry Pi:

Code: Select all

PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
Here's the output from dumptable:

Code: Select all

Debug: TadoGetStatus: Dump table <START>
> isScene: false
> isVariable: false
> isDevice: false
> data: OBFUSCATED, BUT AS EXPECTED
> json: OBFUSCATED, BUT AS EXPECTED
> _contentType: application/json;charset=UTF-8
> ok: false
> isJSON: true
> isTimer: false
> statusCode: 0
> baseType: httpResponse
> trigger: TadoGetZonesCallback
> isGroup: false
> headers:
>     Content-Encoding: gzip
>     Set-Cookie: AWSALB=OBFUSCATED; Expires=Thu, 16 May 2019 09:40:02 GMT; Path=/
>     Transfer-Encoding: chunked
>     Content-Type: application/json;charset=UTF-8
>     Strict-Transport-Security: max-age=31536000
>     X-Content-Type-Options: nosniff
>     Access-Control-Allow-Origin: *
>     X-Application-Context: application:production
>     Server: nginx
>     X-XSS-Protection: 1; mode=block
>     Cache-Control: no-cache, must-revalidate
>     ETag: W/"f5d00bb5d2a84ce5"
>     Connection: keep-alive
>     Date: Thu, 09 May 2019 09:40:02 GMT
> callback: TadoGetZonesCallback
> isSecurity: false
> isHTTPResponse: true
Debug: TadoGetStatus: Dump table <END>
Here's a snippet of code - basically the start of the callback handler for the URL call:

Code: Select all

		if (item.isHTTPResponse) then

		domoticz.log('HTTP Response code = ' .. tostring(item.statusCode),domoticz.LOG_DEBUG)
		
		-- Process TadoGetZonesCallback trigger event (Response to request for Zones list)
		
			if (item.trigger == 'TadoGetZonesCallback') then
				domoticz.log('Dump table <START>',domoticz.LOG_DEBUG)			
				domoticz.utils.dumpTable(item)
				domoticz.log('Dump table <END>',domoticz.LOG_DEBUG)
				if (item.ok) then -- success
The final check (item.ok) never works - as you can see - statusCode is set to 0 and ok set to false in the table dump.

Re: item.ok no longer working?

Posted: Thursday 09 May 2019 12:04
by waaren
doh wrote: Thursday 09 May 2019 11:49 The final check (item.ok) never works - as you can see - statusCode is set to 0 and ok set to false in the table dump.
Thx. From what I see here, it looks like you have a mismatch between the domoticz executable and HTTPResponse.lua

The dzVents subdirectory must be aligned with the version of domoticz.

Could it be that you updated the domoticz binary without aligning the dzVents subdrectory ? (This could happen when you compile locally and only copy the binary to your work directory)

Re: item.ok no longer working?

Posted: Thursday 09 May 2019 13:40
by doh
There was a bug that @gizmocuz has now fixed in latest Beta v4.10716