I have a solar hot water system which has a data-collection device, and I’ve figured out that that device has a rest API. Cool. I’ve set this up and it all works:
rest:
- resource: http://192.168.1.80/dlx/download/live
scan_interval: 60
sensor:
- name: "Solar Hot Water Collector Top"
value_template: "{{ value_json.headersets[0].packets[0].field_values[0].raw_value }}"
device_class: temperature
state_class: measurement
unit_of_measurement: "°C"
- name: "Solar Hot Water Tank Bottom"
value_template: "{{ value_json.headersets[0].packets[0].field_values[1].raw_value }}"
device_class: temperature
state_class: measurement
unit_of_measurement: "°C"
- name: "Solar Hot Water Tank Top"
value_template: "{{ value_json.headersets[0].packets[0].field_values[2].raw_value }}"
device_class: temperature
state_class: measurement
unit_of_measurement: "°C"
- name: "Solar Hot Water Unknown Temperature Sensur"
value_template: "{{ value_json.headersets[0].packets[0].field_values[3].raw_value }}"
device_class: temperature
state_class: measurement
unit_of_measurement: "°C"
- name: "Solar Hot Water Pump Speed"
value_template: "{{ value_json.headersets[0].packets[0].field_values[4].raw_value }}"
state_class: measurement
#icon: "mdi:pump"
unit_of_measurement: "%"
- name: "Solar Hot Water Operating Hours"
value_template: "{{ value_json.headersets[0].packets[0].field_values[6].raw_value }}"
state_class: total_increasing
#icon: "mdi:clipboard-text-clock-outline"
unit_of_measurement: "h"
- name: "Solar Hot Water Heat Quantity"
value_template: "{{ value_json.headersets[0].packets[0].field_values[17].raw_value }}"
state_class: total_increasing
#icon: "mdi:solar-power"
unit_of_measurement: "Wh"
binary_sensor:
- name: "Solar Hot Water Sensor 1 Defective"
value_template: "{{ value_json.headersets[0].packets[0].field_values[12].raw_value }}"
device_class: problem
- name: "Solar Hot Water Sensor 2 Defective"
value_template: "{{ value_json.headersets[0].packets[0].field_values[13].raw_value }}"
device_class: problem
- name: "Solar Hot Water Sensor 3 Defective"
value_template: "{{ value_json.headersets[0].packets[0].field_values[14].raw_value }}"
device_class: problem
- name: "Solar Hot Water Sensor 4 Defective"
value_template: "{{ value_json.headersets[0].packets[0].field_values[15].raw_value }}"
device_class: problem
… took me a little while to figure out that value_json
starts at the root, making json_attributes_path
/ json_attributes
not very useful. (Unfortunately, the returned JSON is… kind of disorganized. It’s really meant to feed a website template, not to get useful values from. But it works!)
However, I would like to group all of these things together into a “Solar Hot Water” device. Is there a way to do that, without creating a complete integration?