Hello,
I’m sure this is very simple, maybe someone can help me.
I need to display in my dashboard a value that is the SUM of an input given date + an input given number of weeks (or days). To the input date, I’m calling start_date. To the input weeks I’m calling 2nd_stage. It would be convenient that HA could give a default value for both the start_date and for the 2nd_stage.
I managed to create the a functional input for the start date (yeah!)
But I’m stuck in how can I create the input for the week/days (coded in bold)
In my config file, I’ve created these inputs:
Thank you very much for your kind help. I already learned something very important: timedelta makes this stuff easier.
I tried your suggestion but I still seem not able to put it to work.
So, I refurbish a bit my draft, and here is what I have now.
Helpers:
In summary, I need to get an automatic value for Veg Start Date (planned) as a date, by adding the Grow Start Date and the Total Germination Time (with a default value of 3 days).
Also I need to get an automatic value for Flower Start Date (planned) as a date, by adding the Veg Start Date (planned) and the Total Vegetative Time (with a default value of 3 weeks).
Still struggling!
First, timedelta() needs a number value for your unit (hours, days, weeks, etc.). In the following:
'input_number.total_germination_time' is not a number, it’s a string. To get the value of that entity’s state as a whole number (integer) you need to use:
Second, in the “flower start date” sensor, you have also set the unit for timedelta() to “days”, but your Input number helper is in weeks. You could do math in the template, but it is easier to just change the unit.
If the two line version like I showed for planned_veg_start_date is working for you, use that for the flower start sensor as well… but both should work, and what you posted in your last comment was still missing the last line. That last line, which is wrapped in {{ }}, is the expression. The expression is the part of the template that is printed to the template output. Without it, there is no output for the sensor, which is why it would come up as constantly “unavailable”.
In the last example you are also missing a domain. (I am partly to blame for that one because I missed that you had left it out in your original post.)
states('planned_veg_start_date') is meaningless. If you want to get the state of the “Veg Start Date (planned)” sensor you need to tell the template it’s a sensor: states('sensor.planned_veg_start_date')