Having sun rise/set & time issues. Can't pinpoint what is wrong

Can someone help me pinpoint what’s wrong with my setup? I currently am trying to get my cabinet lights on a schedule and can’t seem to.

It’s a pain to test since it’s based on sun & time.

Few notes:

  1. The weekday (WD) AM ones work.
  2. All work when manually triggering from web ui.
  3. Logbook shows them all working correctly, but lights are not on when they should be.
  4. Can these all be combined into one file?

#My Setup

configuration.yaml

...
automation: !include automation.yaml
...

automation.yaml

...
- !include automation/KTCN_Cabinet-Lights_PM_ON.yaml
- !include automation/KTCN_Cabinet-Lights_PM_OFF.yaml
- !include automation/KTCN_Cabinet-Lights_AM_WD_ON.yaml
- !include automation/KTCN_Cabinet-Lights_AM_WD_OFF.yaml
- !include automation/KTCN_Cabinet-Lights_AM_WE_OFF.yaml
- !include automation/KTCN_Cabinet-Lights_AM_WE_ON.yaml
...

KTCN_Cabinet-Lights_AM_WD_OFF.yaml

  alias: "KTCN - Cabinet Lights - Weekday - OFF - 7:30AM"
  trigger:
    platform: time
    after: "07:30:00"
  condition:
  - condition: time
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
  action:
    service: switch.turn_off
    entity_id: switch.rf_outlet_5 

KTCN_Cabinet-Lights_AM_WD_ON.yaml

  alias: "KTCN - Cabinet Lights - Weekday - ON - 6AM"
  trigger:
    platform: time
    after: "06:00:00"
  condition:
  - condition: time
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
  action:
    service: switch.turn_on
    entity_id: switch.rf_outlet_5 

KTCN_Cabinet-Lights_AM_WE_OFF.yaml

  alias: "KTCN - Cabinet Lights - Weekend - OFF - Sunrise +1:15hr"
  trigger:
    platform: sun
    event: sunrise
    offset: "+01:15:00"
  condition:
  - condition: time
    weekday:
      - sat
      - sun
  action:
    service: switch.turn_off
    entity_id: switch.rf_outlet_5

KTCN_Cabinet-Lights_AM_WE_ON.yaml

  alias: "KTCN - Cabinet Lights - Weekend - ON - Sunrise -1:15hr"
  trigger:
    platform: sun
    event: sunrise
    offset: "-01:15:00"
  condition:
  - condition: time
    weekday:
      - sat
      - sun
  action:
    service: switch.turn_on
    entity_id: switch.rf_outlet_5    

KTCN_Cabinet-Lights_PM_OFF.yaml

  alias: "KTCN - Cabinet Lights - Every Day - OFF - 11PM"
  trigger:
    platform: time
    after: "23:00"
  action:
    service: switch.turn_off
    entity_id: switch.rf_outlet_5

KTCN_Cabinet-Lights_PM_ON.yaml

  alias: "KTCN - Cabinet Lights - Every Day - ON - Sunset -1hr"
  trigger:
    platform: sun
    event: sunset
    offset: "-01:00:00"
  action:
    service: switch.turn_on
    entity_id: switch.rf_outlet_5

Thanks in advance

Couple things that might help troubleshoot:

  • if you look at your states dev tool and view one of the “problem” automations, do you see a “last_triggered” value? If yes, then we can assume that the issue is downstream (a prob with the condition or with the action itself) (I think the answer here is “yes” based on your note #3)
  • are you restarting your HA instance during the testing? I usually find that my 3-hours-after-sunrise automations don’t execute if I’ve restarted HA after sunrise.
  • You can totally combine those. I keep all of my automations in a single file. Just keep in mind that under “automations:”, you need a list (keep the dash that’s before your include statement and put it before the alias of each automation.
1 Like

Interesting… last triggered is null on a few, specifically:

  • KTCN - Cabinet Lights - Every Day - ON - Sunset -1hr
  • KTCN - Cabinet Lights - Weekend - OFF - Sunrise +1:15hr
  • KTCN - Cabinet Lights - Weekend - ON - Sunrise -1:15hr

Which makes sense for what I’m seeing. Nothing happens on the weekends, and they don’t turn on at night.

They are my 3 based on sunset / rise… So I must have something wrong with my config for them. Could it be the double quotes that are on the offsets? I guess I’ll give that a try.

Thanks btw

So that means it’s a problem with the trigger.

I have double-quotes around my time offsets, too, so I don’t think that’s the issue.

If you check your home-assistant.log, do you see any issues setting up the sun platform? You do have

sun:

in your config YAML, right? Without that, you won’t have the sun platform at all.

1 Like

I do.

I was so hoping that I was dumb enough to miss that. Damn. haha.

log errors?

Also - you’ve got your lat/long set correctly in your config?

1 Like

lat/long are setup.

and i do have log errors… but I’m not sure they are related. http://text-share.com/view/8a9a10e2 If I recall correctly, they are something that will be fixed when I update. (Currently on 0.35.3)

I could be wrong - if an automation fails by it’s condition clause, I wonder if that prevents last_triggered from being valued.

I’m not sure you’ve got your formatting right on your conditions. But you’re not seeing any errors on startup…

In my automations, I have the block below condition: indented. Here’s a working automation that I have:

- alias: Shut down everything at one am
  trigger:
    - platform: time
      after: '1:00'
  condition:
    - condition: state
      entity_id: binary_sensor.vizio_tv_ping_sensor
      state: 'off'
  action:
    ...
1 Like

You might be right but I know this automation works… and it follows the same format as the others.

  alias: "KTCN - Cabinet Lights - Weekday - ON - 6AM"
  trigger:
    platform: time
    after: "06:00:00"
  condition:
  - condition: time
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
  action:
    service: switch.turn_on
    entity_id: switch.rf_outlet_5 

It’s probably an errant space or something like that, but then again, those usually throw errors on restart, right?

Thanks for sticking it out with me and throwing suggestions my way. Super helpful