I’m trying to set uyp a trigger based sensor, ideally with some additional attributes. When my HW kicks in HWrun goes from 0 to 1. So I use this as the trigger.
At this point I want to take the starting HW electrical consumption which is stored in sensor.hw_round and ideally some other data stored as attributes with different units of measurement - recording the values of outdoor temperature and HW tank temperature would be desirable in the same sensor rather than creating another one.
I have the following for recording the inital electrical consumption but the HWStart sensor is not being created.
template:
- trigger:
- trigger: state
entity_id: 'counter.hwrun'
to: 1
sensor:
- name: "HWStart"
state: >-
"{{ states('sensor.hw_round')}}"
unit_of_measurement: kWh
Any pointers in my mistake would be greatly appreciated. Thanks
Did you check the documentation for correct structure? The example they give is:
# Example configuration entry
template:
- trigger:
- trigger: time_pattern
# This will update every night
hours: 0
minutes: 0
sensor:
# Keep track how many days have past since a date
- name: "Not smoking"
state: '{{ ( ( as_timestamp(now()) - as_timestamp(strptime("06.07.2018", "%d.%m.%Y")) ) / 86400 ) | round(default=0) }}'
unit_of_measurement: "Days"
Compare that with your own structure and go from there, provided all your entity_ids are correct?
You are pressing “Reload yaml” when creating your first template entity. In order to use the reload button, you need to have at least 1 already configured template entity. After that, you can reload. If it’s your first template entity, you must restart.
You have more than 1 template section, the first is overwriting the second. You’ll have an error in your logs for this.