Value_templates in trigger based sensort not working

I get the new energy prices for tomorrow sometime during the day. These are stored as attributes.
At midnight I want to transfer the prices for tomorrow to the prices for today. These prices should survice a reboot.
The values of trigger based sensors should survive a reboot, so I tried:

  - trigger:
      - platform: time
        at: "00:00"
      - name: electricityprices_today
        state: "OK"
        unique_id: electricityprices_today
          data: >-
            {% set ns = namespace(items=[]) %}
            {% for i in %}
              {% set ns.items = ns.items + [ {'date':, 'price': i.price} ] %}
            {% endfor %}
            {{ ns.items }}  

I get the following error:

Invalid config for 'template' at my_packages/electricity.yaml, line 67: 'attribute_templates' is an invalid option for 'template', check: sensor->0->attribute_templates

Is there are way to do what I want?

Should just be attributes, not attribute_templates. The latter is for the “legacy” sensor format.

Thanks a lot, this solved it.
Can I use attributes instead of attribute_templates also for sensors?
I like to keep things consistent and as I’m just starting it is not a lot of work to change it.

Read through the template docs. The format you are using for the trigger-based sensor is different from the legacy sensors. Use whichever is appropriate. They don’t mix.

thanks. I really do my best to understand the documentation. It is not easy to read though. Luckily there are also some blogs and youtube to help.

I’m trying the next thing now.
what I’m trying to let a rest sensor only fire at a specific time.
The api presents day ahead electricity prices.

#  - trigger:
#      - platform: time
#        at:
#          - "00:00"
#    sensor:
#      - platform: rest
#        name: testje
#        resource:
#        state: "OK"
#        attributes:
#          - data

I get:

Invalid config for 'template' at my_packages/test.yaml,
line 11: expected a dictionary for dictionary value 'sensor->0->attributes', got ['data'] Invalid config for 'template' at my_packages/test.yaml,
line 7: 'platform' is an invalid option for 'template', check: sensor->0->platform Invalid config for 'template' at my_packages/test.yaml,
line 9: 'resource' is an invalid option for 'template', check: sensor->0->resource

You appear to be trying to create a hybrid of a Trigger-based Template Sensor and a RESTful Sensor. Such a thing doesn’t exist.

That’s why the error messages complain about the platform and resource options. They are not valid options for a Template Sensor.

Thanks for your answer. Who knows maybe sometime in the future it will be possible.
The idea was that a trigger based sensor doesn’t refresh it’s data over a restart.
This way during development I don’t hammer the website providing the information to much, avoiding running out of my token limit.

Correct. A Trigger-based Template Sensor updates its value only when it’s triggered by one of its triggers.

However, you can’t combine the configurations for two completely different integrations (Template and RESTful Sensor) and expect the end-result to work.