Hi!
I have a Vallox ventilation system integration in my HA. The integration provides me a date entity where I can type a date of changing ventilation filter and it also provides a sensor entity with remaining time for filter (its just a date):
I want to receive a notify when will come a date of changing filter.
I found some information in this thread:
And created an input_datetime helper to pass data from Vallox sensor to helper. My code in template.yaml looks like this, but however it doesnt work:
- trigger:
- platform: time
id: set helper
at: "00:00:00"
- platform: time
id: notify
at: input_datetime.date_vallox
condition: []
action:
- variables:
notification_time: >
{% set x = states('sensor.vallox_remaining_time_for_filter') %}
{{ now().replace(day=x[:2]|int, month=x[3:5]|int, hour=7, minute=0) }}
- choose:
- conditions:
- condition: trigger
id: set helper
- condition: time
after: '00:00:00'
sequence:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.date_vallox
data:
datetime: "{{ notification_time }}"
- conditions:
- condition: trigger
id: notify
sequence:
- service: notify.neptun_all_devices
data:
title: Filter changing
message: Its time to change ventilation filter!
- service: notify.persistent_notification
data:
title: Filter changing
message: Its time to change ventilation filter!
default: []
So I dont fully understand this code and possibly typed something wrong.
Service for notifications (neptun_all_devices) work perfectly fine, I checked this.
The file named template.yaml suggests it is for Template Sensors. For example, this might be in your configuration.yaml file:
template: !include template.yaml
The code you posted is an automation, not a Template Sensor.
If it is the correct location then it’s strange that the file’s name is not automation.yaml or some other name than indicates what it is meant to store.
The thread you linked to was for an automation, not a template entity. There are likely errors in your logs regarding this entry because it is invalid due to the lack of an entity type configuration block like sensor, number, binary_sensor, etc. Furthermore, the example was specifically to take a date from a sensor and schedule a notification for 7AM on that date.
As Taras has explained, what you have presented should be added wherever you have your automations, not in template.yaml.
While the method should still work, there are more options for scheduling automations now than there were 3 years ago when the linked thread was created. We may be able to help you with an automation that is more appropriate for your needs if you provide a detailed explanation of what you are trying to do.
Oh thanks, my bad! I moved code from templates to automations and edited it a bit, now it finally works
Here is my code for someone with similar problem:
alias: Notif changing ventilation filter
description: ""
triggers:
- trigger: time
at: sensor.vallox_remaining_time_for_filter
conditions: []
actions:
- action: notify.neptun_all_devices
data:
title: Change your ventilation filter!
message: >-
Change your ventilation filter!
- action: notify.persistent_notification
metadata: {}
data:
title: Change your ventilation filter!
message: >-
Change your ventilation filter!
mode: single