Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find value for JSON path #8

Open
roberthawdon opened this issue Dec 10, 2022 · 10 comments
Open

Unable to find value for JSON path #8

roberthawdon opened this issue Dec 10, 2022 · 10 comments

Comments

@roberthawdon
Copy link

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.

@IBC-IT
Copy link

IBC-IT commented Jan 30, 2023

@roberthawdon any resolution from your end?

@roberthawdon
Copy link
Author

@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.

@mjbnz
Copy link
Owner

mjbnz commented Jan 31, 2023

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.

@IBC-IT
Copy link

IBC-IT commented Jan 31, 2023

@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...

Screenshot 2023-01-30 at 5 46 51 PM

@IBC-IT
Copy link

IBC-IT commented Jan 31, 2023

Also, should the "value" fields include quote marks or not?

@mjbnz
Copy link
Owner

mjbnz commented Jan 31, 2023

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.

@IBC-IT
Copy link

IBC-IT commented Jan 31, 2023

@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?

@ukiews
Copy link

ukiews commented Feb 10, 2023

@mjbnz any hope you had a chance to look at this?

@ukiews
Copy link

ukiews commented Mar 15, 2023

Has anyone else been able to find a solution?

@mjbnz
Copy link
Owner

mjbnz commented Mar 15, 2023

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.

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

No branches or pull requests

4 participants