I’m having an issue using a template helper and adding a year to a date.
Background - I have a Kohler generator with the OnQue system, and I’m using the OnQue integration to read the data. When I do generator maintenance, the OnQue integration does not return the date or hours when the maintenance was performed. So I’ve added two helpers which I will manually update when the maintenance is performed:
- input_datetime.generator_maintenance_performed_date which is a date/time helper.
- input_number.generator_maintenance_performed_hours which is a number helper.
On a dashboard, I want to show the hours or date that the maintenance is due (every 150 hours or yearly). I’ve created template helpers for each of these. I have the hours one working, but I can’t get the date one to return the next year.
In developer tools | Templates, I created this template which works properly:
{% set datetime = as_datetime(states('input_datetime.generator_maintenance_performed_date')) %}
{{datetime.replace(year=datetime.year+1)|as_datetime}}
However, in the helper that I’ve created, it is always returning “Unknown”.
Can anyone help me get this helper working properly?
Thanks!