I have created 2 custom sensor and the first one will get a road name from a feed, and the second one i want to reuse the value from the 1st sensor in the resource. But is there way to reuse the value? i have tried reuse, but it seems see it as string not the value.
rest:
- resource: https://crd-rubbish.epd.ntpc.gov.tw/dispProject/api/line-status.ashx?lineid=244025
scan_interval: 30
method: GET
sensor:
- name: "CurrentLocation"
value_template: "{{ value_json['data']['points'][0]['name'] }}"
- resource: https://positionstack.com/geo_api.php?query={{ states('sensor.CurrentLocation') }}
scan_interval: 60
method: GET
sensor:
- name: "LocLat"
value_template: "{{ value_json['data'][0]['latitude'] }}"
- name: "LocLon"
value_template: "{{ value_json['data'][0]['longitude'] }}"
In my 1st sensor, i am able to get the value in state, so i’ve tried using state of the sensor, as well as using the value_template. However, from the log it is just using ‘https://positionstack.com/geo_api.php?query={{ states(‘sensor.CurrentLocation’) }}’ instead of https://positionstack.com/geo_api.php?query=“value from 1st sensor”
Maybe the format i’ve input in resource is incorrect? or this is not the way to approach.