I have the following in my configuration.yaml, in an attempt to report the remaining mass of pellets in my pellet boiler.
rest:
- resource: https://stokercloud.dk/dev/getjsondriftdata.php?mac=XXXXXXXXXX
scan_interval: 60
sensor:
- name: Hopper Pellets Remaining
value_template: "{{ value_json.505 }}"
json_attributes: "505"
This is to consume the following JSON, which reports the mass of pellets remaining in the hopper under id 505:
{
"501": "22.8 °C flow",
"502": "0 % Power",
"503": "21 °C Shaft",
"504": "0 kW Power",
"505": "813.7 kg Hopper",
"506": "0 Lx Light",
"507": "Stopped clock ",
"508": "07-29-2024 13:13:46",
"521": "0 °C Return",
"522": "0 liter/hour Flow",
"524": "0 °C External temperature",
"525": "48 °C Temperature DHW",
"526": "16.2 % Actual oxygen",
"527": "20.9 % Target oxygen",
"528": "1450 Gram auger/6 min",
"530": "0 kg Today",
"531": "0.000 kg/m2 Today",
"532": "0 °C Smoke temp.",
"533": "75 °C Target boiler temp.",
"534": "65 °C Target DHW temp.",
"542": " ",
"584": "REDACTED",
"585": "41 % humidity",
"586": "1021 hPa pressure",
"587": "4.1 m/s wind speed",
"588": "http://openweathermap.org/img/w/01d.png ",
"589": "26 °C air temperature",
"591": "130 null",
"592": "0.0 °C T5",
"alarm": "0"
}
This almost works as I would like. It creates an entity, with an attribute of “813.7 kg Hopper”. However, I would like to make two improvements:
- I want this to be reported solely as a number. I’ve tried the following but it is not the answer:
value_template: "{{ value_json.505[0].replace(' kg Hopper','') }}"
- I want this to be reported as the status of the sensor. This may be incorrectly phrased as a desire, but I want to be able to view this as the primary value in a graph, create notifications/alerts on the basis of this value, and to view it in dashboards as a single number.
In addition, it may be good to consume other values from here (e.g. “alarm”), and I’m not sure how I would extend this to consume multiple values, would it simply be to append more lines such as this?
sensor:
- name: Boiler Alarm
value_template: "{{ value_json.alarm }}"
json_attributes: "alarm"