0115.0/0.115.1/0.115.2 SUN no longer allowed as a TRIGGER in Automations?

Try this: Set up any new Automation. Try and use Sun as a trigger (sunrise or sunset) and you get this

Error and unable to save the new Automation:

Integration 'sun' does not provide trigger support

All my Automations that use Sunrise/Sunset are Dead in the water (I have several).

Verified on 0.115.0/.155.1/.115.2

ANY other HA version I’ve used in the past year works fine with Sun as a trigger.

Anyone else seeing this Glaring ERROR?

I do have this in my configuration.yaml (and nothing else in my sensor.yaml file)

sun:
  monitored_conditions:
    - elevation
    - daylight
    - next_daylight
    - prev_daylight
    - sunrise
    - sunset
  scan_interval:
    minutes: 1440 #24 hours

WTH is finished
Suggest log a github issue

It’s not a suggestion. It was a statement.

Anyone else able to confirm this behavior?

And if its an issue, log it in the correct place - Github

I’m not into wasting my or the dev’s time.

IS ANYONE able to confirm this “feature?”

I could not reproduce the reported behavior given the following:

Home Assistant OS 0.115.0 on RPi3.
Using default_config which includes the sun integration.
Creating the automation via the UI.
Using a Sun Trigger at sunrise.

Resulting automation was saved without complaint. No errors or warnings in the log.

EDIT

Your configuration for the Sun integration is very different from what’s shown in the documentation:

Good catch. I’m deleting everything except sun: and I’ll try the update again. Not sure where those params came from but I’ve had them in there since at least 0.90.

Edit:
Nope. Same errors. Turns out I’m not alone - I see several others have reported this behavior In other posts. At this point it appears worthy of a PR.

Logger: homeassistant.config
Source: config.py:413 
First occurred: 9:00:55 PM (3 occurrences) 
Last logged: 9:00:56 PM

Invalid config for [automation]: Integration 'sun' does not provide trigger support. Got OrderedDict([('default_config', {}), ('config', {}), ('automation', [OrderedDict([('id', '1567839864112'), ('alias', 'Water on if hotter than 80'), ('trigger', [OrderedDict([('minutes', '/30'), ('platform', 'time_pattern')])]), ('condition', [OrderedDict([('above', '85'), ('condition', 'numeric_state'), ('entity_id', 'sensor.santa_rosa_temperature')]), OrderedDict([('after', 'sunrise'), ('before', 'sunset'), ('condition', 'sun')])]), ('action', [OrderedDict([('entity_id', 'switch.coop_water').... (See /config/configuration.yaml, line 2).

PR logged:

I suggest you try to identify why it fails on your system but doesn’t on mine (which is a vanilla installation of Home Assistant OS). Ideally you want to explain to the devs how to reproduce the error. Otherwise you may get a ‘cannot reproduce it’ response and the Issue is either left open until you can provide more data or simply closed because no progress can be made.

1 Like

I have this.

sun:

My automations that use Sun are mostly as follows, or very similar, and all work.

# SUNSET - STEPS & TABLE #
- alias: Sunset - Steps & Table
  initial_state: true
  trigger:
    platform: template
    value_template: '{{ state_attr("sun.sun", "elevation") < 8 }}'
  condition:
    condition: state
    entity_id: group.family
    state: 'not_home'
  action:
    - service: script.turn_on
      entity_id: script.white_lights

If you want Sunset, change the elevation to < 0.

I turned mine into sensors with a input slider to adjust offset, then used the sensor as a trigger.

sensor:
- platform: template
  sensors: 
    auto_pump_start_night: 
      friendly_name: "Night time pump on at"
      value_template: >-
        {{ (as_timestamp(states.sun.sun.attributes.next_setting) + 
        (states('input_number.auto_start_offset_night') | int) * 60 * 60) | 
        timestamp_custom("%H:%M") }}
      icon_template: mdi:progress-clock
    auto_pump_stop_night:
      friendly_name: "Night time pump off at"
      value_template: >-
        {{ (as_timestamp(states.sun.sun.attributes.next_setting) + 
        (states('input_number.auto_start_offset_night') | int) * 60 * 60 + 
        (states("input_number.run_pool_pump_night") | float) * 60 * 60) | 
        timestamp_custom("%H:%M") }} 
      icon_template: mdi:clock-outline
    auto_pump_start_day: 
      friendly_name: "Day time pump on at"
      value_template: >-
        {{ (as_timestamp(states.sun.sun.attributes.next_rising) + 
        (states('input_number.auto_start_offset_day') | int) * 60 * 60) | 
        timestamp_custom("%H:%M") }}
      icon_template: mdi:progress-clock
    auto_pump_stop_day:
      friendly_name: "Day time pump off at"
      value_template: >-
        {{ (as_timestamp(states.sun.sun.attributes.next_rising) + 
        (states('input_number.auto_start_offset_day') | int) * 60 * 60 + 
        (states("input_number.run_pool_pump_day") | float) * 60 * 60) | 
        timestamp_custom("%H:%M") }} 
      icon_template: mdi:clock-outline

Inputs

input_number:
  auto_start_offset_night:
    icon: mdi:timer-sand
    max: 4.0
    min: 0.0
    mode: slider
    name: Night start offset
    step: 1.0
    unit_of_measurement: Hours

  auto_start_offset_day:
    icon: mdi:timer-sand
    max: 8.0
    min: 0.0
    mode: slider
    name: Day start offset
    step: 1.0
    unit_of_measurement: Hours

  run_pool_pump_night:
    icon: mdi:timer-outline
    max: 10.0
    min: 0.0
    mode: slider
    name: Pool pump night
    step: 1.0
    unit_of_measurement: Hours

  run_pool_pump_day:
    icon: mdi:timer-outline
    max: 7.0
    min: 0.0
    mode: slider
    name: Pool pump day
    step: 1.0
    unit_of_measurement: Hours

input_select:
  pool_pump_mode:
    icon: mdi:car-turbocharger
    name: Pool pump mode
    options:
      - "Auto"
      - "Maintenance"

Automations

automation:
- alias: Automated pool pump night
  trigger:
  - platform: template
    value_template: >-
      {{ states.sensor.time.state == states('sensor.auto_pump_start_night') }}
  condition:
  - condition: state
    entity_id: input_boolean.swim_season
    state: 'on'
  - condition: state
    entity_id: input_select.pool_pump_mode
    state: 'Auto'
  action:
  - service: script.pool_pump_on
  - delay: "{{states('input_number.run_pool_pump_night') | int }}:00:00"
  - service: script.pool_pump_off

- alias: Automated pool pump day
  trigger:
  - platform: template
    value_template: >-
      {{ states.sensor.time.state == states('sensor.auto_pump_start_day') }}
  condition:
  - condition: state
    entity_id: input_boolean.swim_season
    state: 'on'
  - condition: state
    entity_id: input_select.pool_pump_mode
    state: 'Auto'
  action:
  - service: script.pool_pump_on
  - delay: "{{states('input_number.run_pool_pump_day') | int }}:00:00"
  - service: script.pool_pump_off

You don’t happen to be using a custom sun component do you?

No custom component. I went super simple and only have this in configuration.yaml

sun:

I’m trying to figure that out… that’s why I simplified everything and went to a totally basic config. Even creating a new automation from scratch throws the error and is not able to be saved.

I’m open to trying other things. I thought there was a different sun integration/platform out there. - I might try that next.

Jeff

Unless it’s the official Sun integration, the devs won’t debug a custom Sun integration.

if vanilla doesn’t work muddying the waters with custom won’t help anyone, including the people trying to help you

@123 Snap !

1 Like

Yeah, but I’m stuck until this gets sorted. I just looked in my custom_components Dir and there was a /sun directory there dated back to early 2019. Not sure why as ‘sun’ is part of core. So I deleted that Dir and the files inside it and am trying the ug again.

EDIT: deleting that directory and files seemed to fix it. Holy crapola… what a time suck. I honestly have no idea where that dir $files came from. In the early days when I knew very little about home assistant, it’s possible I copies something from someone else. Interesting how this manifested itself.

Sorry for the fire drill here. I’ll close the PR.

Jeff

2 Likes

Have you tried changing your automations to use a template as suggested above?

I am not having trouble with my presunset automations in 0.115.2. As an example, I have in the configuration.yaml:

sun:

In my automation.yaml I have this entry:

- id: '1536785128868'
  alias: Turn on Lights in the Evening
  trigger:
  - event: sunset
    offset: -01:00:00
    platform: sun
  condition: []
  action:
  - data:
      entity_id: scene.all_evening
    service: scene.turn_on
  - entity_id: switch.outside_plugs_one
    service: switch.turn_on

Solved. See above.