Parse json with special characters coming from Ubibot

Hello guys, I am integrating a sensor from Ubibot (WS1) to check temperature, humidity and most of all outside brightness. I received the info through a GET call at

The json received is in a pretty complicated format:

         "field5":"WIFI RSSI",
         "field6":"Vibration Index",
         "field8":"External Temperature Probe",
         "metadata":"{\"fn_th\":300,\"fn_light\":300,\"fn_mag\":0,\"fn_mag_int\":0,\"fn_acc_tap1\":0,\"fn_acc_tap2\":0,\"fn_acc_act\":0,\"fn_acc_min\":10,\"fn_bt\":0,\"fn_ext_t\":300,\"fn_battery\":7200,\"fn_dp\":900,\"cg_data_led\":1, \"wifi_mode\": 1, \"no_net_fn\": 1}",

I want to extract the info related to: “last_values”:"{“field1”:{“value”:20.041199,“created_at”:“2020-06-10T11:19:29Z”,“net”:“1”},“field3”:{“value”:808.320007,“created_at”:“2020-06-10T11:19:29Z”}…

But due to the usage of special characters (") I cannot find a way out… I am stuck to this…

# Integration with UBIBOT
  - platform: rest
    name: UBIBOT
    value_template: '{{ value_json.channels[0].last_value.field1 }}'

But it is absolutely NOT WORKING
Can somebody help me?

thanks very much!


So the problem is there is double JSON encoding going on here for many of these items, including last_values. Try this, e.g.:

    value_template: '{{ (value_json.channels[0].last_values|from_json).field1 }}'

Thanks Phil… you are a star… solved! I did tried as well with from_json command but I was not sure about the syntax.
Finally since I wanted to extract the “value” I justed added it at the end and it works:

value_template: '{{ (value_json.channels[0].last_values|from_json).field1.value }}'

thanks again


1 Like

Hi parabag, I just got a WS1 today, and HA yesterday. Is there any chance you could either post exactly what you did, or maybe PM me or something? I’m reasonably good with tech, but I’m lacking experience with HA and especially POST/GET with respect to how to make use of them. If you choose to help, please pretend like you’re talking to someone who has little idea of what they’re doing.

What my goal is, is to have temperature, humidity, and lux display in HA, and later on, to trigger a Google Assistant routine to say, “turn on the living room heater”. The reason for this, is that my VOCOlinc smart plugs don’t have an integration in HA, but they do in Google, and I’m not sure yet if the firmware can be replaced with something friendlier.

I’d be really happy to get three gauges to show the three data points in HA for starters, but I’m not really sure how to start.

One thing I noticed is that UbiBot has an HTTP data forwarding (beta) feature that appears to send a copy of the JSON data from the WS1 to whatever URL you want. So I’m going to start there with getting DuckDNS going alongside HTTPS, and then after that it probably shouldn’t be too tough to set up HA to receive the POST and “do something” with it.

UbiBot also appears to have local integration where you can completely cut them out and have no need for outside internet access, but they claim there’s a one time fee which I haven’t been able to locate as yet. I might pursue that option if it doesn’t cost a ridiculous amount.

Thank you in advance.

EDIT: Spelling error

It is very easy…
go in your configuration.yaml file and put this:

# Integration with UBIBOT
  - platform: rest
    name: UBIBOT
    value_template: '{{ (value_json.channels[0].last_values|from_json).field3.value|round()|float(value) }}'

Once you did this you will have your integration done (go in integration section of HA) and you can set gauges, trends… etc as you like for the lux. filed1 and field2 I think are for Temperature and humidity if I’m not wrong and it is the same procedure…
For what concerns Google Assistant I cannot help you very much because I do not have it.

I figured it probably had to be pretty easy. I’ve got the remote access with HTTPS working now, so I should probably be good from here.

In the future I think I’m going to just get an Arduino instead of the Ubibot. Overall it seems like a way better route to go, especially considering there’s practically no end to the types of sensors you can add. I don’t like how you have to rely on UbiBot for the device to function. You can buy a developer membership for a mere $5000 (LOL) to get a local server and become independent.

I’ll figure out the Google thing. I imagine there’s a way to do what I’m going for, and if not I’ll just buy Hassio friendly smart plugs and call it “cost of learning”.

Thank you VERY VERY MUCH for your assistance, I really appreciate it.

Hi parabag, or anyone else who reads this; I put the above code into configuration.yaml exactly as shown, except with my own Ubibot “account key” which I got from the Ubisoft website under settings/security, but I keep getting an error in Hassio that states: “bad indentation of a mapping entry at line 22, column 2:
- platform: rest”

I can’t seem to figure out what’s going wrong. Here’s the COMPLETE code I used:

Integration with UBIBOT

 -  platform: rest
    name: "UBIBOT"
    value_template: '{{ (value_json.channels[0].last_values|from_json).field1.value|round()|float(value) }}'

I’ve checked the YAML syntax with a few websites, and it’s apparently correct. Whatever I’m missing surely can’t be all that major.

How do you get Ubibot to send the data to the Hassio endpoint? It looks like you’ve used a GET request, which I’m having trouble working out how to do. Currently I’m just trying to use the Ubibot data forwarding option, which does appear to work, as I’ve tested it at RequestBin.

Thank you in advance.

UPDATE: Looks like I fixed it. Sure enough, it was simple. I amended the code as follows:

sensor flower1
 -  platform: rest
     name: "UBIBOT"
     value_template: '{{ (value_json.channels[0].last_values|from_json).field1.value|round()|float(value)}}'

Now I’m able to add a gage and interact with this webhook as a sensor! It appears lack of experience was the problem.

Hi All,

I too have issues with reading and writing to a device that uses .XML to read from and write to the device. It is a Xytronics ‘ControlByWeb’ X410 PLC. I would like to be able to connect to it via HA. The data received is as follows-


I know roughly how but having issues with correct syntax to get the data.

Any help appreciated.

Sorry, I should have said the data is also read and written in json. IE:


I have this working for 1 Ubibot, now that I have added a second, I am not sure how to setup the different channel.

Is that formatted correct?

I have 2 ubibots looking at it they are on channels 17577 and 22692.

  - platform: rest
    name: Temperature_Kitchen_ubibot
    value_template: '{{ (value_json.channels[0].last_values|from_json).field1.value|float(value) }}'```