No errors in the log but most of my automations aren't working!

This is driving me nuts. I’ve spent dozens of hours re-doing things. They work one minute and don’t the next. Without any error messages in the log I don’t know where to go from here. I already re-built everything from scratch once. Does anyone see anything that could be causing me issues?

In my automation.yaml below, the only things that do work are: 1) theme 2) harmony hub 3) input sliders for my light brightness.

Things not working are the motion detection for the lights and the 2 tasks that turn on my music in the morning and then turn it off when I’m gone. They were all working previously. Any help is much appreciated!

############################################
# THEMES
############################################
# Set Theme to Dark Mode on startup - WORKING
- id: Theme Set to Dark Mode
  alias: 'Set theme at startup'
  initial_state: 'on'
  trigger:
    - platform: homeassistant
      event: start
  action:
    - service: frontend.set_theme
      data:
        name: dark_mode
#    - service: input_boolean
###########################################
# HARMONY HUB
###########################################
# Update Harmony Hub - WORKING
- id: Remote Update Harmony Hub
  alias: 'Remote update Harmony Hub'
  trigger:
    platform: state
    entity_id: remote.harmony_hub
  action:
    service: input_select.select_option
    data_template:
      entity_id: input_select.harmony_hub
      option: >
        {{ states.remote.harmony_hub.attributes.current_activity }}
# Harmony Start Selected Activity - WORKING
- id: Start Selected Activity
  alias: 'Remote start activity from input select living room tv'
  trigger:
    platform: state
    entity_id: input_select.harmony_hub
  action:
    service: script.turn_on
    entity_id: script.input_select_harmony
###########################################
# MOTION
###########################################
# Office Motion On
- id: Office_Motion
  alias: Turn on the office lights when movement is detected
  trigger:
  - entity_id: binary_sensor.office_motion
    platform: state
    to: 'on'
  action:
    - service: scene.turn_on
      entity_id: scene.office_on

# Bathroom Motion On
- id: Bathroom_Motion_On
  alias: Turn on the bathroom lights when movement is detected
  trigger:
  - entity_id: binary_sensor.bathroom_motion
    platform: state
    to: 'on'
  action:
  - service: scene.turn_on
    entity_id: scene.bathroom_on

# Front Porch Motion On
- id: Front_Porch_Motion_On
  alias: Turn on the front porch lights when movement is detected
  trigger:
  - entity_id: binary_sensor.front_porch_motion
    platform: state
    to: 'on'
  action:
  - service: scene.turn_on
    entity_id: scene.front_porch_on

# Bathroom Motion Stopped
- id: Bathroom Motion Stopped
  alias: Bathroom Motion Stopped
  trigger:
    - platform: state
      entity_id: binary_sensor.bathroom_motion
      to: 'off'
      for:
        minutes: '3'
  action:
    - service: scene.turn_on
      entity_id: scene.bathroom_off
# Front Porch Motion Stopped
- id: Front Porch Motion Stopped
  alias: Front Porch Motion Stopped
  trigger:
    - platform: state
      entity_id: binary_sensor.front_porch_motion
      to: 'off'
      for:
        minutes: '3'
  action:
    - service: scene.turn_on
      entity_id: scene.front_porch_off

# Shut off the music at 7:15AM - NOT WORKING ANYMORE
- id: Morning Shutdown 
  alias: Shut off bathroom chromecast each morning
  hide_entity: false
  trigger:
    platform: time
    at: 07:20:00
  condition:
    condition: time
    weekday:
    - mon
    - tue
    - wed
    - thu
    - fri
  action:
    - service: media_player.turn_off
      entity_id: media_player.all_devices_group
#####################
# MORNING ROUTINE
#####################
# Start iHeartRadio in the morning - NOT WORKING ANYMORE
- id: Morning Startup
  alias: Turns on the chromecast and plays iHeartRadio in the bathroom each morning
  hide_entity: false
  trigger:
  - platform: time
    at: '06:10:00'
  condition:
  - condition: time
    weekday:
    - mon
    - tue
    - wed
    - thu
    - fri
  action:
    service: media_player.play_media
    entity_id: media_player.all_devices_group
    data:
      media_content_id: http://kbpi-fm.akacast.akamaistream.net/7/535/19810/v1/auth.akacast.akamaistream.net/kbpi-fm
      media_content_type: audio/mp3
####################
# MEDIA PLAYING 
####################
# Fire TV Paused - Not working anymore
- id: FireTV_Paused
  alias: Media player paused/stopped
  trigger:
  - platform: state
    entity_id: media_player.fire_tv
    from: 'playing'
    to: 'idle'
  - platform: state
    entity_id: media_player.living_room
    from: 'playing'
    to: 'idle'
  condition:
  - condition: state
    entity_id: sun.sun
    state: below_horizon
  action:
    service: scene.turn_on
    entity_id: scene.living_room_normal

- id: Fire TV Playing
  alias: "Fire TV is playing"
  trigger:
    - platform: state
      entity_id: media_player.fire_tv
      to: 'playing'
      from: 'idle'
  condition:
    - condition: state
      entity_id: sun.sun
      state: 'below_horizon'
  action:
    service: scene.turn_on
    entity_id: scene.living_room_theater_on

###################################################
# BRIGHTNESS SLIDERS
###################################################

# All Lights Brightness Slider - WORKING
- id: All Lights Brightness Slider
  alias: All Lights Brightness
  trigger:
    platform: state
    entity_id: input_slider.all_lights_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: group.all_lights
        brightness: '{{ states.input_slider.all_lights_light_brightness.state | int }}'
# Back Porch Brightness Slider - WORKING
- id: Back Porch Brightness Slider
  alias: Back Porch Brightness
  trigger:
    platform: state
    entity_id: input_slider.back_porch_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.back_porch
        brightness: '{{ states.input_slider.back_porch_light_brightness.state | int }}'
# Bathroom Brightness Slider - WORKING
- id: Bathroom Brightness Slider
  alias: Bathroom Brightness
  trigger:
    platform: state
    entity_id: input_slider.bathroom_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.bathroom
        brightness: '{{ states.input_slider.bathroom_light_brightness.state | int }}'
# Dining Room Brightness Slider - WORKING
- id: Dining Room Brightness Slider
  alias: Dining Room Brightness
  trigger:
    platform: state
    entity_id: input_slider.dining_room_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.dining_room
        brightness: '{{ states.input_slider.dining_room_light_brightness.state | int }}'
# Front Porch Brightness Slider - WORKING
- id: Front Porch Brightness Slider
  alias: Front Porch Brightness
  trigger:
    platform: state
    entity_id: input_slider.front_porch_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.front_porch
        brightness: '{{ states.input_slider.front_porch_light_brightness.state | int }}'
# Office Brightness Slider - WORKING
- id: Office Brightness Slider
  alias: Office Brightness
  trigger:
    platform: state
    entity_id: input_slider.office_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.office
        brightness: '{{ states.input_slider.office_light_brightness.state | int }}'
# Living Room Brightness Slider - WORKING
- id: Living Room Brightness Slider
  alias: Living Room Brightness
  trigger:
    platform: state
    entity_id: input_slider.living_room_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.living_room
        brightness: '{{ states.input_slider.living_room_light_brightness.state | int }}'
# Bedroom Brightness Slider - WORKING
- id: Bedroom Brightness Slider
  alias: Bedroom Brightness
  trigger:
    platform: state
    entity_id: input_slider.bedroom_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.bedroom_2
        brightness: '{{ states.input_slider.bedroom_light_brightness.state | int }}'

Start by making your code consistent like:

trigger:
  platform: state
  entity_id:

On some automations you start the trigger with entity_id: instead of platform:. Same thing for spacing.

Ok thanks I will update it. So is platform supposed to go firs? Or it does not matter if entity goes first as long as they are all consistent? I’ll assume platform based on your example

Ok I updated them all to platform first and things still arent working like the dimming while watching fire tv and the getting the media player to turn on at X time. The lights turning on when they sense motion work about 20 to 40 percent of the time.

Is there nything else you can see wrong? Its strange that I get no errors yet multiple automation s do not work for me. All my other HA stuff is working well. Here is the updated automation.yaml:

############################################
# THEMES
############################################
# Set Theme to Dark Mode on startup - WORKING
- id: Theme Set to Dark Mode
  alias: 'Set theme at startup'
  initial_state: 'on'
  trigger:
    - platform: homeassistant
      event: start
  action:
    - service: frontend.set_theme
      data:
        name: dark_mode
#    - service: input_boolean
###########################################
# HARMONY HUB
###########################################
# Update Harmony Hub - WORKING
- id: Remote Update Harmony Hub
  alias: 'Remote update Harmony Hub'
  trigger:
    - platform: state
      entity_id: remote.harmony_hub
  action:
    service: input_select.select_option
    data_template:
      entity_id: input_select.harmony_hub
      option: >
        {{ states.remote.harmony_hub.attributes.current_activity }}
# Harmony Start Selected Activity - WORKING
- id: Start Selected Activity
  alias: 'Remote start activity from input select living room tv'
  trigger:
    platform: state
    entity_id: input_select.harmony_hub
  action:
    service: script.turn_on
    entity_id: script.input_select_harmony
###########################################
# MOTION
###########################################
# Office Motion On
- id: Office_Motion
  alias: Turn on the office lights when movement is detected
  trigger:
    - platform: state
      entity_id: binary_sensor.office_motion
      to: 'on'
  action:
    - service: scene.turn_on
      entity_id: scene.office_on

# Bathroom Motion On
- id: Bathroom_Motion_On
  alias: Turn on the bathroom lights when movement is detected
  trigger:
    - platform: state
      entity_id: binary_sensor.bathroom_motion
      to: 'on'
  action:
    - service: scene.turn_on
      entity_id: scene.bathroom_on

# Front Porch Motion On
- id: Front_Porch_Motion_On
  alias: Turn on the front porch lights when movement is detected
  trigger:
    - platform: state
      entity_id: binary_sensor.front_porch_motion
      to: 'on'
  action:
    - service: scene.turn_on
      entity_id: scene.front_porch_on

# Bathroom Motion Stopped
- id: Bathroom Motion Stopped
  alias: Bathroom Motion Stopped
  trigger:
    - platform: state
      entity_id: binary_sensor.bathroom_motion
      to: 'off'
      for:
        minutes: '3'
  action:
    - service: scene.turn_on
      entity_id: scene.bathroom_off
# Front Porch Motion Stopped
- id: Front Porch Motion Stopped
  alias: Front Porch Motion Stopped
  trigger:
    - platform: state
      entity_id: binary_sensor.front_porch_motion
      to: 'off'
      for:
        minutes: '3'
  action:
    - service: scene.turn_on
      entity_id: scene.front_porch_off

