Help with configuration: timers and the sun

I am trying to figure out why my HA isn’t reacting to my config files the way I expect.

I’ve got two things going one:

a) a Fan that should run for 2 minutes when a particular light is triggered (example from Motion detected -> lights on. no motion within 10mins, turn lights off )

  • However, although the code does turn the fan on when I turn on the light, I don’t think the timer (defined in configuration.yaml) is ever activated, or at least, the fan doesn’t turn off as expected.

b) lights that should come on at bedtime don’t come on. For some reason, nothing seems to happen.

I am coming from Vera, and find the HA config a little steep to learn.

Thanks for any help!


Here is my automation.yaml

- id: bedtime_m_f
  alias: ‘Turn off lights at bedtime M-F’
  trigger:
    platform: time
    at: '22:00:00'
  condition:
   - condition: time
     weekday:
        - sun
        - mon
        - tue
        - wed
        - thu
  action:
    service: light.turn_off
    entity_id: group.g_outdoor_lights
- id: bedtime_weekend
  alias: ‘Turn off lights at bedtime - weekend’
  trigger:
    platform: time
    at: '23:00:00'
  condition:
   - condition: time
     weekday:
        - fri
        - sat
  action:
    service: light.turn_off
    entity_id: group.g_outdoor_lights
- id: family_lamp_at_dusk
  alias: ‘Family Room Lamp when the sun starts to dim’
  trigger:
    platform: numeric_state
    entity_id: sun.sun
    value_template: '{{ state.attributes.elevation }}'
    below: 6
  action:
    service: light.turn_on
    entity_id: group.g_outdoor_lights
- id: outdoor_lights_at_dusk
  alias: ‘Outdoor lights on when the sun starts to dim’
  trigger:
    platform: numeric_state
    entity_id: sun.sun
    value_template: '{{ state.attributes.elevation }}'
    below: 3.5
  action:
    service: light.turn_on
    entity_id: group.g_outdoor_lights
## sensor.alarm_display - When switch.g_counter_fl turns on, turn on G-fan for 2 minutes
- id: g_fan_automation_on
  alias: 'Fan on if counter lights on'
  trigger:
    platform: state
    entity_id: switch.switch_8
    to: 'on'
  action:
    service: timer.start
    entity_id: timer.timer_g_fan
    service: switch.turn_on
    entity_id: switch.switch_9   
- id: g_fan_automation_off        
  alias: 'Turn off lights at end of timer'
  trigger:
    platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.timer_g_fan
  action:
      service: switch.turn_off
      entity_id: switch.switch_9

and my configuration.yaml
homeassistant:
# Name of the location where Home Assistant is running
name: 638
# Location required to calculate the time the sun rises and sets
latitude: 47.7396
longitude: -122.3426
# Impacts weather/sunrise data (altitude above sea level in meters)
elevation: 129
# metric for Metric, imperial for Imperial
unit_system: imperial
# Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
time_zone: America/Los_Angeles
# Customization file
customize: !include customize.yaml
# Show links to resources in log and frontend
introduction:
# Enables the frontend
frontend:
# Enables configuration UI
config:
http:
# Secrets are defined in the file secrets.yaml
# api_password: !secret http_password
# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# base_url: example.duckdns.org:8123
# Checks for available updates
# Note: This component will send some information about your system to
# the developers to assist with development of Home Assistant.
# For more information, please see:
# https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
updater:
# Optional, allows Home Assistant developers to focus on popular components.
# include_used_components: true
# Discover some devices automatically
discovery:
# Allows you to issue voice commands from the frontend in enabled browsers
conversation:
# Enables support for tracking state changes over time
history:
# View all events in a logbook
logbook:

# Enables a map showing the location of tracked devices
map:

# Track the sun
sun:

# Weather prediction
sensor:
  - platform: yr
  - platform: command_line
    name: cpu_temp
    command: "cat /sys/class/thermal/thermal_zone0/temp"
    # If errors occur, remove degree symbol below
    unit_of_measurement: "°C"
    value_template: '{{ value | multiply(0.001) | round(1) }}'


# Text to speech
tts:
  - platform: google

# Cloud
cloud:

ios:


zwave:
 usb_path: /dev/ttyACM0
 network_key: "0x08, 0x06, 0x03, 0x04, 0x05, 0x06, 0x07, 0x02, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10"

alarmdecoder: ## !include alarm_decoder.yaml
  device:
    type: usb
    ##baudrate: 115200
    ##usb_path: /dev/ttyUSB0
  panel_display: On
  zones:
    01:
      name: 'Smoke Detector'
      type: 'smoke'
      rfid: '0123456'
    02:
      name: 'Front Door'
      type: 'opening'
      

timer:
  timer_g_fan:
    duration: '00:02:00'        

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
sensor: !include sensors.yaml

panel_iframe:
  configurator:
    title: Config-internal
    icon: mdi:wrench
    url: http://192.168.7.218:3218

Why are you using the timer that way? Why not just add a delay in the automation and remove the second automation?

- id: g_fan_automation_on
  alias: 'Fan on if counter lights on'
  trigger:
    platform: state
    entity_id: switch.switch_8
    to: 'on'
  action:
    - service: switch.turn_on
      entity_id: switch.switch_9   
    - delay:
        minutes: 2
    - service: switch.turn_off
        entity_id: switch.switch_9

Anyways, the issue with your automation is because you don’t specify your services as a list of services so it just uses the last in service, which happens to be the switch.turn_on. So your timer is completely overlooked. To fix that, add a minus sign for each service in your action:

- id: g_fan_automation_on
  alias: 'Fan on if counter lights on'
  trigger:
    platform: state
    entity_id: switch.switch_8
    to: 'on'
  action:
    - service: timer.start
      entity_id: timer.timer_g_fan
    - service: switch.turn_on
      entity_id: switch.switch_9 

As for your second issue, i don’t actually see an automation to turn lights on at bedtime, you only have automations to turn off lights at bedtime. I think your problem there is that you don’t have the automation!

Thanks, Petro. I’ve got some coding experience (in the wayback), and a ton of home automation config experience on a variety of platforms, but I’m finding HA config a bear.

I’ve made numerous edits to the config and automation, but something is obviously not right.

I get a warning that there is a problem with automations, but can’t seem to figure out where to begin to solve it.

When I click on General -> Check configuration, it goes to color circles, indefinitely.

Can anyone help with a pointer on what’s wrong with my automations, or perhaps what I need to do to get the config checker working?

- id: bedtime_m_f
  alias: ‘Turn off lights at bedtime M-F’
  trigger:
    - platform: time
      at: '22:00:00'
  condition:
   - condition: time
     weekday:
        - sun
        - mon
        - tue
        - wed
        - thu
  action:
    - service: homeassistant.turn_off
      entity_id: group.outdoor_lights

- id: bedtime_weekend
  alias: ‘Turn off lights at bedtime - weekend’
  trigger:
    - platform: time
      at: '23:00:00'
  condition:
   - condition: time
     weekday:
        - fri
        - sat
  action:
    - service: homeassistant.turn_off
      entity_id: group.outdoor_lights

- id: family_lamp_at_dusk
  alias: ‘Family Room Lamp at dusk’
  trigger:
    - platform: numeric_state
      entity_id: sun.sun
      value_template: '{{ state.attributes.elevation }}'
      below: 6
  action:
    - service: homeassistant.turn_on
      entity_id: light.family_room

- id: outdoor_lights_at_dusk
  alias: ‘Outdoor lights on at dusk’
  trigger:
    - platform: numeric_state
      entity_id: sun.sun
      value_template: '{{ state.attributes.elevation }}'
      below: 3.5
  action:
    - service: homeassistant.turn_on
      entity_id: group.g_outdoor_lights
    
## sensor.alarm_display - When switch.g_counter_fl turns on, turn on G-fan for 10 minutes
- id: g_fan_automation_on
  alias: 'Fan on if counter lights on'
  trigger:
    - platform: state
      entity_id: switch.switch_8
      to: 'on'
  action:
    - service: homeassistant.turn_on
      entity_id: switch.switch_9   
    - delay:
        minutes: 2
    - service: homeassistant.turn_off
      entity_id: switch.switch_9
        
- id: g_fan_automation_off        
  alias: 'Turn off lights at end of timer'
  trigger:
    - platform: event
      event_type: timer.finished
      event_data:
      entity_id: timer.timer_g_fan
  action:
    - service: homeassistant.turn_off
      entity_id: switch.switch_9

Sorry didn’t see your post til now.

  1. Not sure if this is a copy/paste issue but you are using ‘’ instead of the code friendly characters '.

The formatting on that trigger is wrong. you need to put indents for the entity id because it is part of the data.

  trigger:
    - platform: event
      event_type: timer.finished
      event_data:
        entity_id: timer.timer_g_fan