Thanks for the reply. Sometimes I have difficulty finding things in the docs. I have stripped it down with no condition and found that the script is not being executed. I have tried using the automation editor yet it still will not fire. Here is my automation, help with getting this to work would be much appreciated.
- id: '1569630741558'
alias: test
trigger:
- at: 09:32:00
platform: time
condition: []
action:
- data:
entity_id: script.night_motion
service: script.toggle
And there’s the rub.
The automation editor is fairly new, I don’t know of anyone helping on the forum who uses it.
Calling anyone that does !
It produces some Wacky code we are still trying to get our heads round
Generally we use samba and our personal favourite editors, steering clear of the automation editor as it strips out any comments as well as inserting ‘extra’ stuff
Until we can purchase, install and configure a new HA instance each we aren’t going to be able to help much with this.
We could write you code that would work if cut and pasted in over samba and an editor or ssh’d in with nano or vim etc. But the editor does not seem to like such code so there may be conflicts
Look around the forum check what others have done, unfortunately you seem to be caught in a transition period.
Sorry
Glad to see you got the formatting sorted, though from what we’ve just learned, that may not be the actual formatting in the actual file.
Do you have a favourite text editor ?
What platform is your computer?
I also use notepad++ and edit the files manually. Just wanted to see if the editor would provide some in site to where the problem is. I have been able to determine that the issue is how i call the script. If I use entity_id: script.1569530171754 it works, but if I use entity_id: script.night_motion it does not. If I use only notepad++ can i use some other name instead of the ID number that the editor uses?
Yes you can,
But I’ll just call in some fresh eyes on this as what you have tried should have worked.
tom_l, finity, pnbruckner - any of you aware of this behaviour?
John,
Tink raises a good point, did you name (give it an alias) your script ‘script.night_motion’ and if so how, or are you making an assumption?
Can you show your script ?
Where are they ? Do you have a script.yaml and automation.yaml file? Are they in there ? or your configuration.yaml ?
Also, your automation is triggered by what ?
The conditions check that your morning script is not running (how long does that take? What’s in that.?) then it’s either before sunrise OR after 03:40 (that equates to ‘any time’ doesn’t it.?)
And then run the script that you were checking wasn’t running ?
Mutt
I was able edit the script file and change the ID to a friendly name and now can call it from the automation. The syntax of my script file is not exactly how it is described in the docs as referenced by Tinkerer.
As for the condition it is to accomplish the following:
Check and see if the script is not running
Check that the time is after 3:45am and before sunrise.
My trigger is just for testing but will be replaced with a motion sensor once I get the automation working correctly.
My automation is:
alias: Motion in Morning
trigger:
- at: '07:17:00'
platform: time
condition:
condition: and
conditions:
- condition: state
entity_id: script.morning_motion
state: 'off'
- condition: or
conditions:
- condition: time
after: '03:45:00'
- condition: sun
before: sunrise
action:
- service: script.turn_on
entity_id: script.morning_motion
My script is:
alias: Morning Motion
description: Turn on Fireplace and TV Light
sequence:
- service: switch.turn_on
data:
entity_id: switch.smart_switch_switch
- delay: 00:00:15
- service: switch.turn_on
data:
entity_id: switch.zooz_zen26_s2_on_off_wall_switch_switch
I just noticed that in the previous post it removed the first line of the script. Instead of the ID that the editor put in, I replaced it with ‘night_motion’:. Note that the docs do not show the single quote, not sure if it is required.
Yeah, closer
Your alias needs to be ALL lower case and NO spaces
The system will try to correct/interpret but you may get odd results
Just go with: morning_motion
If you ever see “incorrect slug” or similar that’s what it’s referring to.
So using notepad++ : -
The script delay should be in quotes ‘00:00:15’
In your conditions : -
Remove the whole “condition: and” line
And the same for the “- condition: or” line and the “conditions:” line blow that
The unindent (take 2 spaces out from) the following lines so they look like the first condition, all nicely in line.
See where that gets you.
But why not put the delay and the switch turn on in the automation?
Also nothing stops you from turning on something that is already on so get rid of the script running, in doesn’t do anything.
Edit: though if you want to be clear, you could change the condition to check the switch was off. So it only ever runs to turn it on the switch the 1st time but may repeat in the 15 sec delay, again no problem.
From what I have read the Alias can be anything and is just for the UI and is not used to call the script. By replacing the ID number in the script with a name all lower case and no spaces but leaving the quotes it works.
I have cleaned up the conditions as indicated and everything looks good by manually triggering the automation. Will have to see how it works tonight then add my motion sensor.
I think there may be some confusion between the script “alias:” & the script designator which ends up being the object_id.
example from the docs:
script: #<--- domain
wakeup: # <--- designator = object_id = all lowercase, no spaces, underscores are OK
alias: Wake Up # <--- name in the UI = pretty much anything, no quotes required but they are OK
description: 'Turns on the bedroom lights and then the living room lights after a delay'
fields:
minutes:
description: 'The amount of time to wait before turning on the living room lights'
example: 1
sequence:
.
.
the script above will show in the states page as “script.wakeup”. and in the UI as “Wake Up”.
Thanks finity,
If I had access to my HA instance and sample code, I ‘may’ (no guarantee though) have caught that, same with Marc’s comment earlier.
I seem to be okay extrapolating from known examples but less so on writing on a blank sheet, I shall try to improve and I appreciate both your inputs, as I’m sure John does too.
finity, apologies if you felt spammed (tink’s point above)