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 api.ubibot.com/channels?account_key=blablablablablablablablabla.
The json received is in a pretty complicated format:
{
"result":"success",
"server_time":"2020-06-10T11:20:26Z",
"channels":[
{
"channel_id":"123456",
"field1":"Temperature",
"field2":"Humidity",
"field3":"Light",
"field4":"Voltage",
"field5":"WIFI RSSI",
"field6":"Vibration Index",
"field7":"Knocks",
"field8":"External Temperature Probe",
"field9":"",
"field10":null,
"latitude":"45.05",
"longitude":"7.6667",
"name":"C-123456",
"public_flag":"false",
"tags":null,
"url":null,
"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}",
"description":null,
"traffic_out":"8384",
"traffic_in":"9203",
"status":"{\"ssid\":\"xxxxxxxxxxx\",\"status\":\"mac=MACADDRESS,usb=0\",\"usb\":\"0\",\"mac\":\"MACADDRESS\"}",
"timezone":null,
"created_at":"2020-06-10T08:31:46Z",
"updated_at":"2020-06-10T08:31:46Z",
"usage":"25438",
"last_entry_id":"128",
"last_entry_date":"2020-06-10T11:19:35Z",
"product_id":"ubibot-ws1",
"device_id":"MYDVICEID1234",
"channel_icon":null,
"last_ip":"47.53.15.102",
"attached_at":"2020-06-10T08:31:46Z",
"firmware":"ws1_v2.6.9",
"full_dump":"0",
"activated_at":"1591778067",
"serial":"AKG***WS1",
"mac_address":"MACADDRESS",
"full_dump_limit":"3",
"cali":null,
"size_out":"1073741824",
"size_storage":"209715200",
"plan_code":"ubibot_free",
"plan_start":"2020-06-10T08:31:46Z",
"plan_end":null,
"bill_start":"2020-06-10T08:31:46Z",
"bill_end":"2020-07-10T08:31:46Z",
"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\"},\"field2\":{\"value\":51,\"created_at\":\"2020-06-10T11:19:29Z\",\"net\":\"1\"},\"field4\":{\"value\":3.165038,\"created_at\":\"2020-06-10T10:34:29Z\"},\"field5\":{\"value\":-63,\"created_at\":\"2020-06-10T11:19:32Z\"},\"wifi\":{\"value\":\"MACADDRESS,-74;MACADDRESS,-83;MACADDRESS,-70;MACADDRESS,-63;MACADDRESS:ec,-81\",\"created_at\":\"2020-06-10T11:19:32Z\"}}",
"vconfig":"{\"field1\":{\"h\":\"0\",\"u\":\"1\"},\"field2\":{\"h\":\"0\",\"u\":\"3\"},\"field3\":{\"h\":\"0\",\"u\":\"4\"},\"field4\":{\"h\":\"0\",\"u\":\"5\"},\"field5\":{\"h\":\"0\",\"u\":\"6\"},\"field6\":{\"h\":\"0\",\"u\":\"7\"},\"field7\":{\"h\":\"0\",\"u\":\"8\"},\"field8\":{\"h\":\"0\",\"u\":\"1\"},\"field9\":{\"h\":\"0\",\"u\":\"9\"}}",
"vpref":"{\"fields\":[{\"key\":\"field1\",\"index\":0,\"visible\":true},{\"key\":\"field2\",\"index\":1,\"visible\":true},{\"key\":\"field3\",\"index\":2,\"visible\":true},{\"key\":\"field4\",\"index\":3,\"visible\":true},{\"key\":\"field5\",\"index\":4,\"visible\":true},{\"key\":\"field6\",\"index\":5,\"visible\":true},{\"key\":\"field7\",\"index\":6,\"visible\":true},{\"key\":\"field8\",\"index\":7,\"visible\":true}],\"v\":1}",
"battery":null,
"vpref_from":"owner",
"net":"1",
"c_icon_base":null,
"full_serial":"XXXXXXXXX",
"triggering_rules":null
}
]
}
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
resource: https://api.ubibot.io/channels?account_key=blablablablablablablablabla
name: UBIBOT
value_template: '{{ value_json.channels[0].last_value.field1 }}'
But it is absolutely NOT WORKING
Can somebody help me?
thanks very much!
Luca