Skip to content

Fix preset.sh returning invalid http response#219

Open
mcarbonne wants to merge 1 commit into
roleoroleo:masterfrom
mcarbonne:fix_ptz_goto_preset
Open

Fix preset.sh returning invalid http response#219
mcarbonne wants to merge 1 commit into
roleoroleo:masterfrom
mcarbonne:fix_ptz_goto_preset

Conversation

@mcarbonne
Copy link
Copy Markdown

@mcarbonne mcarbonne commented Apr 29, 2026

Since a recent update of the firmware on my camera, I had a lot of error logs in my home assistant instance :

Failed to parse headers (url=http://XXXX/cgi-bin/preset.sh?action=go_preset&num=0): [MissingHeaderBodySeparatorDefect()], unparsed data: 'PTZ_CMD_GOTO_POS pPtzInfo->nXPos=1750 ,pPtzInfo->nYPos=1365\nContent-type: application/json\r\n\r\n'
Failed to parse headers (url=http://XXX/cgi-bin/preset.sh?action=go_preset&num=1): [MissingHeaderBodySeparatorDefect()], unparsed data: 'PTZ_CMD_GOTO_POS pPtzInfo->nXPos=1448 ,pPtzInfo->nYPos=159\nContent-type: application/json\r\n\r\n'

To reproduce the issue without home assistant :

$ curl -vvv -u "XXXX:XXXX" "http://XXXXX/cgi-bin/preset.sh?action=go_preset&num=0"
* Host XXXXXXX was resolved.
* IPv6: (none)
* IPv4: X.X.X.X
*   Trying X.X.X.X:X..
* Connected to XXXXX (X.X.X.X) port X
* Server auth using Basic with user 'admin'
> GET /cgi-bin/preset.sh?action=go_preset&num=0 HTTP/1.1
> Host: XXXXX
> Authorization: Basic xxxx
> User-Agent: curl/8.5.0
> Accept: */*
> 
< HTTP/1.1 200 OK
* Header without colon
* Closing connection
curl: (8) Header without colon

I found the culprit. For whatever reason, ptz binary do output something on stdout so I redirected the output to /dev/null.

[root@XXX]# ptz -f /mnt/mmc/sonoff-hack/etc/ptz_presets.conf -a go_preset -n 0
PTZ_CMD_GOTO_POS pPtzInfo->nXPos=1750 ,pPtzInfo->nYPos=1365

I also fixed a bash syntax error in the same file.
Maybe having shellcheck running in a github action would be a good idea, I can open another PR regarding this point (but this PR focuses on fixing the bug only)

@mcarbonne
Copy link
Copy Markdown
Author

@roleoroleo the fix has been running for a few days without any issues on my setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant