Raise shutters at sunrise, but not when I am home, and no earlier than 7am

This is what I came up with but I’m not sure if that’s correct? Sometimes it doesn’t trigger, I’m not sure what’s going on?

triggers:
  - trigger: sun
    event: sunrise
    offset: 0
  - trigger: time
    at: "07:00:00"
conditions:
  - condition: not
    conditions:
      - condition: zone
        entity_id: device_tracker.pixel_david
        zone: zone.home
  - condition: time
    after: "07:00:00"
actions:
  - device_id: 2d4bd745d39bda0ee671ca3a2241c683
    domain: cover
    entity_id: f57d7da60ed01a2794c4ca0d6e71f742
    type: set_position
    position: 100
mode: single

Please follow Question Guideline #11 and format your configuration properly.

fixed the formatting.

Regarding the triggers, the only thing that looks abnormal is the offset. Normally a Time trigger with 0 seconds offset will look like:

trigger: sun
event: sunset
offset: "0"
Other acceptable versions
trigger: sun
event: sunset
offset: "00:00:00"
trigger: sun
event: sunset

The conditions look fine, with a couple minor points. The main issue is whether you want the later or earlier trigger, as long it’s after 7am. The way it is currently configured the shutters will open on the earlier of the two triggers, as long it’s after 7am.

If you want the later of the two triggers, you need to add a Sun condition. That way, the 7am trigger won’t cause the shades to open if sunrise is after 7am.

Sun condition
  - condition: sun
    after: sunrise
  • It may be better in the long run to use the state of your person entity rather than a Zone condition based on a single device tracker. It is pretty common to need multiple trackers for a single person to get reliable presence detection.
Person-based condition
conditions:
  - condition: not
    conditions:
      - condition: state
        entity_id: person.david
        state: home

Thanks for the suggestions, friend.

Hi davc,

If you get that trigger, then it probably will never pass this condition:

Do you get sunrises after 7:00 local?
I guess it’s possible…

SG, you get sunrises after 7am in WI from about Oct 9th until the time changes… and for about a week in March after DST starts. :slight_smile:

Places closer to the equator that also observe DST (like Key West or Miami) have about 50% of their sunrises after 7am.

First thing I’m not sure about is if the trigger at 7 is considered after 7, but I guess not. so I’d put in after 6:59.

But then, if sunrise is before 7, it will be blocked by the condition. If sunrise is after 7, then the trigger would already have happened at 7 and executed. So why bother trigger at sunrise again? So I guess, if the trigger is 7 and sun has not rose, you should block too? You only want the trigger at 7 to work if the sun is already up.

If you want two conditions to be true, you need both as a trigger and as a condition. See this post, from: my automation does not always work.

I didn’t like that at 7:00:00 and condition after 7:00:00 either, as it might be a point of uncertainty.
I suggest…

At sunrise, if David is not home, change the cover and eliminate the (uncertainty)...

sunrise in winter here is about 8am :slight_smile:

triggers:
  - trigger: sun
    event: sunrise
  - trigger: time
    at: "07:00:00"
conditions:
  - condition: not
    conditions:
      - condition: state
        entity_id: person.david
        state: home
  - condition: time
    after: "06:59:00"
  - condition: sun
    after: sunrise
actions:
  - device_id: 2d4bd745d39bda0ee671ca3a2241c683
    domain: cover
    entity_id: f57d7da60ed01a2794c4ca0d6e71f742
    type: set_position
    position: 100
mode: single

This is what I am using, it worked today

3 Likes