I’ve created a RESTful sensor:
rest:
- scan_interval: 60
resource: http://192.168.1.114:8080/
sensor:
- name: "Heatmaster Boiler"
json_attributes_path: "$.Heatmaster"
json_attributes:
- "status"
- "temp"
- "O2"
- "Top_Air"
- "Bottom_Air"
I get the data into HA I can see them in the developers->states listing. I can see them in the Heatmaster sensor as attributes.
What I really want is a separate sensore for each attribute. From reading it sounds like I need to use a template to do this? I’ve no idea how.
Any suggestions, pointers on how to create multiple sensors?
thanks
tom_l
December 6, 2022, 4:15am
2
Like this:
rest:
- scan_interval: 60
resource: http://192.168.1.114:8080/
sensor:
- name: "Heatmaster Boiler Status"
state: "{{ value_json.Heatmaster.status }}"
- name: "Heatmaster Temperature"
state: "{{ value_json.Heatmaster.temp }}"
- name: "Heatmaster O2"
state: "{{ value_json.Heatmaster.O2 }}"
- name: "Heatmaster Top Air"
state: "{{ value_json.Heatmaster.Top_Air }}"
- name: "Heatmaster Bottom Air"
state: "{{ value_json.Heatmaster.Bottom_Air }}"
You can add unit of measurement or device classes to any that require it. Also if there are any binary sensors (on/off) put them under binary_sensor:
rather than sensor:
and adjust the template to return true or false.
Well I screwed something up:
Invalid config for [rest]: [state] is an invalid option for [rest]. Check: rest->rest->0->sensor->0->state. (See /config/configuration.yaml, line 83).
The only thing on line 83 is: rest:
I just had to change state: to value_template: and it works!
rest:
- scan_interval: 60
resource: http://192.168.1.114:8080/
sensor:
- name: "Heatmaster Boiler Status"
value_template: "{{ value_json.Heatmaster.status }}"
- name: "Heatmaster Temperature"
value_template: "{{ value_json.Heatmaster.temp }}"
device_class: temperature
unit_of_measurement: '°F'
- name: "Heatmaster O2"
value_template: "{{ value_json.Heatmaster.O2 }}"
- name: "Heatmaster Top Air"
value_template: "{{ value_json.Heatmaster.Top_Air }}"
- name: "Heatmaster Bottom Air"
value_template: "{{ value_json.Heatmaster.Bottom_Air }}"
1 Like
tom_l
December 6, 2022, 6:06am
5
Opps. Sorry, should have looked it up in the docs instead of doing it from memory. state:
is for the new template sensor format, not the new rest sensor integration.