#Template in the template

1 messages · Page 1 of 1 (latest)

raven comet
#

I have got the sensor:

`sensor:

  • platform: rest
    name: battery_saures
    resource: "https://api.saures.ru/1.0/sensor/battery"
    verify_ssl: false
    scan_interval: 900
    method: GET
    #device_class: battery
    headers:
    User-Agent: Home Assistant
    params:
    start: "{{ (now()).strftime('%Y-%m-%d') }}"
    sid: "{{ states('sensor.saures_sid') }}"
    sn: "10301739"
    value_template: "{{ value_json.data }}"`

I have got the parameter that changes daily
start: "{{ (now()).strftime('%Y-%m-%d') }}"

I have got the result
{'2024-04-02': 10}
… for today.

The result will be tomorrow:
{'2024-04-03': 10}
And so on.

How can I insert template (current date) in value_template? Like this
value_template: "{{ value_json.data. {{ (now()).strftime('%Y-%m-%d') }} }}"

turbid sedge
#
value_template: "{{ value_json.data[now().strftime('%Y-%m-%d')] }}"
raven comet
turbid sedge
#

Fixed

#

But you could probably have fixed that yourself if you read the error message 😉