Please format your code so it preserves the indents. Select the code and then press the preformatted option button as indicated in this image:
There are a few ways to go about this but I would do this because I am a noob, and yes please use the < / > in the tool bar.
Create a…
Script
timed_light_plus_notify:
sequence:
- service: notify.mypushbullet
data:
message: "Turning on Lights!"
- service: switch.turn_on
data:
entities:
- switch.relay_2_1
- switch.relay_2_3
Then I would create a…
Automation
- alias: Lights On
trigger:
platform: time
after: '18:55:00'
action:
service: script.turn_on
entity_id: script.timed_light_plus_notify
Like I said I am sure there are better, faster ways but this will work.
Regards,
@PtP Thank you for your suggestion. I will try this out.
I was using mobile and didn’t find the toolbar as it was hidden by default. Sorry for the inconvenience if any.
automation 4:
- alias: 'Light On'
trigger:
platform: time
after: "18:55:00"
action:
- service: notify.mypushbullet
data:
message: 'Turning ON Gate Light!'
title: 'Home Assistant'
- service: switch.turn_on
entity_id: switch.relay_2_1
- service: switch.turn_on
entity_id: switch.relay_2_3
No worries!
I have not tested your code but maybe indenting both of your entity_ids under the second and third - service by 2 spaces might help.
Or…
- service: switch.turn_on
entities:
- switch.relay_2_1
- switch.realy_2_3
This method didn’t work.
ERROR:homeassistant.util.yaml:mapping values are not allowed here
- service: switch.turn_on
entities: #Error is in this line
- switch.relay_2_1
- switch.realy_2_3
timed_light_plus_notify:
sequence:
- service: notify.mypushbullet
data:
message: "Turning on Lights!"
- service: switch.turn_on
data:
entity_id:
switch.relay_2_1
- service: switch.turn_on
data:
entity_id:
switch.relay_2_3
Break them up into 2 or create a group.
Thank you for the suggestion. However, I tried using script and break them in to two items. But didn’t succeed.
Its executing till the “light 1 On”. But the second light didn’t Turn On and UI didn’t update.
Here is the code i have used. Is it a bug or it will not support to a call the same service (service: switch.turn_on) with different entity_id 's.
script:
timed_light_plus_notify:
sequence:
- alias: Push Notification Lights On
service: notify.mypushbullet
data:
message: 'Turning ON Gate Light!'
title: 'Home Assistant'
- alias: light 1 On
service: switch.turn_on
data:
entity_id: switch.relay_2_1
- alias: light 2 On
service: switch.turn_on
data:
entity_id: switch.relay_2_3
automation 4:
- alias: 'Light On'
trigger:
platform: time
after: "09:14:00"
action:
service: script.turn_on
entity_id: script.timed_light_plus_notify
I will now try using the groups as you suggested.
- service: switch.turn_on
entity_id:
- switch.relay_2_1
- switch.realy_2_3
I ended up doing like this, its working now.
But its too much code duplication, is there any better way to achieve this?
automation 4:
- alias: 'Light1 On'
trigger:
platform: time
after: "10:00:00"
action:
- service: notify.mypushbullet
data:
message: 'Turning ON Gate Light!'
title: 'Home Assistant'
- service: switch.turn_on
entity_id: switch.relay_2_1
automation 5:
- alias: 'Light2 On'
trigger:
platform: time
after: "10:00:00"
action:
- service: notify.mypushbullet
data:
message: 'Turning ON Varantha Light!'
title: 'Home Assistant'
- service: switch.turn_on
entity_id: switch.relay_2_3
Appdaemon
If you know Python
I am pretty sure the yaml you posted before last was close. You don’t use aliases in a sequence.
Best of Luck!!
automation 4:
- alias: 'Light1 On'
trigger:
platform: time
after: "10:00:00"
action:
- service: notify.mypushbullet
data:
message: 'Turning ON Gate Light!'
title: 'Home Assistant'
- service: switch.turn_on
entity_id: switch.relay_2_1
- service: notify.mypushbullet
data:
message: 'Turning ON Varantha Light!'
title: 'Home Assistant'
- service: switch.turn_on
entity_id: switch.relay_2_3
@PtP Thank you for your support, I don’t know much on Python, anyways I will try Appdaemon.
I had tried with out alias as you suggested, but no luck, hence tried using alias as well.
I saw the alias is the sample script https://home-assistant.io/components/script/
I’m very glad that we have such a great community here to help each other.
@devdelay This worked!! Thank you very much.
Is it worked because we have added another notify service in between the switch service?
Very strange and confused
automation 4:
- alias: 'Lights On'
trigger:
platform: time
after: "10:25:00"
action:
- service: notify.mypushbullet
data:
message: 'Turning ON Gate Light!'
title: 'Home Assistant'
- service: switch.turn_on
entity_id: switch.relay_2_1
- service: notify.mypushbullet
data:
message: 'Turning ON Varantha Light!'
title: 'Home Assistant'
- service: switch.turn_on
entity_id: switch.relay_2_3
Worked for me
Use a comma to turn more than one entity on:
entity_id: switch.relay_2_1, switch.relay_2_3
I can confirm that this works
- alias: Zet lampen tuin automatisch aan bij zonsondergang
trigger:
- platform: numeric_state
entity_id: sun.sun
value_template: '{{ state.attributes.elevation }}'
below: -4 # Solar elevation. This is the angle between the sun and the horizon. Negative values mean the sun is below the horizon.
action:
- service: light.turn_on
data:
entity_id: light.achtertuin, light.voortuin, light.voortuin_dubbel
brightness_pct: 60
color_name: white
and this doesn’t
- alias: Zet lampen tuin automatisch aan bij zonsondergang
trigger:
- platform: numeric_state
entity_id: sun.sun
value_template: '{{ state.attributes.elevation }}'
below: -4 # Solar elevation. This is the angle between the sun and the horizon. Negative values mean the sun is below the horizon.
action:
- service: light.turn_on
data:
entity_id: light.achtertuin
brightness_pct: 60
color_name: white
- service: light.turn_on
data:
entity_id: light.voortuin
brightness_pct: 70
color_name: white
- service: light.turn_on
data:
entity_id: light.voortuin_dubbel
brightness_pct: 70
color_name: white
Strange that the 2nd yaml code doesn’t work.
I’m with gerard33 here,
As I read it there should be no reason why his second code doesn’t work over the first.
In fact I would say the second (though longer) is more flexible as I want to set data, data_template, light.turn_on AND a light.turn_off from a given trigger
This implies you have to pick one and repeat triggers ???
Confused as hell
Mutt
Had the same issue.
I could not get 2 actions to work in one automation.
But when i took a copy of automation and pasted it below it + rename for the copy.
All of the sudden the top one worked.
When using the Configurator addon i noticed the extra “ENTER’s” below the last automation that did not work.
i removed the extra “ENTER’s” and all of the sudden it worked for all of them !!! WIN