Hi,
I have several trigger based sensor that update every day at midnight the last reset attribute. But they should also update every time the values change on the entity given under state. So I think it should be like this
template:
- trigger:
- platform: time_pattern
hours: 0
minutes: 0
sensor:
- name: "Laptop"
unique_id: "laptop_daily_energy"
unit_of_measurement: "kWh"
state_class: measurement
device_class: energy
state: '{{ states("sensor.laptop_total_daily_energy") | float }}'
attributes:
last_reset: '{{ now() }}'
- sensors:
- name: "Laptop"
unique_id: "laptop_daily_energy"
unit_of_measurement: "kWh"
state_class: measurement
device_class: energy
state: '{{ states("sensor.laptop_total_daily_energy") | float }}'
So under sensor I have the sensor without the last_reset because that should be set on midnight. Under trigger I only want the sensor with last_reset to be updated. But I am not sure do I need the full sensor info on trigger also or will it only overwrite the attribute if I only use the unique id and attribute. and the rest is not needed? Did not find info about that.
Hope you know what I mean, I want to save double info on trigger and sensor while updating last reset only on midnight and update the value every time it changes.