aww thank you so much. I donât really understand variable trigger thing but iâm going to give it a try.
Out of interest, why does this not work?
I get this error
Invalid config for [script]: Entity ID switch.{{states.input_select.radiator.state}} is an invalid entity id for dictionary value @ data['script']['script10']['sequence'][0]['entity_id']. Got 'switch.{{states.input_select.radiator.state}}'. (See /config/configuration.yaml, line 30). Please check the docs at https://home-assistant.io/components/script/
because you have templates outside template sections in your script, and your input select selections are uppercase. All entity idâs are lowercase, you need to use the lower filter as well.
Itâs defined in the automation if you copied it properly. I wrote it off the top of my head, so there could be errors. Without the errors, I canât help you debug it.
I think I have confused things so if you still donât mind helping me I want to clear a few things up.
I have 4 sonoff switches which I want to control manually to turn on/off the radiators at any time.
I want an Input_Select which has a drop-down menu of my switches and when an individual switch is selected I want it to turn on that switch for the period of time which is decided by the input_number slider.
I want to also be able to cancel the "Hours/Timer" period if I manually turn off the switch.
I also want the input select to revert to "None" once a specific radiator has been selected.
I had it all set up before but it involved something like 6 automations and 3 scripts so i was hoping it could be down with fewer things and i could also learn from this in the future.
I would really appreciate if you were able to help.
Providing a solution so that âAllâ works is extremely complicated with just Yaml. Itâs possible but it would require a loop and a counter. It ends up being a ton of work and I donât have a python script handy at the moment that solves that issue.
This solution will only work for 1 switch at a time. Meaning you cannot have multiple heaters on a timer on at a time. If you want that, then you cannot merry them into a single script. You have to have a separate script for each one. You only have 1 script. If the script is running and you use the dropdown again, the currently running script may get canceled. I havenât tested it out, it may behave differently.
Probably want to split the automation up again because having it combined means youâll have to have a bunch of data templates.
split method:
automation:
- id: 1xxgsfgh
alias: Turns off LR timer
trigger:
platform: state
entity_id: input_select.radiator
condition:
condition: template
value_template: "{{ trigger.to_state.state in [ 'Living Room','Man Cave','Bedroom','Hall'] }}"
action:
- service: script.timed_radiator
data_template:
radiator: >
{% set radiators = {
'Living Room':'switch.living_room',
'Man Cave':'switch.man_cave',
'Bedroom':'switch.bedroom',
'Hall':'switch.switch3' } %}
{{ radiators[trigger.to_state.state]] }}
now where do I create the variable using the trigger.to_state and how to place it in the data_template of the script daughter (no variable needed in the wife script, only one there )
@petro@pnbruckner would you please have a look, I am a bit stuck here⌠one of my daughters came home, and it selected the wife script⌠(apparently the condition isnât correct) and it didnt pass the variables either.
trigger.to_state is a state object, not a state string. It will not match anything in a list of strings. Iâm guessing you meant trigger.to_state.state, but thatâs not clear since you donât show the trigger.
Second, when you call a script using its name as the service, you donât put variables under variables:. You just list them directly under data: or data_template:. This is clearly explained here.
I want the automation to create to variables, presence_person (trigger.to_state) and presence_location (trigger.to_state.state), and pass these to the scripts.
tbh it isnât as clear as you say, since I need the triggers to be passed? If you point me to the 'variables: â error, youâre right, Iâve taken that out.
seems to work now with this:
- condition: template
value_template: >
{{trigger.entity_id in ['group.daughter1', 'group.daughter2', 'daughter3',
'group.daughter4', 'group.wife'] and
trigger.to_state.state == 'home'}}
- service_template: >
script.announce_{{ 'daughters' if trigger.entity_id in ['group.daughter1', 'group.daughter2', 'group.daughter3',
'group.daughter4'] else 'wife'}}
data_template:
presence_person: "{{trigger.entity_id.name}}"
presence_location: "{{trigger.to_state.state}}"