Unable to find value for JSON path
Hi, I'm currently attempting to use this plugin to control my home automation system (Home Assistant)
When using the API to toggle an appliance, the following JSON response comes back from the API:
[
{
"entity_id": "switch.desk_lamp_outlet_1",
"state": "on",
"attributes": {
"outlet_in_use": true,
"icon": "mdi:desk-lamp",
"friendly_name": "Desk Lamp"
},
"last_changed": "2022-12-10T20:15:07.713523+00:00",
"last_updated": "2022-12-10T20:15:07.713523+00:00",
"context": {
"id": "REDACTED",
"parent_id": null,
"user_id": "REDACTED"
}
}
]
Logic would tell me that the JSON Path for the state value should be $.[0].state or $[0]['state']; however, neither of these are working, and neither is setting the path to state or leaving the path empty and making the plugin look for the expected value of on.
I'm sure there's something simple I'm missing here.
@roberthawdon any resolution from your end?
@IBC-IT No, in the end I found a better plugin for my use case of controlling Home Assistant: https://github.com/cgiesche/streamdeck-homeassistant
However, for controlling other APIs, this issue would still stand.
My apologies for not responding sooner - I've not worked on the plugin since I originally submitted it elgato to be distributed.
The json path code is just the included streamdeck utility javascript, here. It's fairly basic in functionality. I have not tested, but it looks like [0].state might have worked in your instance.
@mjbnz So in my case, with response of: [{"component":"main","capability":"mediaInputSource","command":"setInputSource","arguments":["HDMI3"]}]
Would not the path be [0].arguments[0] to determine whether it's HDMI 1,2,3 etc.?
Still not working in my case...

Also, should the "value" fields include quote marks or not?
Would not the path be
[0].arguments[0]to determine whether it's HDMI 1,2,3 etc.?Still not working in my case...
Yes, that's how I'd read it. looks like the streamdeck SDK's getProperty() doesn't deal with that correctly (an array at the base).
Absolutely no promises, but I'll try to get some time to look at that this weekend.
Also, should the "value" fields include quote marks or not?
No. it's supposed to be for basic string matching if included. with field defined, it tries to parse as json, without, it looks for the text in the response body. code for that is here.
@mjbnz thank you!
I also don't understand why it does not work when the path is empty, and the value is entered as simply HDMI2
Would that not bypass any array at the base?
@mjbnz any hope you had a chance to look at this?
Has anyone else been able to find a solution?
Has anyone else been able to find a solution?
I wasn't able to find time last month, more pressing items got in the way. There's a few little items I'd like to sort out with the plugin. Give me a couple of weeks and I should be able to find some time to look into it.