I want to make a REST call to retrieve to pieces of data, moonrise and moonset. I can make it work using two separate calls, but from the docs, I should be able get the two sensors populated in a single call.
Here are the the calls I use:
- platform: rest
resource: !secret visual_crossing_moon_data
name: "Moon Rise"
scan_interval: 43200
json_attributes_path: "$.days[0]"
json_attributes:
- moonrise
value_template: "{{ value_json['days[0]']['moonrise']}}"
- platform: rest
resource: !secret visual_crossing_moon_data
name: "Moon Set"
scan_interval: 43200
json_attributes_path: "$.days[0]"
json_attributes:
- moonset
value_template: "{{ value_json['days[0]']['moonset']}}"
Here’s what I tried using the example I found the docs:
rest:
- resource: !secret visual_crossing_moon_data
sensor:
- name: "Moon Rise
value_template: "{{ value_json.days[0]['moonrise'] }}"
- name: "Moon Set"
value_template: "{{ value_json.days[0]['moonset'] }}"
With code in my configuration.yaml, I get the error, “resource is an invalid key”
Here’s the doc reference: