I am fairly new and trying to create an automation that locks my doors when I leave (started by my pushing a button/toggle on lovelace) and then sets the lights depending if its day or night (using 2 different scenes).
Here is what I have created so far, would appreciate any help:
Very interesting, I didnât even think about appending a string like that. I messed around a bit and still cannot get the scenes to fire. Here is the updated YAML:
So you have scenes named scene.night_dim & scene.all_off, correct?
Hmm, wait a second. How are you triggering the automation? Are you triggering it manually? If so, then the trigger variable will not be defined, and hence it wonât work. This automation has to be triggered by the sunrise or sunset event to work properly.
So yes, those are the names of the scenes. If I trigger it manually to âtestâ it, everything works except for the lighting scene⌠that is problem #1.
The second issue is, as you said, the way in which I plan to trigger it. I had hoped to trigger this with a button on lovelace however, in its current state it looks to auto trigger based on the sun event. Which is obviously, very problematic.
Thereâs nothing problematic or wrong with the automation as written. It will work and do what itâs written to do. And like any automation that uses the trigger variable, you canât test it by using the manual TRIGGER button, because again, the trigger variable doesnât exist in that scenario.
But if you want it to do something else, then yes, that would definitely be a problem.
Maybe you need to describe exactly what you want the automation to do. It sounds, however, like maybe you donât actually want an automation at all, but maybe a script instead.
I think you are right⌠maybe I should be looking down a different road (script vs automation). See it I still have a lot to learn, I did not realize they were different things.
Anyhow: I am trying to have a script that I can enable via a button/toggle/etc on lovelace. This Leave Home button would execute a script that then locks my door, arms my alarm, and adjust the lighting scene depending whether or not it is dark outside.
This was my latest YAML before I knew automation was not the way to go:
So this would lock 2 doors, then pause for 60 seconds and finally arm my alarm away. Then the lights would set to ânight_dimâ if itâs equal to or greater than sunset or âall_offâ if its equal to or greater than sunrise.
FYI, a script is just a sequence of steps that you can run via a service call (which you can do, e.g., from a UI âbuttonâ), whereas an automation is a sequence of steps together with a trigger, and optionally a condition, that automatically decides when to run the sequence (aka action.)
Error executing service <ServiceCall script.leave_home (c:727211df4e6246ddb03ce50fee41b2fe)>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/core.py", line 1244, in _safe_execute
await self._execute_service(handler, service_call)
File "/usr/src/homeassistant/homeassistant/core.py", line 1261, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 142, in service_handler
await script.async_turn_on(variables=service.data, context=service.context)
File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 214, in async_turn_on
raise err
File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 209, in async_turn_on
await self.script.async_run(kwargs.get(ATTR_VARIABLES), context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 190, in async_run
await self._handle_action(action, variables, context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 274, in _handle_action
await self._actions[_determine_action(action)](action, variables, context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 357, in _async_call_service
context=context,
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 97, in async_call_from_config
domain, service_name, service_data, blocking=blocking, context=context
File "/usr/src/homeassistant/homeassistant/core.py", line 1211, in async_call
raise ServiceNotFound(domain, service) from None
homeassistant.exceptions.ServiceNotFound: Unable to find service scene/night_dim
I think this is because the scenes generally need to be called like this: