Extract value from json

Hi guys,
I searched in the various old posts but there is nothing that is simple enough for me to be able to integrate what I will try to summarize as briefly as possible.

The goal is to bring two values ​​of my central heating unit into a two different Sensor Widged or into a new Custum widget.
These values ​​are the Internal Temperature and the Set Temperature.

Since the heating system is connected online, after much research I managed to find the http string to get these values.
Through the Html command, I receive a JSON response from the broswer in which are listed, (among other Data), the internal temperature and the set temperature.

Please, is there anyone who is able to extract data from the Json response, so that it can be displayed into a widget within HomeGenie?

Below is a part of the Json response that contains the data set for the internal temperature (roomTemp) and set temperature (ConfortTemp Value).
{ “Mode”: 2, “allowedModes”: [0,1,2,5], “outsideTemp” 7.0, “holidayEnabled”: false, “holidayUntil”: “0001-01-01T00: 00: 00”, " dhwTemp “: {” min “: 35.0,” max “: 65.0,” value “: 35.0,” prevValue “0.0,” step “: 0.0},” flameSensor “: false,” dhwDisabled “: false,” zones " { “mode”: { “allowedOptions”: [2.3], “value”: 2}, “comfortTemp”: { “min”: 10.0, “max”: 30.0, “value”: 24.0, “prevValue” : 0.0, “step”: 0.0}, “desiredTemp” 0.0, “roomTemp”: 21.9, “derogaTemp”

Have you looked at modifying the Weather program. That might be suitable for your project.

Hi Peter,
exactly… I looked at the weather program and other old posts that talk about similar situations. But the indications are too general to succeed with my knowledge.
Maybe you are able to do this?

It was the first program that came to mind that manipulated JSON strings. Have you considering deploying MQTT and publishing the results to HG. Again this is only a suggestion on first read. Maybe other users might have a more practical suggestion.

I was able to parse a similar JSON string like this:

   var poolcontrollerData = Net.WebService(webserviceurl).GetData();
   string currentwatts = poolcontrollerData["pump"]["1"]["watts"];

webserviceurl is a string variable containing the REST URI e.g. http://hostname:port/path

This was the only method I found that would work with my JSON string because the node names are numeric.

Thank you very much for your seggestion!
I just sat in front of the PC, Jay, I’ll try your suggestion immediately and let you know my results.


Unfortunately I’m continuing to make attempts, because for the moment I get the following error:

"The best overloaded method match for` string.this [int] 'has some invalid arguments "

I’m trying to figure out if the reason for this error is due to the incorrect insertion of the Json data that I have to query. (I am currently trying the roomTemp value)

I will update you as soon as (hopefully), I will be able to use Joe’s String.

C# programs reference Newtonsoft.Json package, so you can do something like this:

var s = "{\"Mode\":2,\"allowedModes\":[0,1,2,5],\"outsideTemp\":7.0,\"holidayEnabled\":false,\"holidayUntil\":\"0001-01-01T00: 00: 00\",\"dhwTemp\":{\"min\":35.0,\"max\":65.0,\"value\":35.0,\"prevValue\":0.0,\"step\":0.0},\"flameSensor\":false,\"dhwDisabled\":false,\"zones\":{\"mode\":{\"allowedOptions\":[2.3],\"value\":2},\"comfortTemp\":{\"min\":10.0,\"max\":30.0,\"value\":24.0,\"prevValue\":0.0,\"step\":0.0},\"desiredTemp\":0.0,\"roomTemp\":21.9}}";

dynamic d = JObject.Parse(s);
Program.Notify("Test3", d.zones.comfortTemp.value.ToString());

Here in s you should place response from your heating unit server and adjust d.zones.comfortTemp.value to reflect actual response from server.

That’s exactly what we’ve been missing here. Straight to the point solutions.