# Shut off the music at 7:15AM - NOT WORKING ANYMORE
- id: Morning Shutdown 
  alias: Shut off bathroom chromecast each morning
  hide_entity: false
  trigger:
    - platform: time
      at: 07:20:00
  condition:
    - condition: time
      weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
  action:
    - service: media_player.turn_off
      entity_id: media_player.all_devices_group
#####################
# MORNING ROUTINE
#####################
# Start iHeartRadio in the morning - NOT WORKING ANYMORE
- id: Morning Startup
  alias: Turns on the chromecast and plays iHeartRadio in the bathroom each morning
  hide_entity: false
  trigger:
  - platform: time
    at: '06:10:00'
  condition:
  - condition: time
    weekday:
    - mon
    - tue
    - wed
    - thu
    - fri
  action:
    service: media_player.play_media
    entity_id: media_player.all_devices_group
    data:
      media_content_id: http://kbpi-fm.akacast.akamaistream.net/7/535/19810/v1/auth.akacast.akamaistream.net/kbpi-fm
      media_content_type: audio/mp3
####################
# MEDIA PLAYING 
####################
# Fire TV Paused - Not working anymore
- id: FireTV_Paused
  alias: Media player paused/stopped
  trigger:
  - platform: state
    entity_id: media_player.fire_tv
    from: 'playing'
    to: 'idle'
  - platform: state
    entity_id: media_player.living_room
    from: 'playing'
    to: 'idle'
  condition:
  - condition: state
    entity_id: sun.sun
    state: below_horizon
  action:
    service: scene.turn_on
    entity_id: scene.living_room_normal

- id: Fire TV Playing
  alias: "Fire TV is playing"
  trigger:
    - platform: state
      entity_id: media_player.fire_tv
      to: 'playing'
      from: 'idle'
  condition:
    - condition: state
      entity_id: sun.sun
      state: 'below_horizon'
  action:
    service: scene.turn_on
    entity_id: scene.living_room_theater_on

###################################################
# BRIGHTNESS SLIDERS
###################################################

# All Lights Brightness Slider - WORKING
- id: All Lights Brightness Slider
  alias: All Lights Brightness
  trigger:
    platform: state
    entity_id: input_slider.all_lights_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: group.all_lights
        brightness: '{{ states.input_slider.all_lights_light_brightness.state | int }}'
# Back Porch Brightness Slider - WORKING
- id: Back Porch Brightness Slider
  alias: Back Porch Brightness
  trigger:
    platform: state
    entity_id: input_slider.back_porch_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.back_porch
        brightness: '{{ states.input_slider.back_porch_light_brightness.state | int }}'
# Bathroom Brightness Slider - WORKING
- id: Bathroom Brightness Slider
  alias: Bathroom Brightness
  trigger:
    platform: state
    entity_id: input_slider.bathroom_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.bathroom
        brightness: '{{ states.input_slider.bathroom_light_brightness.state | int }}'
# Dining Room Brightness Slider - WORKING
- id: Dining Room Brightness Slider
  alias: Dining Room Brightness
  trigger:
    platform: state
    entity_id: input_slider.dining_room_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.dining_room
        brightness: '{{ states.input_slider.dining_room_light_brightness.state | int }}'
# Front Porch Brightness Slider - WORKING
- id: Front Porch Brightness Slider
  alias: Front Porch Brightness
  trigger:
    platform: state
    entity_id: input_slider.front_porch_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.front_porch
        brightness: '{{ states.input_slider.front_porch_light_brightness.state | int }}'
# Office Brightness Slider - WORKING
- id: Office Brightness Slider
  alias: Office Brightness
  trigger:
    platform: state
    entity_id: input_slider.office_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.office
        brightness: '{{ states.input_slider.office_light_brightness.state | int }}'
# Living Room Brightness Slider - WORKING
- id: Living Room Brightness Slider
  alias: Living Room Brightness
  trigger:
    platform: state
    entity_id: input_slider.living_room_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.living_room
        brightness: '{{ states.input_slider.living_room_light_brightness.state | int }}'
# Bedroom Brightness Slider - WORKING
- id: Bedroom Brightness Slider
  alias: Bedroom Brightness
  trigger:
    platform: state
    entity_id: input_slider.bedroom_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.bedroom_2
        brightness: '{{ states.input_slider.bedroom_light_brightness.state | int }}'

Maybe try and add Initial_state: on to all of your automations. Ive had problems in the past with only some working and discovered they were off on restart.

Haha coincidental timing, i just did that and appreciate your suggestion. it seems to be helping a bit but the motion sensor automations still aren’t reliable at all. I’ll test the media player on at x time tomorrow. That’s what I really would like to get working again.

What kind of motion sensors are you using because for example the xiaomi ones have a rather long timeout (something like >1 minute) before they are re-triggered.

The motion sensors I have are gocontrol and eco. One I was able to set to detect motion every 20 seconds or so and the other is every minute or 2. I’ve been trying 3 minutes of motion stopped in my automations but will try 5 minutes just to check that. That could explain the lights not turning off but I’m still seeing the motion sensor trigger and the lights not turning on sometimes. And sometimes when they do turn on there’s a 10 second delay. Is there any way to eliminate the delay?

I don’t think increasing the off time will change anything. What I was refering too is that the xiaomi sensors stay on for a minimum of 1 minute. If you’re seeing motion being detected there must be another issue.

About the delay, do you mean after motion is detected in HA it takes up to 10 seconds before the lights turn on or does it take up to 10 seconds before HA detects the motion?

I have configured it slightly different, not off for 3 minutes but a delay in the action based on a slider:

  trigger:
  - platform: state
    entity_id: binary_sensor.motion_sensor_xxxx
    to: 'off'

  condition:
    condition: state
    entity_id: light.xxxx
    state: 'on'

  action:
    - delay: '00:{{ states.input_slider.xxxx.state | int }}:00'
    - service: light.turn_off
      entity_id: light.xxxx

the problem with your automations is the syntax I think (90% sure in fact).

you need two spaces alignment before a “-”.
for instance what you have on your post 4:

- id: FireTV_Paused
  alias: Media player paused/stopped
  trigger:
  - platform: state
    entity_id: media_player.fire_tv
    from: 'playing'
    to: 'idle'
  - platform: state
    entity_id: media_player.living_room
    from: 'playing'
    to: 'idle'
  condition:
  - condition: state
    entity_id: sun.sun
    state: below_horizon
  action:
    service: scene.turn_on
    entity_id: scene.living_room_normal

while you should have

- id: FireTV_Paused
  alias: Media player paused/stopped
  trigger:
    - platform: state
      entity_id: media_player.fire_tv
      from: 'playing'
      to: 'idle'
    - platform: state
      entity_id: media_player.living_room
      from: 'playing'
      to: 'idle'
  condition:
    - condition: state
      entity_id: sun.sun
      state: below_horizon
  action:
    service: scene.turn_on
    entity_id: scene.living_room_normal

an the same goes for all the other automations obviously

Thank you both.

Sjee, yes it seems there is a delay turning the lights on. HA detects the motion right away but the lights fan sometimes take another 10 seconds or more to turn on. And when they turn on they aren’t always turning off after 3 minutes of motion stopped.

Your way looks pretty slick I will have to try that when I get home today.

Lambtho you are correct. I made that update and things are working like the media player turning on in the morning. Still having issues with the motion sensor triggering lights. My front porch is working but not my bathroom ones.

Do your lights turn on and off immediately when you do it manually from the states tab? Which lights do you have?

Could you repost an updated version of your automations ?

@Jer78 so you set initial_state in your automations as a precaution?

I also see a lot of from: 'off' to: 'on' statements, does that add anything to the reliability in case of a binary sensor or is there an other reason to do this?

1 Like

@sjee Yeah I do it as a precaution. There’s no time I ever want my automations off when I restart HA. And I found that for some reason they sometimes are off which makes it hard to troubleshoot when you’re working on one. You have to check whether it’s running or not first then turn it on if it’s off and that’s annoying.

As for using from off to on for triggers, I don’t think it matters at all for something like a binary sensor. You’d use it more with input_select or sensors where you may have more combinations.

Yes I will post the updated automations in about an hour when I get home for lunch. The lights in using are hue for the most part. But the groups in using are the ones HA created from my wink. Maybe wink is the delay in some cases because when I toggle switches on the front end the lights respond immediately and those are the _2 hue versions

Ok here is the most recent, cleaned up version of automations.yaml:

############################################
# THEMES
############################################
# Set Theme to Dark Mode on startup - WORKING
- id: Theme Set to Dark Mode
  alias: 'Set theme at startup'
  initial_state: 'on'
  trigger:
    - platform: homeassistant
      event: start
  action:
    - service: frontend.set_theme
      data:
        name: dark_mode

###########################################
# HARMONY HUB
###########################################
# Update Harmony Hub - WORKING
- id: Remote Update Harmony Hub
  alias: 'Remote update Harmony Hub'
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: remote.harmony_hub
  action:
    - service: input_select.select_option
      data_template:
        entity_id: input_select.harmony_hub
        option: >
          {{ states.remote.harmony_hub.attributes.current_activity }}
# Harmony Start Selected Activity - WORKING
- id: Start Selected Activity
  alias: 'Remote start activity from input select living room tv'
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_select.harmony_hub
  action:
    - service: script.turn_on
      entity_id: script.input_select_harmony
###########################################
# MOTION
###########################################
# Office Motion On
- id: Office_Motion
  alias: Turn on the office lights when movement is detected
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: binary_sensor.office_motion
      to: 'on'
  action:
    - service: scene.turn_on
      entity_id: scene.office_on

# Bathroom Motion On
- id: Bathroom_Motion_On
  alias: Turn on the bathroom lights when movement is detected
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: binary_sensor.bathroom_motion
      to: 'on'
  action:
    - service: scene.turn_on
      entity_id: scene.bathroom_on

# Front Porch Motion On
- id: Front_Porch_Motion_On
  alias: Turn on the front porch lights when movement is detected
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: binary_sensor.front_porch_motion
      to: 'on'
  action:
    - service: scene.turn_on
      entity_id: scene.front_porch_on
# Bathroom Motion Stopped
- id: Bathroom Motion Stopped
  alias: Bathroom Motion Stopped
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: binary_sensor.bathroom_motion
      to: 'off'
      for:
        minutes: '3'
  action:
    - service: scene.turn_on
      entity_id: scene.bathroom_off
# Front Porch Motion Stopped
- id: Front Porch Motion Stopped
  alias: Front Porch Motion Stopped
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: binary_sensor.front_porch_motion
      to: 'off'
      for:
        minutes: '3'
  action:
    - service: scene.turn_on
      entity_id: scene.front_porch_off
# Shut off the music at 7:15AM - NOT WORKING ANYMORE
- id: Morning Shutdown 
  alias: Shut off bathroom chromecast each morning
  initial_state: 'on'
  hide_entity: false
  trigger:
    - platform: time
      at: 07:20:00
  condition:
    - condition: time
      weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
  action:
    - service: media_player.turn_off
      entity_id: media_player.all_devices_group
#####################
# MORNING ROUTINE
#####################
# Start iHeartRadio in the morning - NOT WORKING ANYMORE
- id: Morning Startup
  alias: Turns on the chromecast and plays iHeartRadio in the bathroom each morning
  initial_state: 'on'
  hide_entity: false
  trigger:
    - platform: time
      at: '06:10:00'
  condition:
    - condition: time
      weekday:
        - mon
        - tue
        - wed
        - thu
        - fri
  action:
    - service: media_player.play_media
      entity_id: media_player.all_devices_group
      data:
        media_content_id: http://kbpi-fm.akacast.akamaistream.net/7/535/19810/v1/auth.akacast.akamaistream.net/kbpi-fm
        media_content_type: audio/mp3
####################
# MEDIA PLAYING 
####################
# Fire TV Paused - Not working anymore
- id: FireTV_Paused
  alias: Media player paused/stopped
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: media_player.fire_tv
      from: 'playing'
      to: 'idle'
    - platform: state
      entity_id: media_player.living_room
      from: 'playing'
      to: 'idle'
  condition:
    - condition: state
      entity_id: sun.sun
      state: below_horizon
  action:
    - service: scene.turn_on
      entity_id: scene.living_room_normal
#
- id: Fire TV Playing
  alias: "Fire TV is playing"
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: media_player.fire_tv
      to: 'playing'
      from: 'idle'
  condition:
    - condition: state
      entity_id: sun.sun
      state: 'below_horizon'
  action:
    - service: scene.turn_on
      entity_id: scene.living_room_theater_on
###################################################
# BRIGHTNESS SLIDERS
###################################################
# All Lights Brightness Slider - WORKING
- id: All Lights Brightness Slider
  alias: All Lights Brightness
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_slider.all_lights_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: group.all_lights
        brightness: '{{ states.input_slider.all_lights_light_brightness.state | int }}'
# Back Porch Brightness Slider - WORKING
- id: Back Porch Brightness Slider
  alias: Back Porch Brightness
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_slider.back_porch_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.back_porch
        brightness: '{{ states.input_slider.back_porch_light_brightness.state | int }}'
# Bathroom Brightness Slider - WORKING
- id: Bathroom Brightness Slider
  alias: Bathroom Brightness
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_slider.bathroom_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.bathroom
        brightness: '{{ states.input_slider.bathroom_light_brightness.state | int }}'
# Dining Room Brightness Slider - WORKING
- id: Dining Room Brightness Slider
  alias: Dining Room Brightness
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_slider.dining_room_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.dining_room
        brightness: '{{ states.input_slider.dining_room_light_brightness.state | int }}'
# Front Porch Brightness Slider - WORKING
- id: Front Porch Brightness Slider
  alias: Front Porch Brightness
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_slider.front_porch_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.front_porch
        brightness: '{{ states.input_slider.front_porch_light_brightness.state | int }}'
# Office Brightness Slider - WORKING
- id: Office Brightness Slider
  alias: Office Brightness
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_slider.office_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.office
        brightness: '{{ states.input_slider.office_light_brightness.state | int }}'
# Living Room Brightness Slider - WORKING
- id: Living Room Brightness Slider
  alias: Living Room Brightness
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_slider.living_room_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.living_room
        brightness: '{{ states.input_slider.living_room_light_brightness.state | int }}'
# Bedroom Brightness Slider - WORKING
- id: Bedroom Brightness Slider
  alias: Bedroom Brightness
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_slider.bedroom_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.bedroom_2
        brightness: '{{ states.input_slider.bedroom_light_brightness.state | int }}'
####### TEST JOIN
# - id: Test Join
  # alias: Test Join
  # trigger:
    # platform: state
    # entity_id: input_boolean.activate_join
    # to: 'on'
  # action:
    # service: notify.join
    # data:
      # target:
        # - 'Phone'
      # title: Test Notification From Home Assistant
      # message: 'text/This is a test!!!'

When I got home for lunch the bathroom motion sensor triggered the light almost immediately. It’s so weird how things work then don’t then do then don’t. I really hope I can get this all to work reliably.

Thanks for everyone’s help so far!

I’m anxious to mess with this more tonight. My eventual goal is to have several time conditions that will adjust the number of minutes between notion stopped and the lights turning off. So like 1 minute between 10pm and 6am, 20 minutes between 6:01 am and 7:15am and then maybe 5 minutes between 7:16am and 9:59pm.

I’ve seen an example of that somewhere but I hope it’s still current and works. If anyone has a working example of that they could share I would be very grateful!

Not 100% sure, but almost… when you have the ‘for/minutes(or hour or second)’ in your automations, you MUST have directly the numeric value. If you put some ’ ’ around it, it will read it as a string.
So for instance, change

  trigger:
    - platform: state
      entity_id: binary_sensor.front_porch_motion
      to: 'off'
      for:
        minutes: '3'

with

  trigger:
    - platform: state
      entity_id: binary_sensor.front_porch_motion
      to: 'off'
      for:
        minutes: 3

could you reexplain what issues are you still facing with that last version of your automations ? Also, when you say ‘not working’, do you still see a line that says it has triggered anyway (which means the errors comes from the action part), or do you not see anything (which means the trigger/condition part is most likely the problem)
Could you also try to trigger the automations manually using the dev-services tool and report what happens ?

Yes thank you for following back up with me. I’m having just as many problems now with automations as I was the other day. It seems any time I had new automations or change other things some existing automations break without any changes being made to them. That’s handy that you meantion errors equal problems with actions and no errors points to the other. Seems simple but not a connection I had made.

I think you may be right about quotes being a no no under the for: of a trigger. From what I’ve googled most people agree with that. But I seem to remember reading to the contrary before but I’ve taken them out for now.

I have since learned that quotes ARE necessary for when used in a trigger like:

# Shut off the music at 7:20AM
- id: Morning Shutdown 
  alias: Shut off bathroom chromecast each morning
  initial_state: 'on'
  hide_entity: false
  trigger:
    - platform: time
      at: '21:29:00'
  condition:
    - condition: time
      weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
  action:
    - service: media_player.turn_off
      entity_id: media_player.all_devices_group

That one above works and so does my other one to turn it off later. Earlier tonight I didn’t have the quotes and was getting and error message. Just in case anyone else is reading this.

Where I’m still having problems is with the motion sensors turning OFF the lights on 2 of them. All 3 of the motion sensors turn ON their respective room’s lights just fine (well the bathroom one is delayed 10 seconds and some times doesn’t trigger) but only the front porch is successfully turning off after X minutes.

What’s strange is I’m using the same exact thing for all 3 of them and only 1 turns off.

I’m also having problems with my media player (in my case Fire TV) not dimming the lights like it should. I had those 2 automations working succesfully a week or 2 ago and I’m not sure what happened. Any ideas for those?

I tried sjee’s input slider to control delay time for turning the lights off too. I believe I have it set up correctly but it hasn’t worked yet. Here is what I’ve got for that:

# Bathroom Motion Stopped <--------- NOT WORKING :(
- id: Bathroom Motion Stopped
  alias: Bathroom Motion Stopped
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: binary_sensor.bathroom_motion
      to: 'off'
  condition:
    - condition: state
      entity_id: scene.bathroom_on
      state: 'on'
  action:
    - delay: '00:{{ states.input_slider.sensor_delay_bathroom.state | int }}:00'
    - service: scene.turn_on
      entity_id: scene.bathroom_off

and in my input_sliders.yaml:

sensor_delay_bathroom:
  name: Bathroom Sensor Delay
  initial: 1
  min: 1
  max: 10
  step: 1

I took your suggestion and looked through the logbook, what I’m seeing is all of the motions sensors triggering, all of the automations that turn all of the lights triggering, and only the front porch light off automation firing, not the bathroom one. The office one I haven’t tested as much because I am always in there working on there. If it matters, all of my lights are hue lights except the front porch. And 2 of my motion sensors or ecolink and the bathroom one is gocontrol.

In my error log, sometimes I am seeing these errors. sometimes they are there and most times they are not. It has to do with the input sliders I added to control volume for each device and my chromcast/google home groups. is it a cause for concern? I restarted hass right after typing this and no errors. Here they are:

2017-09-01 21:26:58 WARNING (SyncWorker_6) [netdisco.ssdp] Error fetching description at 127.0.0.1
2017-09-01 21:26:58 WARNING (SyncWorker_6) [netdisco.ssdp] Error fetching description at 192.168.1.159
2017-09-01 21:26:58 WARNING (SyncWorker_6) [netdisco.ssdp] Error fetching description at 192.168.1.248
2017-09-01 21:26:59 WARNING (SyncWorker_6) [netdisco.ssdp] Error fetching description at https://192.168.1.33:8888
2017-09-01 21:27:01 WARNING (SyncWorker_2) [pywemo.ssdp] Error fetching description at https://192.168.1.33:8888
2017-09-01 21:27:08 ERROR (MainThread) [homeassistant.core] Invalid service data for input_slider.select_value: expected float for dictionary value @ data['value']. Got ''
2017-09-01 21:27:08 ERROR (MainThread) [homeassistant.core] Invalid service data for input_slider.select_value: expected float for dictionary value @ data['value']. Got ''
2017-09-01 21:27:08 ERROR (MainThread) [homeassistant.core] Invalid service data for input_slider.select_value: expected float for dictionary value @ data['value']. Got ''
2017-09-01 21:27:08 ERROR (MainThread) [homeassistant.core] Invalid service data for input_slider.select_value: expected float for dictionary value @ data['value']. Got ''
2017-09-01 21:27:08 ERROR (MainThread) [homeassistant.core] Invalid service data for input_slider.select_value: expected float for dictionary value @ data['value']. Got ''
2017-09-01 21:29:00 ERROR (MainThread) [homeassistant.core] Invalid service data for input_slider.select_value: expected float for dictionary value @ data['value']. Got ''
2017-09-01 21:32:22 WARNING (SyncWorker_15) [netdisco.ssdp] Error fetching description at 192.168.1.199

Just curious, what does that error fetching description message mean? I see that from time to time as well.

Newest automations.yaml:

############################################
# THEMES
############################################
# Set Theme to Dark Mode on startup
- id: Theme Set to Dark Mode
  alias: 'Set theme at startup'
  initial_state: 'on'
  trigger:
    - platform: homeassistant
      event: start
  action:
    - service: frontend.set_theme
      data:
        name: dark_mode

###########################################
# HARMONY HUB
###########################################
# Update Harmony Hub
- id: Remote Update Harmony Hub
  alias: 'Remote update Harmony Hub'
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: remote.harmony_hub
  action:
    - service: input_select.select_option
      data_template:
        entity_id: input_select.harmony_hub
        option: >
          {{ states.remote.harmony_hub.attributes.current_activity }}
# Harmony Start Selected Activity
- id: Start Selected Activity
  alias: 'Remote start activity from input select living room tv'
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_select.harmony_hub
  action:
    - service: script.turn_on
      entity_id: script.input_select_harmony
###########################################
# MOTION
###########################################
# Office Motion On
- id: Office_Motion
  alias: Turn on the office lights when movement is detected
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: binary_sensor.office_motion
      to: 'on'
  condition:
    - condition: state
      entity_id: light.office
      state: 'off'
  action:
    - service: scene.turn_on
      entity_id: scene.office_on

# Bathroom Motion On
- id: Bathroom_Motion_On
  alias: Turn on the bathroom lights when movement is detected
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: binary_sensor.bathroom_motion
      to: 'on'
  action:
    - service: scene.turn_on
      entity_id: scene.bathroom_on

# Front Porch Motion On
- id: Front_Porch_Motion_On
  alias: Turn on the front porch lights when movement is detected
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: binary_sensor.front_porch_motion
      to: 'on'
  action:
    - service: scene.turn_on
      entity_id: scene.front_porch_on
      
# Office Motion Stopped
- id: Office Motion Stopped
  alias: Office Motion Stopped
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: binary_sensor.office_porch_motion
      to: 'off'
      for:
        minutes: 1
  action:
    - service: scene.turn_on
      entity_id: scene.office_off
# Bathroom Stopped <--------- NOT WORKING
# - id: Bathroom Motion Stopped
  # alias: Bathroom Motion Stopped
  # initial_state: 'on'
  # trigger:
    # - platform: state
      # entity_id: binary_sensor.bathroom_porch_motion
      # to: 'off'
      # for:
        # minutes: 5
  # action:
    # - service: scene.turn_on
      # entity_id: scene.bathroom_off
      
# Bathroom Motion Stopped <--------- NOT WORKING :(
- id: Bathroom Motion Stopped
  alias: Bathroom Motion Stopped
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: binary_sensor.bathroom_motion
      to: 'off'
  condition:
    - condition: state
      entity_id: scene.bathroom_on
      state: 'on'
  action:
    - delay: '00:{{ states.input_slider.sensor_delay_bathroom.state | int }}:00'
    - service: scene.turn_on
      entity_id: scene.bathroom_off

# Front Porch Motion Stopped
- id: Front Porch Motion Stopped
  alias: Front Porch Motion Stopped
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: binary_sensor.front_porch_motion
      to: 'off'
      for:
        minutes: 1
  action:
    - service: scene.turn_on
      entity_id: scene.front_porch_off
# Shut off the music at 7:20AM
- id: Morning Shutdown 
  alias: Shut off bathroom chromecast each morning
  initial_state: 'on'
  hide_entity: false
  trigger:
    - platform: time
      at: '21:29:00'
  condition:
    - condition: time
      weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
  action:
    - service: media_player.turn_off
      entity_id: media_player.all_devices_group
#####################
# MORNING ROUTINE
#####################
# Start iHeartRadio in the morning
- id: Morning Startup
  alias: Turns on the chromecast and plays iHeartRadio in the bathroom each morning
  initial_state: 'on'
  hide_entity: false
  trigger:
    - platform: time
      at: '21:28:00'
  condition:
    - condition: time
      weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
  action:
    - service: media_player.play_media
      entity_id: media_player.all_devices_group
      data:
        media_content_id: http://kbpi-fm.akacast.akamaistream.net/7/535/19810/v1/auth.akacast.akamaistream.net/kbpi-fm
        media_content_type: audio/mp3
####################
# MEDIA PLAYING 
####################
# Fire TV Paused <------------- NOT WORKING
- id: FireTV_Paused
  alias: Media player paused/stopped
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: media_player.fire_tv
      from: 'playing'
      to: 'idle'
  condition:
    - condition: state
      entity_id: sun.sun
      state: below_horizon
  action:
    - service: scene.turn_on
      entity_id: scene.living_room_on
# Fire TV Playing  <------------- NOT WORKING
- id: Fire TV Playing
  alias: "Fire TV is playing"
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: media_player.fire_tv
      to: 'playing'
      from: 'idle'
  condition:
    - condition: state
      entity_id: sun.sun
      state: 'below_horizon'
  action:
    - service: scene.turn_on
      entity_id: scene.living_room_dim
###################################################
# BRIGHTNESS SLIDERS
###################################################
# All Lights Brightness Slider
- id: All Lights Brightness Slider
  alias: All Lights Brightness
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_slider.all_lights_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: group.all_lights
        brightness: '{{ states.input_slider.all_lights_light_brightness.state | int }}'
# Back Porch Brightness Slider - WORKING
- id: Back Porch Brightness Slider
  alias: Back Porch Brightness
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_slider.back_porch_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.back_porch
        brightness: '{{ states.input_slider.back_porch_light_brightness.state | int }}'
# Bathroom Brightness Slider - WORKING
- id: Bathroom Brightness Slider
  alias: Bathroom Brightness
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_slider.bathroom_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.bathroom
        brightness: '{{ states.input_slider.bathroom_light_brightness.state | int }}'
# Dining Room Brightness Slider - WORKING
- id: Dining Room Brightness Slider
  alias: Dining Room Brightness
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_slider.dining_room_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.dining_room
        brightness: '{{ states.input_slider.dining_room_light_brightness.state | int }}'
# Front Porch Brightness Slider - WORKING
- id: Front Porch Brightness Slider
  alias: Front Porch Brightness
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_slider.front_porch_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.front_porch
        brightness: '{{ states.input_slider.front_porch_light_brightness.state | int }}'
# Office Brightness Slider - WORKING
- id: Office Brightness Slider
  alias: Office Brightness
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_slider.office_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.office
        brightness: '{{ states.input_slider.office_light_brightness.state | int }}'
# Living Room Brightness Slider - WORKING
- id: Living Room Brightness Slider
  alias: Living Room Brightness
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_slider.living_room_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.living_room
        brightness: '{{ states.input_slider.living_room_light_brightness.state | int }}'
# Bedroom Brightness Slider - WORKING
- id: Bedroom Brightness Slider
  alias: Bedroom Brightness
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_slider.bedroom_light_brightness
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.bedroom_2
        brightness: '{{ states.input_slider.bedroom_light_brightness.state | int }}'
# Volume Adjust - Bathroom Chromecast (Part 1)
- id: Bathroom Chromecast Volume Slider
  alias: bathroom_chromecast_adjust_volume
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_slider.bathroom_chromecast_volume_slider
  action:
    - service: media_player.volume_set
      data_template:
        entity_id: media_player.bathroom
        volume_level: '{{ trigger.to_state.state }}'
# Volume Adjust - Bedroom Home (Part 1)
- id: Bedroom Home Volume Slider
  alias: bedroom_room_home_adjust_volume
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_slider.bedroom_home_volume_slider
  action:
    - service: media_player.volume_set
      data_template:
        entity_id: media_player.bedroom_home
        volume_level: '{{ trigger.to_state.state }}'
# Volume Adjust - Living Room Home (Part 1)
- id: Living Room Home Volume Slider
  alias: living_room_home_adjust_volume
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_slider.living_room_home_volume_slider
  action:
    - service: media_player.volume_set
      data_template:
        entity_id: media_player.living_room_home
        volume_level: '{{ trigger.to_state.state }}'
# Volume Adjust - Home Group (Part 1)
- id: All Google Homes Volume Slider
  alias: all_google_homes_adjust_volume
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_slider.all_google_homes_volume_slider
  action:
    - service: media_player.volume_set
      data_template:
        entity_id: media_player.home_group
        volume_level: '{{ trigger.to_state.state }}'
# Volume Adjust - All Devices Group (Part 1)
- id: All Devices Volume Slider
  alias: all_devices_adjust_volume
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_slider.all_devices_volume_slider
  action:
    - service: media_player.volume_set
      data_template:
        entity_id: media_player.all_devices_group
        volume_level: '{{ trigger.to_state.state }}'
# Volume Adjust - Living Room Home (Part 2)
- id: Bedroom Home Volume Slider part 2
  alias: Living Roome Volume Slider part 2
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: media_player.living_room_home
  action:
    - service: input_slider.select_value
      data_template:
        entity_id: input_slider.living_room_home_volume_slider
        value: '{{ states.media_player.living_room_home.attributes.volume_level }}'
# Volume Adjust - Bedroom Home (Part 2)
- id: Bedroom Home Volume Slider part 2
  alias: Bedroom Home Volume Slider part 2
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: media_player.bedroom_home
  action:
    - service: input_slider.select_value
      data_template:
        entity_id: input_slider.bedroom_home_volume_slider
        value: '{{ states.media_player.bedroom_home.attributes.volume_level }}'
# Volume Adjust - Home Group (Part 2)
- id: All Google Homes (Part 2)
  alias: All Google Homes (Part 2)
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: media_player.home_group
  action:
    - service: input_slider.select_value
      data_template:
        entity_id: input_slider.all_google_homes_volume_slider
        value: '{{ states.media_player.home_group.attributes.volume_level }}'
# Volume Adjust - All Devices Group (Part 2)
- id: All Devices Group Volume Slider (Part 2)
  alias: All Devices Group Volume Slider (Part 2)
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: media_player.all_devices_group
  action:
    - service: input_slider.select_value
      data_template:
        entity_id: input_slider.all_devices_volume_slider
        value: '{{ states.media_player.all_devices_group.attributes.volume_level }}'
# Volume Adjust - Bathroom Chromecast (Part 2)
- id: Bathroom Chromecast Volume (Part 2)
  alias: Bathroom Chromecast Volume (Part 2)
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: media_player.bathroom
  action:
    - service: input_slider.select_value
      data_template:
        entity_id: input_slider.bathroom_chromecast_volume_slider
        value: '{{ states.media_player.bathroom.attributes.volume_level }}'
####### TEST JOIN
# - id: Test Join
  # alias: Test Join
  # trigger:
    # platform: state
    # entity_id: input_boolean.activate_join
    # to: 'on'
  # action:
    # service: notify.join
    # data:
      # target:
        # - 'Phone'
      # title: Test Notification From Home Assistant
      # message: 'text/This is a test!!!'

Thanks!