[HELP] Automation based on temperature and time

Hello HA-Community,

i created an automation for covercontrol, based on temparature and time.
When the temperature of sensor X is 22.5 °C or above and it´s between 8:15 AM and 5:15 PM close cover X, Y, Z to 30%.
The automation works, if the temperature is under 22.5 and reaches it between 8:15 AM and 5:15 PM.
But now it´s very warm here and we have 23 °C before 8:15 AM, with my automation the cover don´t close after 8:15 AM, because the temperature was reached before the time.

Optional I want, if the covers already set to the exact position, that it don´t triggers / no notification is triggered.

Can you help me? This is my code:

alias: COVER CONTROL
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.ble_temperature_essbereich_thermometer
    above: '22.5'
  - platform: homeassistant
    event: start
condition:
  - condition: time
    before: '17:15:00'
    after: '08:15:00'
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
action:
  - device_id: 7ecac06fb8a8ef4877ac59e1a73694c9
    domain: cover
    entity_id: cover.esszimmer_rollo_1
    type: set_position
    position: 30
  - device_id: 4b7807dc4907e4db5e1f829dc1c66e66
    domain: cover
    entity_id: cover.esszimmer_rollo_2
    type: set_position
    position: 30
  - device_id: 4185942f42ba490052474100c7bce295
    domain: cover
    entity_id: cover.esszimmer_rollo_3
    type: set_position
    position: 30
  - device_id: 1309dcccdaaa21008bd6f49033ad747c
    domain: cover
    entity_id: cover.wohnzimmer_rollo_5
    type: set_position
    position: 30
  - device_id: 6b5c90fa5806406ac15d616045a4eee2
    domain: mobile_app
    type: notify
    message: >-
    The shutters on the south side were lowered by 70% due to heat
    shut down.
    title: Shutters on the south side were lowered by 70%
mode: single

Sorry - those times don’t make sense.

In 24hr notation, 8:15pm is 20:15, and 17:15am doesn’t exist. Do you mean 5:15am - 05:15?

Edit - it’s probablaly a language thing - I can see what you are trying to do from your condition.

You need another automation that triggers at 5:15pm (17:15) and closes the shutters if the are open.

Once you get past 5:15pm with the above automation, it will trigger but your conditions will prevent it doing anything.

Sorry, i´m from germany and swapped the two :grimacing:
I mean 8:15 AM and 5:15 PM - I changed it in my inquiry, thanks!

Don’t worry - I’m from Australia and just plain can’t type - I end up editing every post I do 3 times :slight_smile:

1 Like

Also see my edited post above that suggests you need a second automation. You could do it in this one - but I believe there are no overheads having a second one to do the time trigger.

My wish is that it opens after 5:15 p.m. and the automation only checks the next day between 8:15 a.m. and 5:15 p.m. whether it is warm enough or whether it has already reached 22.5 degrees or not and triggers it accordingly.

In the same automation, add a trigger for when is 08:15 and a condition to not run unless the temperature is above 22,5°.
This will force it to check the conditions if is 08:15 but will on ly run if it is above your threshold.

Ok - same still applies. Open, not closed:

Edit your ams and pms got me again… 2secs

automation:
  - trigger:
    - platform: time
      #  This trigger will fire at 5:15PM
      at: "17:15:00"
action:
  - device_id: 7ecac06fb8a8ef4877ac59e1a73694c9
    domain: cover
    entity_id: cover.esszimmer_rollo_1
    type: set_position
    position: 100
  - device_id: 4b7807dc4907e4db5e1f829dc1c66e66
    domain: cover
    entity_id: cover.esszimmer_rollo_2
    type: set_position
    position: 100
  - device_id: 4185942f42ba490052474100c7bce295
    domain: cover
    entity_id: cover.esszimmer_rollo_3
    type: set_position
    position: 100
  - device_id: 1309dcccdaaa21008bd6f49033ad747c
    domain: cover
    entity_id: cover.wohnzimmer_rollo_5
    type: set_position
    position: 100
  - device_id: 6b5c90fa5806406ac15d616045a4eee2
    domain: mobile_app
    type: notify
    message: >-
    The shutters on the south side were opened.
    title: Shutters on the south side were opened
    mode: single

You don’t need to check if they are already open, just open them at 17:15.

You mean like this? But I can´t add a condition below the trigger “8:15”. Or you mean, your condition must be under the condition part?

alias: ROLLO - Südseite schließen (temperaturgesteuert)
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.ble_temperature_essbereich_thermometer
    above: '22.5'
  - platform: homeassistant
    event: start
  - platform: time
    at: '08:15:00'
  - condition: not
    conditions:
      - condition: numeric_state
        entity_id: sensor.ble_temperature_essbereich_thermometer
        above: '22.5'
condition:
  - condition: time
    before: '17:15:00'
    after: '08:15:00'
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
action:
...

I have already built an automation for opening after 5:15 p.m.
Unfortunately, this is of no use, if it is already over 22.5 degrees before 8.15 a.m., then my automation will no longer trigger.

No worries. What Edward suggested will work.

1 Like

Sorry, I’m writing in a tablet and cannot validate the code right now, but I would suggest something like this:


alias: ROLLO - Südseite schließen (temperaturgesteuert)
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.ble_temperature_essbereich_thermometer
    above: '22.5'
  - platform: homeassistant
    event: start
  - platform: time
    at: '08:15:00'
condition:
  - condition: numeric_state
    entity_id: sensor.ble_temperature_essbereich_thermometer
    above: '22.5'
  - condition: time
    before: '17:15:00'
    after: '08:15:00'
    weekday:
      - mon
      - tue
      - wed
      - thu

You don’t need another automation to open after 17:15. Just add that as another trigger on your automation and remove the “before: 17:15:00” from your time based condition.

Thank you, I´ve changed it and give it a try!

How can I add trigger at 17:15 with action, that the cover opens?

Now my triggers are:

  • Over 22.5 degrees
  • Home Assistant - Event: start
  • At 08:15

Conditions:

  • Between 8:15 and 17:15
  • under 22.5 degrees

The actions are:

  • close cover to 30%
  • notify me.
1 Like

Aha, you wanna open at 17:15. I understood from before yiu wanna close it… My mistake, sorry.
You can always name your triggers and use options to define what to do in each case, I would go for that onky if I have too many other automation and want to reduce the number on that list. It hat is not a problem for you having another automation is probably the best way as it would be easier to read (and probably easier to maintain).

By the way, is the automation working now?
You probably will have to wait a few days until you can validate all those cases in real life, right?

Yes, I want open the covers based on time, because at 17:15 it`s not as hot as at noon.
Thanks, I will then leave it at a separate automation.

I changed the automation and will test it tomorrow - I will give feedback!

By the way, you should later play with other triggers and conditions, so you kind of use sunrise/sunset instead to f fix times and some weather integration to keep the cover open if it isn’t sunny outside, etc.