I’ve added a rest sensor to pull data from UtilityAPI. Took a bit to get the JSON formatting to work but I got it. Then I wanted to change the name to something meaningful rather than just “REST Sensor”. When I add the “name” parameter the new entity appears, however, the data stops showing up. I’ve restarted many times and tried a few different was of adding the rest sensor, but can’t get it to work with a proper name.
Config that works without a name…
sensor:
- platform: rest
resource: https://utilityapi.com/api/v2/intervals?meters=xxxxxxx&limit=1&order=latest_first
headers:
Authorization: >
Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
scan_interval: 120
device_class: ENERGY
state_class: total_increasing
value_template: "{{ value_json['intervals']['readings']['kwh']}}"
All I do is add a name like below and it stops working…
sensor:
- platform: rest
name: Energy Demo
resource: https://utilityapi.com/api/v2/intervals?meters=xxxxxxx&limit=1&order=latest_first
headers:
Authorization: >
Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
scan_interval: 120
device_class: ENERGY
state_class: total_increasing
value_template: "{{ value_json['intervals']['readings']['kwh']}}"
[There was supposed to be another screenshot here, but I’m new, so…]
I’ve tried it with quotes and without.
I also tried this method of adding a rest sensor, however it keeps giving an error…
“JSON result was not a dictionary or list with 0th element a dictionary”
rest:
resource: https://utilityapi.com/api/v2/intervals?meters=xxxxxxxx&limit=1&order=latest_first
headers:
Authorization: >
Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
scan_interval: 120
sensor:
name: "EnergyDemo"
device_class: ENERGY
state_class: total_increasing
json_attributes_path: "$.intervals.readings[0]"
json_attributes:
- kwh
value_template: "{{ value_json['intervals']['readings']['kwh']}}"
Any help getting this to work with a name would be great.
Also, when trying to use the unit_of_measure parameter it gives an error…
“Invalid config for ‘rest’ at configuration.yaml, line 42: ‘unit_of_measure’ is an invalid option for ‘rest’, check: rest->0->sensor->0->unit_of_measure”