Open blinds between certain time if temp range is right

I’m trying to figure out what I’m doing wrong here. The goal is that the conditional time be 12:00 to -1:05 sunset where the blinds open if at any point the temp sensor reads between 25 and 80. We have been holding between 50 and 70 the past few days but it hasn’t opened. Where am I off here? Thank you in advance.

- id: '2028683333304'
  alias: Entry blinds daytime open if below 80F; noon to 1hr before sunset
  description: ''
  trigger:
  - type: temperature
    platform: device
    device_id: 52a7c56c24bf78a8eba58757bac2625e
    entity_id: sensor.temperature_14
    domain: sensor
    above: 25
    below: 80
  condition:
  - condition: sun
    before: sunset
    before_offset: "-01:05:00"
  - condition: time
    after: "12:00"
    before: '19:00'
  action:
  - service: scene.turn_on
    target:
      entity_id: scene.daytimeentry
  mode: single

This automation will only trigger if the temperature was below 25 going above 25 or above 80 going below 80. To achieve what you want you need to trigger on every temperature change and add your thresholds as a condition.

Also conditions are AND by default, so currently they will only be true at 1:05 hours before sunset.

Thank you for the reply. Very noob with these things, so I’m wondering if this trigger line would work to the mix: value_template: “{{ state.attributes.value - 5 }}” as I’m trying to find a way to accomplish what you’re saying without a trigger written for every few degrees change.

- id: '2028683333304'
  alias: Entry blinds daytime open if below 80F; noon to 1hr before sunset
  description: ''
  trigger:
  - type: temperature
    platform: device
    device_id: 52a7c56c24bf78a8eba58757bac2625e
    entity_id: sensor.temperature_14
    domain: sensor
    value_template: "{{ state.attributes.value - 5 }}"
    above: 25
    below: 80
  condition:
  - condition: or
    conditions:
  - condition: sun
    before: sunset
    before_offset: "-01:05:00"
  - condition: time
    after: "12:00"
    before: '19:00'
  action:
  - service: scene.turn_on
    target:
      entity_id: scene.daytimeentry
  mode: single

No, that won’t work.

Please also forget what I said about the conditions with sunset, I mixed something up, as you had it in the beginning was fine.

What does the scene.daytimeentry do? Only open the blinds or other things as well? Can you please show the code for the scene?

I think you have to remove the temperature sensor from the Trigger section, and add it as a Condition.
What you could use as a trigger is for instance a Time Pattern trigger.
Something like this:

- id: '2028683333304'
  alias: Entry blinds daytime open if below 80F; noon to 1hr before sunset
  description: ''
  trigger:
  - platform: time_pattern
    minutes: /1
  condition:
  - condition: numeric_state
    entity_id: sensor.temperature_14
    above: '25'
    below: '80'
  - condition: sun
    before: sunset
    before_offset: '-01:05:00'
  - condition: time
    after: '12:00'
    before: '19:00'
  action:
  - service: scene.turn_on
    target:
      entity_id: scene.daytimeentry
  mode: single

This will check every minute whether all the conditions are met, and if so open the blinds.

You can continue using the temperature sensor, just not with a numeric state trigger. This way it doesn’t need to run every minute.

- id: '2028683333304'
  alias: Entry blinds daytime open if below 80F; noon to 1hr before sunset
  description: ''
  trigger:
  - platform: state
    entity_id: sensor.temperature_14
  condition:
  - condition: numeric_state
    entity_id: sensor.temperature_14
    above: '25'
    below: '80'
  - condition: sun
    before: sunset
    before_offset: '-01:05:00'
  - condition: time
    after: '12:00'
    before: '19:00'
  action:
  - service: scene.turn_on
    target:
      entity_id: scene.daytimeentry
  mode: single

Question is what the scene does and if a condition needs to be added to only fire if the blinds are not already open.

Interesting!
But how exactly does this state of a temperature sensor work in this case?
Isn’t the automation now in fact running every millisecond or so?

What I am also wondering about is how the blinds will be closed again when the conditions are not met.
This is still missing from the configuration I think?

It runs whenever the temperature sensor changes states.

Don’t know about the closing of the blinds, maybe it’s a separate automation, OP needs to tell us.

But then when is the sensor changing state in this case?
Is this whenever the temperature is changing, like going from 26 to 27?
If so, this would mean that the blinds will not close when the temperature stays constant while a time threshold is passed?

Yes, it changes whenever the temperature changes.

If the temperature never changes between noon and sunset, the sensor is certainly defect.

Yes, sure.
But I can imagine that the temperature stays constant at 30 for let’s say 30 minutes while 12:00 is passed. So in that case the blinds will not be closed within the intended time condition.
Or am I missing something here?

Yes, that’s correct. Then it will only trigger at 12:30.

OK, thanks Burningstone for clearing this up.
But I am still not clear about why using a time pattern trigger would be the less preferred choice. Why is it less desirable to have an automation running for instance every minute?

It triggers way more frequently than needed and therefore more processing power is needed. However, I admit that it doesn’t matter as the processing power needed is so small. But in general you always should try to minimize the amount of triggers.

OK, thanks Burningstone. I totally get it now :grinning:
So in the end it is a choice between reducing the processing power as much as possible or trying to match the intended condition as much as possible.
But when using the time pattern trigger, I think the optimum between these two can be achieved by fine-tuning the time pattern period.

Not really and that line of thinking suggests you may be unfamiliar with one of Home Assistant’s key strengths: it is event-based.

Here’s an analogy:

Event-based: Your employees are perfectly capable of informing you when they have completed their assigned tasks or when important events have occurred. So if you give them a task, they will inform you when they’re done.

Polling-based: However, you ignore that ability and choose to repeatedly inquire about the task’s status.
“Are you done yet?”
“Are you done yet?”
“Are you done yet?”
“Are you done yet?”
“Are you done yet?”
etc

Over the past three years that I have participated in this forum, the majority of examples employing the Time Pattern Trigger have been unnecessary and usually created by newcomers unfamiliar with Home Assistant’s capabilities.

1 Like

Wow! Thanks for all the conversation. I’m trying to follow it.

Basically, I made the scene to open the entry blinds during the day to a certain level. That’s all it does. Sadly, the blinds don’t support like % open like my others do so I had to use a scene.

They close at 1 hour prior to sunset via a basic trigger at sunset -1.

My goal is to have them open when the temperatures are not extreme but to close when necessary to try to minimize heat loss / heat gain when it’s a bit more than what the window seems to handle sun wise.

So if I’m following, it seems better to use the last example with:

  trigger:
  - platform: state
    entity_id: sensor.temperature_14
  condition:
  - condition: numeric_state
    entity_id: sensor.temperature_14
    above: '25'
    below: '80'

EDIT: I chose to begin this at noon because it seems that noon is the best time to avoid the direct intense sun shining in because of the window faces southeast. I have no clue about this azimuth thing or how to figure that out so I went with time.

Yes, that’s correct: I am still pretty new to Home Assistant and IoT in general.
I certainly accept your knowledge, but I am trying to fully understand it.

Isn’t it so that with an Event-based approach Home Assistant is checking constantly whether a status is changing, so in your example the manager is asking “Are you done yet” every millisecond?
And with a Polling-based approach the manager is asking this every minute (or whatever period is chosen)?

Ah! I think I understand it now: the manager isn’t asking constantly, he/she is just waiting for the employees to inform when they are ready.
So in that case it takes less processing power when using the Event-based setup.

You don’t need a scene for that. What’s the entity_id of the cover?

This should do what you want, just replace cover.xxx with your entity_id

- id: '2028683333304'
  alias: Entry blinds daytime open if below 80F; noon to 1hr before sunset
  description: ''
  trigger:
  - platform: state
    entity_id: sensor.temperature_14
  - platform: time
    at: '12:00:00'
  condition:
  - condition: numeric_state
    entity_id: sensor.temperature_14
    above: '25'
    below: '80'
  - condition: sun
    before: sunset
    before_offset: '-01:05:00'
  - condition: time
    after: '12:00'
    before: '19:00'
  - condition: state
    entity_id: cover.xxx
    state: closed
  action:
  - service: cover.open_cover
    target:
      entity_id: cover.xxx
  mode: single

I added a condition so that it will only open the cover if it is currently closed. I also added a trigger at 12:00.

Thank you for the help. Yeah, it’s “cover.entryway_large” so I will swap it out and see what happens.

Let me try to overcomplicate my brain here. Let’s say that from 12:00 to -1:05:00 sunset I wanted to have it open at any time if it’s closed when those temp conditions are met, does that mean I should make an entry per temperature range like you said? Say, 25-30, 30-35, 35-40, etc etc. on a 5 degrees range?