Automation based on sensor.dark_sky_summary is broken

Hi,

Can someone please take a look at the config below tell me what i’m missing. Trying to setup an automation for when i’m working in the morning and it’s cloudy/overcast outside to turn on the living room lights.

Not sure if case sensitivity is issue but, I noticed when i check the state of ‘sensor.dark_sky_summary’ I get ‘Overcast’ not ‘overcast’. But either way it doesn’t seam to work. Any help is appreciated. Thanks.

- id: '000000000009'
  alias: Work in the morning
  trigger:
  - entity_id: sensor.dark_sky_summary
    platform: state
    to: overcast
  condition:
  - condition: state
    entity_id: device_tracker.macbookpro
    state: home
  - after: 07:00:00
    before: '10:00:00'
    condition: time
  action:
  - entity_id: group.living_room
    service: light.turn_on

One more thing. Also noticed the single quotes around 7am keep getting removed. Not sure if that helps but i keep seeing it happen.

The only way the automation will trigger is if:

  • You are home.
  • Current time is between 7:00 and 10:00
  • The sensor’s state changes from something other than overcast to overcast (during the time range).

Your automation will be triggered the moment sensor.dark_sky_summary changes state (to Overcast or overcast, whichever is the correct one). In other words, if the sensor’s state is overcast prior to 7:00, and remains that way throughout the time range, the automation will not trigger.

I got what you’re saying. What would be a better approach to this?

Just add another trigger and condition. Make the automation trigger at 7:00 and the condition check if the sensor’s state is currently overcast (I’ll let you determine if the correct state is overcast or Overcast). This handles the situation where the sensor is already reporting overcast when the time range begins.

- id: '000000000009'
  alias: Work in the morning
  trigger:
  - platform: state
    entity_id: sensor.dark_sky_summary
    to: overcast
  - platform: time
    at: '07:00:00'
  condition:
  - condition: state
    entity_id: device_tracker.macbookpro
    state: home
  - condition: time
    after: '07:00:00'
    before: '10:00:00'
  - condition: state
    entity_id: sensor.dark_sky_summary
    state: overcast
  action:
  - entity_id: group.living_room
    service: light.turn_on
1 Like

I appreciate the help i’ll give that a shot and let you know.

That worked more importantly i really appreciate the explanation. Thanks!

1 Like

Glad to hear it works now.

Please mark my previous post with the Solution tag. Only you, the author of this topic, can do that. It will automatically place a check-mark next to the topic’s title. This signals to others, who may have a similar question, that this topic has an accepted solution. It will also automatically place a link under your first post that leads to the Solution.

Hi is there a way to do multiple triggers?

Yes. The automation posted above demonstrates how to do that (it contains two triggers).

Right so I’m currently using the automation listed above but i would like to make some additions. Below is what i have so far that’s not working so far:

- id: '000000000006'
  alias: Morning routine2
  trigger:
  - entity_id: weather.home
    platform: state
    to: cloudy
  - entity_id: weather.home
    platform: state
    to: rainy
  - entity_id: weather.home
    platform: state
    to: partlycloudy
  - at: '12:30:00'
    platform: time
  condition:
  - condition: state
    entity_id: device_tracker.macbookpro
    state: home
  - after: '12:30:00'
    before: '13:00:00'
    condition: time
  - condition: state
    entity_id: weather.home
    state: cloudy
  - condition: state
    entity_id: weather.home
    state:  rainy
  - condition: state
    entity_id: weather.home
    state: partlycloudy
  action:
  - entity_id: group.living_room
    service: light.turn_on

Can i please get some help

Multiple triggers are logically ORed. That means the first trigger OR the second trigger OR the third trigger, etc can trigger the automation.

Multiple conditions are (by default) logically ANDed. That means the first condition AND the second condition AND the third condition, etc must all evaluate to True in order for the automation to execute the action.

That means the condition you’ve created will never evaluate to True because it demands the impossible combination of the weather sensor being simultaneously cloudy, rainy, and partlycloudy. Clearly, those three conditions should not be logically ANDed but logically ORed.

You will need Mixed AND and OR conditions. Have at look at the linked example and try your hand at adapting it for your needs. Let me know if you need assistance.

So this is what i have so far:

- id: '000000000006'
  alias: Morning routine2
  trigger:
  - entity_id: weather.home
    platform: state
    to: cloudy
  - entity_id: weather.home
    platform: state
    to: rainy
  - entity_id: weather.home
    platform: state
    to: partlycloudy
  - at: '12:30:00'
    platform: time
  condition:
  - condition: state
    entity_id: device_tracker.macbookpro
    state: home
  - after: '12:30:00'
    before: '13:00:00'
    condition: time
  - condition: and
    conditions:
    - condition: state
      entity_id: weather.home
      state: cloudy
  - condition: or
    conditions:
    - condition: state
      entity_id: weather.home
      state: rainy
  - condition: or
    conditions:
    - condition: state
      entity_id: weather.home
      state: partlycloudy
  action:
  - entity_id: group.living_room_lamps
    service: light.turn_on

Look at the documentation’s example again.

Hint:

condition: or only needs to be specified once at the start of all the conditions that will be ORed. The example shows that clearly.

1 Like

How am i looking:

- id: '000000000006'
  alias: Morning routine2
  trigger:
  - entity_id: weather.home
    platform: state
    to: cloudy
  - entity_id: weather.home
    platform: state
    to: rainy
  - entity_id: weather.home
    platform: state
    to: partlycloudy
  - at: '12:30:00'
    platform: time
  condition:
  - condition: state
    entity_id: device_tracker.macbookpro
    state: home
  - after: '12:30:00'
    before: '13:00:00'
    condition: time
  - condition: or
    conditions:
    - condition: state
      entity_id: weather.home
      state: cloudy
    - condition: state
      entity_id: weather.home
      state: rainy
    - condition: state
      entity_id: weather.home
      state: partlycloudy
  action:
  - entity_id: group.living_room_lamps
    service: light.turn_on

That looks good. That condition wants macbookpro to be home and the time to be between 12:30 and 13:00 and the weather to be either cloudy, rainy, or partlycloudy.

I appreciate the help!!!

1 Like