Repository navigation
Description
Bug report, debug log and your config file (FULL LOGS ARE MANDATORY)
Context:
I'm was making HA integration that can communicate with HyperHDR through MQTT but I bumped into some critical bugs.
- I can't control other instances LED Device components, I tested with MQTT Clients to confirm the issue source.
- MQTT doesn't reconnect when host shutdown.
I need to uncheck and check the MQTT Enable to reconnect.
Steps to reproduce
- Switch to instance 1 using mqtt, json command
- the hyperhdr logs report the the selected instance has been changed to 1
- Turn off the LED using
HyperHDR's componentscommand with MQTT.
What is expected?
The selected index LED Turn off
What is actually happening?
-- The instance 0 what turned off.
-- In the logs before it reports the led turned off, It switch back to instance 0 all the time.
More-info
So it seems that sending MQTT command always switch back to instance 0 and reports in the logs before each command:
2023-09-21T10:46:11.278Z [HTTPJSONRPC] (JsonAPI.cpp:97) Client '::1' switch to HyperHDR instance 0
2023-09-21T10:46:11.279Z [HTTPJSONRPC] (JsonAPI.cpp:97) Client '::1' switch to HyperHDR instance 1
2023-09-21T10:46:14.918Z [HTTPJSONRPC] (JsonAPI.cpp:97) Client '::1' switch to HyperHDR instance 0
2023-09-21T10:46:14.919Z [SMOOTHING0] Clearing queued colors before: enabling
2023-09-21T10:46:14.919Z [SMOOTHING0] Smoothing queue is cleared
2023-09-21T10:46:14.919Z [LEDDEVICE_WS281X] (LedDevice.cpp:103) Enable device
2023-09-21T10:46:14.920Z [LEDDEVICE_WS281X] (LedDevice.cpp:333) Switch on
2023-09-21T10:46:14.920Z [LEDDEVICE_WS281X] (LedDevice.cpp:409) Power On
Another issue don't know if I should say bug or feature but when the MQTT Server drops HyperHDR Doesn't reconnect to MQTT.
System
I also tested this in the the last build https://github.com/awawa-dev/HyperHDR/actions/runs/6091102810
HyperHDR Server:
- Build: (HEAD detached at b8c7f04) (Awawa-3141e80/b8c7f04-1676222403)
- Build time: Feb 12 2023 17:40:25
- Git Remote: https://github.com/awawa-dev/HyperHDR
- Version: 19.0.0.0
- UI Lang: auto (BrowserLang: ar)
- UI Access: default
- Avail Capt: Linux (V4L2)
- Database: read/write
HyperHDR Server OS:
- Distribution: Ubuntu 20.04.4 LTS
- Architecture: arm64
- CPU Type: Raspberry Pi 4 Model B Rev 1.5
- CPU Revision: d03115
- CPU Hardware: BCM2835
- Kernel: linux (6.1.21-v8+ (WS: 64))
- Qt Version: 5.15.2
- Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36
Activity
awawa-dev commentedon Sep 21, 2023
FULL LOGS ARE MANDATORY and the 2 duplicates auto-reconnect feature request: #570
xZetsubou commentedon Sep 21, 2023
Sorry, its because I explained what happening I didn't copy fully logs, As for duplicate I didn't notice sorry because of issue titles.
awawa-dev commentedon Sep 21, 2023
It works as intended: I didn't design this part, but I understand what it was about. Both the UI and mqtt use the API server, and this behavior is enforced by the UI because we don't want the user to be stuck on the instance he just stopped. Hence, it switches to instance 0 which cannot be deleted or stopped. The question is, do you really need to stop the entire instance? You can easily enable/disable all components of all instances using: HyperHDR's components -> All instances (global) or disable led/grabber in a given instance. Or just start it back up after stopping it and switch back to it.
xZetsubou commentedon Sep 21, 2023
The issue with using
All instances (global)that it disables the USB Capture too, turning it ON again causes black screen on TV for seconds., that why I only turn off LED Device since tuning the led device off won't interrupt the tv image.I assumed this is a bug because it doesn't behave like runs cmd with link. this is the way I use to turn off both LEDs.
awawa-dev commentedon Sep 21, 2023
Please explain which and how single commands (not multiple as it is not supported by MQTT, same behaviuor as JSON POST requests) behave differently when passed using MQTT and run via RPC, as I am not sure I understand this part. In code the command is simply forwarded from MQTT to API handler.
xZetsubou commentedon Sep 21, 2023
After more tests it seems yes both works the same way they both switch back to instance 0 before each command,
Because I was testing by running the command on my browser HTTP link
run it buttonthis how the request behave when I run the command through browser:with curl or mqtt they switch back to instance 0
If this is how it's works normally then sorry for reporting it as an issue.
awawa-dev commentedon Sep 21, 2023
As explained, switching to instance zero is normal, there are also multiply fuses in many parts of the code that prevents the json API from executing API commands for instances that have been stopped/removed, as in some situations an api vs core state mismatch may occur asynchronously and may lead to application crash.
xZetsubou commentedon Sep 22, 2023
Understood, then it seems using MQTT it's impossible to control other instances components and effects since it always switch back to default instance, I guess.
I don't understand what you mean here by saying
disable led in a given instanceto clarify I'm not turning off any instances here what I'm trying to do is switch to instance to disable led but since it always change to instance 0. if this behavior is normal then it's fine :)awawa-dev commentedon Sep 22, 2023
Post your full json api sequence you are sending via MQTT.
xZetsubou commentedon Sep 22, 2023
I send 2 payloads
First switch instance that I want control:
{ "command" : "instance", "subcommand" : "switchTo", "instance" : 1 }Then turn off led
{ "command":"componentstate", "componentstate": { "component":"LEDDEVICE", "state": false } }awawa-dev commentedon Sep 22, 2023
Thanks. I'll test it later and let you know next week. The instance switching should happen only when you stop or delete the instance. If confirmed, I'll probably implement accepting JsonArray with multiply requests /JsonObjects at once (with the same restriction as with passing multiply json commands via GET request) should solve it, which I planned some time ago.
awawa-dev commentedon Oct 1, 2023
The connection is reset after each command, so it behaves exactly like sending json via POST without maintaining the session. GET multi-commands are an exception here because from the beginning it was developed with different assumptions, but it has been described. I'm currently working on enabling multiple commands to be executed simultaneously in MQTT. I think it should be ready soon, I'll let you know.
[-]MQTT Bugs instance reset and no reconnect.[/-][+]Support for multiple API commands in one MQTT request[/+]