Double Sunset Trigger

Hi I new to this, but have a PI Running HA and just getting to send an email at sunrise & sunset

All works ok but it always sends 2 emails at sunset 1 min apart, anyone know why

Re Dave (Code below)

automation:           
  - alias: 'Send notification when sun rises'
    hide_entity: False 
    trigger:
      platform: sun
      event: sunrise
      offset: '+00:00:01'
    action:
      service: notify.smtp_gmail
      data:
        title: 'PI Sender Sunrise'
        message: 'Sunrise'

  - alias: 'Send notification when sun sets'
    trigger:
      platform: sun
      event: sunset
      offset: '+00:00:01'
    action:
      service: notify.smtp_gmail
      data:
        title: 'PI Sender Sunset'
        message: 'Sunset'

Are you located on Tatooine?

11 Likes

Has done it again tonight, that is every night this week, but sunrise is ok, 1 min apart

Any thoughts?

Anything I could try?

Re Dave

I don’t see why it would be sending a duplicate but I believe offset is optional. Looks like you’re setting it for one second. Try removing it to see if that works for you.

Do you have any errors in your log?

I know you’re receiving the email twice, but have you check the logbook to see if the automation is triggering twice, or if a single trigger is somehow sending the email twice?

Hi, thanks for the reply, I had not known abut log book (still learning)

Here is today’s

Looks like its triggered twice.

8:00 PM
Yr Symbol changed to 1
4:27 PM
Sun has set
4:27 PM
Send Notification When Sun Sets has been triggered
4:26 PM
Send Notification When Sun Sets has been triggered
3:00 PM
Yr Symbol changed to 3
2:12 PM
OpenWeatherMap changed to sunny
1:41 PM
OpenWeatherMap changed to cloudy
1:10 PM
OpenWeatherMap changed to sunny
12:40 PM
OpenWeatherMap changed to cloudy
12:19 PM
OpenWeatherMap changed to sunny
10:16 AM
OpenWeatherMap changed to exceptional
9:00 AM
Yr Symbol changed to 1
8:15 AM
Yr Symbol changed to 2
7:59 AM
Send Notification When Sun Rises has been triggered
7:58 AM
Sun has risen
12:45 AM
Update Available changed to 0.36.1

I originally had the offset set to 00:00:00, I then added the 01 as a test. I have changed it to 00:10:00 to see what happens tomorrow

Re Dave

The offset is plus or minus the event. So in this case 00:10:00 would be ten minutes after sunset. If you want the email right at sunset you can remove this or leave it at zeros.

For example this is my automation section: The Auto Night turns on my living room lights an hour and a half before sunset and my bedroom fan turns on at 12:30am and turns off at different times of the week. I need to remove the christmas lights turning on at sunset. :slight_smile:

(ignore spacing here)

automation:

  • alias: Auto Night
    trigger:
    platform: sun
    event: sunset
    offset: “-01:30:00”
    action:
    service: homeassistant.turn_on
    entity_id: group.night_time

  • alias: Bedroom Fan On
    trigger:
    platform: time
    after: ‘00:30:00’
    action:
    service: homeassistant.turn_on
    entity_id: switch.bedroom_fan

  • alias: weekday Bedroom Fan Off
    trigger:
    platform: time
    after: ‘08:30:00’
    condition:
    condition: time
    weekday:
    - mon
    - tue
    - thu
    - fri
    action:
    service: homeassistant.turn_off
    entity_id: switch.bedroom_fan

  • alias: wed Bedroom Fan Off
    trigger:
    platform: time
    after: ‘06:45:00’
    condition:
    condition: time
    weekday:
    - wed
    action:
    service: homeassistant.turn_off
    entity_id: switch.bedroom_fan

  • alias: weekend Bedroom Fan Off
    trigger:
    platform: time
    after: ‘9:30:00’
    condition:
    condition: time
    weekday:
    - sat
    - sun
    action:
    service: homeassistant.turn_off
    entity_id: switch.bedroom_fan

  • alias: AutoAquarium on
    trigger:
    platform: time
    after: ‘09:55:00’
    action:
    service: homeassistant.turn_on
    entity_id: switch.waffles

  • alias: AutoAquarium off
    trigger:
    platform: time
    after: ‘21:55:00’
    action:
    service: homeassistant.turn_off
    entity_id: switch.waffles

  • alias: Auto Christmas
    trigger:
    platform: sun
    event: sunset
    action:
    service: homeassistant.turn_on
    entity_id: group.christmas

Have you looked through your configuration to make sure you don’t have this automation listed twice? Also try making your alias names a single word without quotes to see if that is it.

I’m getting this as well, and only have the automation listed once. The first evening it only triggered once, but has triggered twice every night since, verified in the log. The sunrise is only happening once though.

automation:
  - alias: "wake up the sun's up"
    trigger:
      platform: sun
      event: sunrise
    action:
      service: notify.bot
      data:
        message: "The sun has risen."
  - alias: "sun is going down soon"
    trigger:
      platform: sun
      event: sunset
      offset: "-00:30:00"
    condition:
        condition: time
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
    action:
      service: notify.bot
      data:
        message: "The sun is going to set in 30 minutes."

I am still getting them, but not every day, I have an email sent at Sunrise and that works with Zero double sends.

But the Sunset is different.

Below is a screen dump of my inbox for sunsets, can anybody work out a pattern. The ones in Bold are the double sunsets

Re Dave

I feel like this might be a bug. I am also getting this error.
Some evening it gets triggered twice.

My automation:

- alias: Evening lighting on
  trigger:
    platform: sun
    event: sunset
  action:
    - service: homeassistant.turn_on
      entity_id:
        - group.frontyard_lights
        - group.backyard_lights
    - service: notify.pushbullet
      data:
        message: "God kväll, tänder utomhusbelysningen."
        target: "channel/xxx"
    - condition: state
      entity_id: alarm_control_panel.alarm_1
      state: disarmed
    - service: script.turn_on
      entity_id: script.say
      data:
        variables:
          where: 'kitchen'
          what: 'Tänder utomhusbelysningen.'

Double sunset, Tue, Wed, Thu, this week always 1 or 2 mins apart?

Re Dave

I get this consistently also. I have a pushover notification to let me know when the sun sets, and I get duplicate push notifications every evening. Quite annoying actually to always have to clear 2 notifications . . .

My automation is simply:

 #Living Room Lights Automations
 - alias: Turn on Living Room Lights at Sunset
   hide_entity: True
   trigger:
     platform: sun
     event: 'sunset'
     offset: '-00:15:00'
   action:
     - service: homeassistant.turn_on
       entity_id: group.living_room_lights
     - service: notify.pushover
       data:
         message: Sun is setting at Home, now turning on Living Room lights!

Yes this is getting annoying, is it a bug? Do we need to report it somewhere?

1 Like

I have now reported it on the github

Re Dave

4 Likes