Automation to only run between certain hours

Until now I have a blind stay closed each day until 14:00 when the sun passes over the roof, to protect some delicate wooden furniture.

But I want to automate the blind so that it only stays closed if cloud cover is less than 80%, based on AccuWeather data, between the hours of 07:00-14:00.

I have sorted the AccuWeather API & integration, but I don’t know how to organise the code so that the curtain either doesn’t open & remains closed 07:00-14:00 if the cloud cover is <81 OR closes between 07:00-14:00 IF the cloud cover drops to <81.

This is what I have done so far…

- id: '1672922816590'
  alias: Cloud Cover TEST
  description: ''
  trigger:
  - platform: time
    at: 07:00:00
  - platform: numeric_state
    entity_id: sensor.the_billet_cloud_cover
    below: 81
  condition: []
  action:
  - service: cover.close_cover
    data: {}
    target:
      device_id: 12e39abc1f656fa538a8e818bfefd171
  mode: single

This is the sensor “state” info at the time of writing.

All assistance gratefully received!

TIA

That code isn’t going to open the cover at all, and will close it at 07:00 regardless of cloud cover or at any time the cloud cover changes from above 81 to below 81 (triggers are OR).

Just add conditions to check for cloud cover at 07:00, and to prevent it from operating outside 07:00 to 14:00 (e.g. 15:00 with low cloud cover) (conditions are AND):

- id: '1672922816590'
  alias: Cloud Cover TEST
  description: ''
  trigger:
    - platform: time
      at: 07:00:00
    - platform: numeric_state
      entity_id: sensor.the_billet_cloud_cover
      below: 81
  condition:
    - condition: numeric_state
      entity_id: sensor.the_billet_cloud_cover
      below: 81
    - condition: time
      after: "06:59:00"
      before: "14:00:00"
  action:
    - service: cover.close_cover
      data: {}
      target:
        device_id: 12e39abc1f656fa538a8e818bfefd171
  mode: single

So:

  • triggers at 07:00, only closes if low cloud cover
  • triggers on low cloud cover, only closes if between 07:00 and 14:00

I made the after: condition 06:59 so it doesn’t clash with the 07:00 trigger.

2 Likes

Wow - thank you so much!

1 Like

Would this pair of automations work? So that …

  • If cloud cover at 07:00 is <81% the cover remains closed*** OR closes anytime between 07:00-14:00 if the cloud cover drops below 81% between 07:00-14:00
  • If cloud cover at 07:00 is >81% the cover opens*** AND opens anytime between 07:00-14:00 if the cloud cover goes above 81% between 07:00-14:00

*** The cover closes at SS+30 each day.

TIA

- id: '1672922816591'
  alias: Cloud Cover <80% Close cover
  description: ''
  trigger:
    - platform: time
      at: 07:00:00
    - platform: numeric_state
      entity_id: sensor.the_billet_cloud_cover
      below: 81
  condition:
    - condition: numeric_state
      entity_id: sensor.the_billet_cloud_cover
      below: 81
    - condition: time
      after: "06:59:00"
      before: "14:00:00"
  action:
    - service: cover.close_cover
      data: {}
      target:
        device_id: 12e39abc1f656fa538a8e818bfefd171
  mode: single
- id: '1672922816590'
  alias: Cloud Cover >80% Open cover
  description: ''
  trigger:
    - platform: time
      at: 07:00:00
    - platform: numeric_state
      entity_id: sensor.the_billet_cloud_cover
      above: 81
  condition:
    - condition: numeric_state
      entity_id: sensor.the_billet_cloud_cover
      above: 81
    - condition: time
      after: "06:59:00"
      before: "14:00:00"
  action:
    - service: cover.open_cover
      data: {}
      target:
        device_id: 12e39abc1f656fa538a8e818bfefd171
  mode: single

I think so. One way to find out for sure… :wink:

2 Likes