Hi guys!
I’m trying to do automation for a watering system for my bonsai.
I made a system that only depends on a switch.
So I want this automation to turn on that switch every 2 days, but also have the possibility to increase or decrease this frequency. I thought that a counter would help but I couldn’t figure how.
The input number should help me with the increase/decrease.
About the templates, those things scare me I honestly don’t know how to start with those.
But I’ll take a look!
The time of the day can be static, for instance at 11:00 AM.
I’m struggling a bit on this.
I’m thinking of making some sort of schedule table with buttons for every day of the week, but for this I need 7 automations, each button will toogle the automation of the corresponding weekday.
Not the most elegant solution, but I can’t find another solution.
Hello,
I have a similar problem.
I want the trigger to sheck if the automatisation last run have bin in less day’s that the input_number.
I try this but don’t work
- id: '1595533899655'
alias: 3 - ARROSSAGE auto
description: ''
trigger:
- entity_id: sun.sun
platform: state
to: sunset
condition:
- condition: template
value_template: '{(now().strftime("%s")-states('automatisation_3 - ARROSSAGE auto').last_changed.strftime("%s"))/(3600*24) )>(state('input_number.intervalle_arrosage')}'
The template should use double parentheses {{ }} not single parentheses { }.
The states() function requires a valid entity_id. This is not a valid entity_id: “automatisation_3 - ARROSSAGE auto”
The states() function produces a string value which does not have a method called last_changed. The means you cannot do this: states('automatisation_3 - ARROSSAGE auto').last_changed
The output of the states() function is always a string value. That means you cannot perform a numerical comparison using a string value. You must convert the string to a number using either the int or float filter.
You cannot mix the use of single (') and double (") quotes within the template. Use one type of quote at the beginning and end of the template and another type of quote inside the template. For example: "{{states('light.cuisine')}}"
The last function in the template is state which does not exist. You probably meant to use states.
Stumbled upon this while looking on how to make a 2 over 2 days automation. Basically like we split some chores with my wife like that, 2 days me 2 days her. Wanted to make it so Hass dashboard shows who’s shift it is.
Ended up using a slightly modified version of something from this thread. Here’s how it looks in the editor:
So basically it toggles a boolean every 2 days. I thought I’d need to use choice condition to do like “if its on turn it off” before I rememberd there’s a “toggle” action So it makes it very simple.
The main difference is that this is based on days, it does not take time into account. However it is also possible to adjust this to add time offsets, to make it change on specific hour of a day, if needed. This, hwoever, will change at 00:00 as the new day comes.
EDIT:
It also looks like it’s better to use now().date() instead of time sensor, as for me it’s last updated did not change for hours for some reason… Maybe it’s by design, not sure.
Hi, just saw this thread - exactly what I am looking for.
Wanted to add it into my boolean yaml, but it looks I missed something. As the sensor does not have an initial last_changed info, it does never update. Does anybody has any help on this?
The first one rounds up. For example, if the time difference is 1 day and 20 hours, it will report 2 days. The second one doesn’t do any rounding and will report 1 day.
Just realized, that it looks that the template needs an initial value as the “last_changed” needs at least one change to start. Thought I could manage this with a automation after startup, but could not use this value_template sensor in the automation.
See below error message:
TemplateError('UndefinedError: 'None' has no attribute 'last_changed'') while processing template 'Template("{{ 'on' if (now().date() - states.sensor.test_every2days.last_changed).days > 1 else 'off' }}")' for attribute '_state' in entity 'binary_sensor.test_every2days'
OK I tried it, error in log is gone but the boolean is still unavailable if I test it afterwards, shouldn’t it be set right now to on and therefor also a last change ? Following my template sensor: