Hi Guy’s,
I’ve been working on extracting a JSON value from a REStful API for a few days now and I seem to be hitting a wall in regards to the nested JSON values and how to get these formatted into a value_template config.
The data is from a Fireboard BBQ thermometer, I have API access and get data back via curl.
I have created this rest sensor,
The Fireboard API seems to have evolved a lot since the previous threads on this topic. Resulting in a much deeper nesting.
- platform: rest
scan_interval: 60
resource: "https://fireboard.io/api/v1/devices/UUID/temps.json"
headers:
Authorization: "TOKEN"
value_template: "{{ value_json['channels']['current_temp'] }}"
name: Fireboard Temp
json_attributes:
- current_temp
- channel_label
Sensor returns nothing,
My output of the API data is here,
[
{
"uuid":"Private",
"id":Private,
"title":"FireBoard 2 Drive",
"hardware_id":"Private",
"created":"2021-04-12T13:28:33.278Z",
"latest_temps":[
{
"degreetype":1,
"channel":1,
"temp":24.7,
"created":"2021-07-12T20:05:44Z"
}
],
"device_log":{
"internalIP":"192.168.56.128",
"onboardTemp":25.7,
"linkquality":"38/100",
"bleClientMAC":"",
"vBattPer":0.9770082315882354,
"nightmode":false,
"deviceID":"Private",
"macNIC":"7c:9e:bd:28:df:fc",
"uptime":"0:20",
"vBattPerRaw":0.933,
"publicIP":"Private",
"frequency":"2.4 GHz",
"cpuUsage":"20%",
"date":"2021-07-12 20:02:15 UTC",
"signallevel":-81,
"boardID":"GHK4DKRRJ",
"band":"802.11bgn",
"mode":"Managed",
"tempFilter":"true",
"versionImage":"201703260554",
"versionEspHal":"HAL: V1R2;MSP: 1.8.0;",
"memUsage":"2.6M/4.2M",
"txpower":78,
"model":"FBX2D",
"ssid":"Private",
"contrast":"10",
"commercialMode":"false",
"macAP":"74:83:c2:97:ef:e8",
"drivesettings":"{\"p\":4,\"s\":1,\"d\":5,\"ms\":100,\"f\":0,\"l\":1}",
"auxPort":"",
"version":"3.1.30",
"bleSignalLevel":0,
"versionNode":"5.0.0",
"diskUsage":"0.7M/4.0M",
"versionUtils":"6.1.3",
"vBatt":4.097,
"versionJava":"7.6.5"
},
"last_templog":"2021-07-12T20:05:19Z",
"last_battery_reading":0.9770082315882354,
"channels":[
{
"channel_label":"Pit",
"current_temp":24.7,
"alerts":[
],
"range_average_temp":24.4,
"id":14871974,
"last_templog":{
"degreetype":1,
"channel":1,
"temp":24.7,
"created":"2021-07-12T20:05:44Z"
},
"channel":1,
"created":"2021-07-12T19:42:13Z",
"enabled":true,
"range_min_temp":22.3,
"sessionid":2627590,
"range_max_temp":24.7
},
{
"channel_label":"Meat",
"channel":2,
"created":"2021-07-12T19:42:13Z",
"alerts":[
{
"time_stop":"23:59:59",
"notify_email":false,
"time_start":"00:00:01",
"id":3145146,
"notify_sms":false,
"temp_max":80.0,
"minutes_buffer":0,
"channel":2,
"created":"2021-07-12T19:42:13Z",
"notify_app":true,
"enabled":true,
"device_id":106820,
"temp_min":null,
"session_id":2627590,
"minutes_repeat":30
}
],
"enabled":true,
"id":14871975,
"sessionid":2627590
},
{
"channel_label":"Channel 3",
"channel":3,
"created":"2021-07-12T19:42:13Z",
"alerts":[
],
"\"enablePrivate"
Under channels > current_temp I am trying to read this value for the channel labelled Pit, also referred to as channel 1 further down.
Anyone got a suggestion for formatting a value_template to capture this?