0
Under review

Help on getting data from http response

Dave De Busschere 5 years ago in Devices / Http updated by Ricardo Pinto | visiontech pt 5 years ago 57

I'm  trying to get data from the respnonse "actualvolume" 

I've been exploring the forum here but i can't figure out what i'm doing wrong.


Parse type: Jhson

I get this response:

{"?xml":{"@version":"1.0","@encoding":"UTF-8"},"volume":{"@deviceID":"C4F312D5994F","targetvolume":"16","actualvolume":"16","muteenabled":"false"}}

Image 2282

Image 2283

Image 2284


Image 2288

Try to add a . in front of the command see if it helps like ".volume.actualvolume" Also good sites to check if your command works are https://jsonpath.curiousconcept.com/ or http://jsonpathfinder.com/

I just noticed that the Comfortclick, doesn't update the Json response, only the xml

The first line "Response Data" respons the actual volume = 14

the second line "Response Data Xml to Json" keeps the old respons " actual volume =     16????

I made a button and even if I press this it doesn't change.

The add a "." didn't work.

It also may be just .actualvolume because you already are sending /volume with the first part of the command. Have you tested it on a web browser, does it change the volume when you paste the command in there?

Can you copy past your Response Data Xml to Json here?

On the Sending menu, change Send Ciclically to true, and on the Cyclical Send Delay use 10s for example, so you can visualize the actual values at least with a 10s interval

I get this response:

{"?xml":{"@version":"1.0","@encoding":"UTF-8"},"volume":{"@deviceID":"C4F312D5994F","targetvolume":"16","actualvolume":"16","muteenabled":"false"}}

According to the JSONPath validator / Expression tester, to get the volume the Token Name is:

volume.actualvolume

So your Token is correct.

Probably the data is coming as a String and not as a Double.

Can you test with a String value?

Create two items, CurrentVolume and TargetVolume as Strings. Set the Token names to:

volume.actualvolume and volume.targetvolume

And test it out

no result:

tried: volume.actualvolume, .volume.actualvolume, .volume

When I look at the Bose website (special-types) it looks like the response is a flag?

sorry for being a amateur, but when I able to retrieve the responsdata and publish it in bos I'm on a go.

https://developer.bose.com/special-types


Hi,

I read the Bose API documentation, and they say that when using GET and POST commands, the data must be formatted in correct XML. So far so good.

But the point here, is that you get the correct response from the unit on the command. But when using the token, it doesn't extract the value. Right now I'm only concerned about the simple GET commands, and as soon as fixed move on to the POST data commands.

If you open the following URL in your browser http://192.168.2.209:8090/volume do you get an answer?

I suppose you get something like:

<?xml version="1.0" ?>
<volume deviceID="$MACADDR">
<targetvolume>$INT</targetvolume>
<actualvolume>$INT</actualvolume>
<muteenabled>$BOOL</muteenabled>
</volume>


Right?

Please copy past your XML answer here. The one you get from the browser, and the one you get on bOS command from "Response Data".

browser answer:

Bos answer:



Can you do a little test?

Create 2x Double values:

Name: Target Volume double

Token name: targetvolume

Name: Actual Volume double

Token name: actualvolume

Create 2x String values:

Name: Target Volume string

Token name: targetvolume

Name: Actual Volume string

Token name: actualvolume

I tested the response on several online converters / parsers, and I believe that:

If we keep the <?xml version...?> part, the correct token name should be volume.targetvolume and volume.actualvolume

{ 
    "?xml":{ 
        "@version":"1.0",
        "@encoding":"UTF-8"
    },
    "volume":{ 
        "@deviceID":"C4F312D5994F",
        "targetvolume":"16",
        "actualvolume":"16",
        "muteenabled":"false"
    }
}

But if you remove the <?xml version...?>, the correct token name is actually only targetvolume and actualvolume, just the text, with no "." after or before.

{
   "deviceID": "C4F312D5994F",
   "targetvolume": "10",
   "actualvolume": "10",
   "muteenabled": "false"
}

Can you test the token names only with targetvolume and actualvolume without any dots?

The double and strings values, are just to test the correct format. I supposed that the values from volume are coming as double values, but you can test both

Ah BTW, can you change the parser type to XML on the device?

And post again the responses?

And if you change back the parser to Json? The values show empty again?

Nothing changes

I turned the volume with the Bose remote up to 12, when I push the button in Bos Theme "Get current volume" the response data changes to 12 BUT the response Data Xml to Json remains on the 10!!!

I Get a reading (communication between the Bose and Bos). 


Can it be a bOS bug?

First: It doesn't make sense that the Response Data updates, and the Response Data Xml to Json doesn't... as it's supposed to be updated according to the Response Data received...everytime the Response Data changes, the Xml to Json is supposed to change also.

Second: It doesn't make sense the Tokens don't extract anything, because if we check the Json response in any online expression tester, the values are correct:

