What i’m attempting to do is have the IOS action turn on a boolean according to day and time.
It’s easy enough to get the boolean name using a template, but I’m unable to use it in the target field for the input_boolean.turnon function.
{% set sensor_names = [ 'dogmon', 'dogtues', 'dogwed', 'dogthurs', 'dogfri', 'dogsat', 'dogsun' ] %}
{% set today_name = sensor_names[now().weekday()] %}
{% if now().strftime("%H") | float < 13 -%}
{% set entity_name = 'input_booleon.'+today_name+'am' %}
{%- else -%}
{% set entity_name = 'input_booleon.'+today_name+'pm' %}
{%- endif %}
I can get it usable in a data_template by creating a template sensor, but that doesn’t work for input booleans.
Besides the fact that {{ entity_name }} should be in-between quotes, It should work. What’s the issue?
Please show the full automation you’ve implemented and the errors.
EDIT: Oh, and 'input_booleon.'+today_name.. should be input_boolean...
Taras, thank you so much! I was trying to get the variable set in the script and it kept ejecting it, so i defined it in the sensors as a template and it didn’t like that either. Oh, and it didn’t’ like the variable name with or without the quotes.
Just to get it working, I went with your simple option of just a toggle and it worked when I tested it! Now that this is working, I can add a TTS to my speaker or maybe a dinner triangle sound and work on the logging.
My wife will also like this because I have it notify both of us in the morning and now she can just tell it that she fed the dog from the notification either on the phone or the watch.
I can tell you for certain that without the outer quotes, it is a syntax error. Here’s the result of Check Configuration, complaining about the template on line 11:
for this simple example where the template, on line 11, is not delimited by quotes:
Anyway, glad to hear it all worked out in the end.