Using JSONPath Expression Tester web service (https://jsonpath.curiousconcept.com/), which is the one I use all the time to test the expressions before getting them on bOS, if you past the following expression:

{ 
   "?xml":{ 
      "@version":"1.0",
      "@encoding":"UTF-8"
   },
   "volume":{ 
      "@deviceID":"C4F312D5994F",
      "targetvolume":"16",
      "actualvolume":"16",
      "muteenabled":"false"
   }
}

And place volume.actualvolume on the Expression, you get this as an answer:

[ 
"16"
]

BUT, only by using the called JSONPath 0.2.5 or above... below that implementation, the response is empty.

bOS team, can you help us out here?

Hello,


Seems you were using wrong token name, you should be using XML parser and token name should be volume.actualvolume. Did you try this as well?


Best regards.

Ahhh almost there...

We've tested with the correct token on previous tests, but not with xml as parser.

Thanks for the help

Hi there,


It looks like that was the issue ;-)

Got response !!!!!!! :-))))))))))


Now we can start to make the Bose audio integration.

Keep you guys posted on the result.


Thaaaaaaaaanks, 

1.) Is there a way, to have Bos check the value instantly? I have activated the send cyclically but the value's don't change.

I put the volume to 10 but it stays on 14 until I push the button to send the command.

2.) Can I use a slider to change the volume? I have to integrate the slider value in a post <volume>value</volume>

I was expecting that the GET command would be updated with the cyclical send...

If you test the url, does it change properly? If not, it's Bose who's not sending the correct values...

http://192.168.2.209:8090/volume

It work's didn't wait long enough :-)))

now I'm trying to post the volume value with an integer (slider or push button) to increase/decrease the volume?

+1

An easy way, but it needs to get adjusted and tested:

- Create a Volume Send integer under the BOSE device;

- Get the integer on the visualization and set it to Percent Setter on the Control Type;

- On the Status Values collection, create the values from 0 to 100, and the Unit to %

- Create a Task under the BOSE device; On the Trigger, use the Volume Send integer, OnChange, AllowRetrigger;

- On the Command of that task, use Run and choose the POST command which sends the volume

- On your POST command of the volume, on the Post Data stuff, use the Properties on the String Editor, to set the Volume Send integer; And on the POST text, instead of using static value for the volume, use the %0 pointer so that it can use the value coming from the Volume Sent integer;

- Likewise, you need to use a task to cyclical get the current volume, and update the status of the "button"

I've posted a more complex way a few minutes ago, but now it doesn't make sense so I deleted the post

If you need more steps, instead of just 10% step, change the Bar Steps on the button visualization, from 10, to 100 (for 1% step), or 20 (for a 5% step).

Test it, and/or adapt the example

Obrigado Ricardo,

But I think due to my lack of knowledge, I'm missing some things.

According to our discription I made it as follow:




 

Hi,

I think you're missing some spots there:

On the 3rd image, the integer doesn't need to have a reference

And on the last image, you created a command called task, but it's supposed to be a task and not a command.

So try this:

- On the Integer, delete the reference, leave it empty

- Delete the Command "Task" you created

- Create a Task node, not a command, and call it something like Volume update task

- On that Task, set the Trigger as your Devices\BOSE livestyle650\Integer.Value (set it to OnChange, AllowRetrigger)

- Below, on the Commands of the task, click Add, Run, select your POST vol., choose Function Send (it's the only option).

And test it :) Hope it works

Bom dia Ricardo,

About the task is where i get confused, thats why i made a command.

I made the task node, but i can't configure anyrhing, settings is empty?

Do i need to insert a command in the task node? 


Bom dia Dave,

I'm terrible sorry... I call it Task, but in fact it's called Program, DUH! It's a Program task basically...

So resuming:

- Create a Program, not a command, and call it something like Volume update

- On that Program, set the Trigger as your Devices\BOSE livestyle650\Integer.Value (set it to Condition: ValueChanged(OnChange), and click on the AllowRetrigger)

- Below, on the Commands of the Program, click Add, Run, select your POST vol., choose Function Send (it's the only option).

Now this is it! I think... :D

+1

Muito obrigado Ricardo,

It works :-))))))

Excellent!

I'm glad that it helped. Does the cyclical get the volume work well also, and update the visualization?

Best regards 

The value on the integer (button) doesn't change when i use the BOSE remote or app?

I'm trying with the programm but no result so far.

the POST and GET command interfear eachother. When i change the value in the BOSE app to it automaticly changes back to the comfort click value. Because the integer didn't change to the BOSE app vol.

Hi,

Probably we're missing something, because POST and GET command is not supposed to interfere with each other.

Can you export your implementation, even if it's not complete, so we can double check?

Best regards

J2043-BOSE lifestyle650.bos

solved the interfear, it was actualy that the Bos was sending his value toward the BOSE.

But i'm still not able to make the Bos visual (Integer) to change to the reading from the BOSE


It just stays on the setting i last used in Bos, so if i change the volume with the BOSE remote, i do get the value with the GET command but i don't see how i can make the Integer change to the actual reading.


Best Regards,

Hi,

Try this....

You are using Double values to get the data, and I was expecting integers, so I wasn't getting there...

Import this example and test it.

- Insert the "Volume button" double on the visualization;

- I used a Percentage template for the default value;

- Change the style to manual;

- On the Status Values create from 0 to 100;

- Set Show Bar to True;

- Choose 0 as Decimal places;

- Choose Control Type as Percent Setter;

I suppose that when the "actual" double updates, or with cyclical call, the volume button value will update.

For that, the Program gets the "actual" double as trigger, and sets that value to the button. So if you have cyclical get active for the volume, in theory the button in the visualization should change also.

Best regards

Casa-BOSE lifestyle650.bos

Hi Recardo,

I get en "internal server error" message when:

1. i change volume with the BOSE remote

2. when i change volume with the visualization

But i do get following:

- the value in the visualizations changes when i use the BOSE remomote ;-)

- when i use the visualization to change the volume i get the error message. BUT the volume of het BOSE won't change.

Hi Recardo,

Got it working.

I put everything on integer instead of double. 

Thanks for al the effort you put into it.

Hi, 

I can use integers as we to retrieve the values.

If this is easier I'll change everything to integers ( can also use strings if needed).

Regards,


Bom dia Ricardo,

Now we (you and me) got the volume control to work, I'm moving to the next part MUTE and ON/OFF.

I don't see how I input the key_value and key_status in the post data?

<key state="$KEY_STATE" sender="$KEY_SENDER">$KEY_VALUE</key>

(At he bottom of this message is my input), without result.

I also changed the $key_value with "MUTE" and $KEY_STATE with"press".


Muito obrigado,

Here is the list reference from Bose:


+1

Hi Dave,

Reading the data, if not mistaking, you should send the following :

<key state="press" sender="Gabbo">MUTE</key>

Regards,

Hi thanks,

It was the "Gabbo" I forgot 

It works.

+1

LOL! What the hell is "Gabbo"? Liked the funny joke on BOSE API documentation...


Sorry to be late, wasn't able to come back before :-)


Fabien Fuster is another advanced user Dave. Any hints from him, are right in the spot.

You're in the right track, soon you'll be able to dominate the BOSE integration :-D

Best regards

Hi there,

I got quite a lot working on the BOSE, Burt I'm stuck with retrieving some data/respons.

I would like to see what source or radio station is playing.

I got the GET command to work and receive the xml respons but when I try to isolate the specific data I get lost (no respons).

Here are the screen shots from the BOSE api site with the commands

Someone a clue??


I'm about to post soon the integration :-)




Hi Dave,

Can you post a copy of your real xml answer. I will try to help out from there..

Hi,

Can you test with source, instead of nowPlaying.source? This is to extract the source input name.

If you want to extract the station name, can you test with token stationName?

Best regards

hi Ricardo,

no luck . But previous to get the volume  i had to use the token: volume.targetvolume

So i tried here for the "stationname" what you typed and also token nowplaying.stationname,  now_playing.stationname,  nowplaying.contentitem.stationname

All without result, hmmmm?

Please take note on characters, some are lowercase, and other uppercase.

I've parsed the xml response to json, and get correct answers with the following token names:

nowPlaying.ContentItem.source

nowPlaying.stationName

Can you copy paste them and test? Don't write them down in just lowercase, copy them as I wrote, as it has upper and lowercase on the API documentation

nope no luck there. could it be that the response is a text instead of a number (value)?

I think so, those values are supposed to be strings, so if you're using integer or double it won't work...

Test it out with strings, and use the token names I've wrote, and be careful with the uppercase and lowercase characters.

BR

I was using strings, but I just saw that there still was one uppercase fault.


Got it working.

Coming close to an end here, THANKS


Case sensitive stuff is always tricky :-D

Best of luck to finish the integration. We're here to help.

Best regards

Thanks,

I'd like to make a spacing between the top 3 buttons and the preset buttons.

Do you know how I can make a divider and how to make the string respons 3 column wide?

Ffor the looks it can be with a spacer ( half or 1/3 of a button height) OR use the respons string with the radiostation as a spacer but in this case it has to be 3 column wide?

+1

Hi,

You can have different approaches:

The basic one, is to add a spacer, with the same size of the others: In an empty space of the frame, click on "Add Other Control", choose Spacer, and move the spacer up where you want it, after the 3 buttons.

If you want a spacer look, but thinner, you need to create a frame, set it to Horizontal orientation, with 1 Row, 3 Columns, move the 3 buttons to the frame, select the frame, and on the Menu properties set Bottom Menu to true. Then change the percentage to create an empty space. Please note that in this situation the buttons will look smaller due to the shrinking process.

I'd go for the option 1, to add a simple spacer, so you can keep a standard look.

BR

+1

Always to quick for me Ricardo ! Well done since 2 days.... 

To add on the last post, I do sometime the following :

I create a main frame of 1 column and as many row as I need. Then on each row I add a new frame that I can again subdivide to as many column and row I need. Doing so, you can have a feedback full wide on row 1 and many control knobs on row 2 for example...same can be done per "box".

Don't pay attention to the content, this is used as a test screen on my end :

other example:

Great thanks guys, 

now i got it, how the layout works.

+1


This time I was quicker than you 😁

Well done Fabien, indeed the approach of "frame inside frame inside frame..." is actually one good option to create different layouts.

Thanks for screenshot, it's clarifying about the frames concept.

Go Dave!

Best regards