Too many triggers for my shutters

Hello all,

I’ve been using Home Assistant for a few years now and with the move to a house of my own, the need for automation is increasing and has pushed me to my limits. I hope you can help me avoid many probably unnecessarily complicated automations.

I have several shutters in my house that I would like to automate using different “events” throughout the day.
Examples:
When it is bright enough outside, I want the shutters to go up automatically, but only if the floor is occupied by a resident. However, if the sun is shining directly, the shutters should go down again halfway. (And also go up again when the direct sunlight ends).
When the TV comes on, certain shutters should go down again regardless of sunlight and brightness.

So, many different triggers that should affect the state of my shutters:

  1. brightness outside
  2. sunlight
  3. occupancy of the floor
  4. (sometimes) state of the TV

I started to create an automation for each state change of a trigger, but in the end I have to check the state of all other triggers at the same time for each state change of one of the triggers to determine the correct target state for my shutters. This leads to many very long and confusing automations.

Is there a way to build these automations more simply?

I had first considered if it would be easier to determine the state of the shutter via a variable and set the variable depending on the trigger. But in the end this does not reduce the complexity. On the contrary, this would lead to even more automations.

I am unfortunately at the end with my creativity and hope here a push in the right direction. I would be happy to get more clues for my research to build these automations easier.

Thanks a lot
Alex

Example Automation for TV turns off
alias: Erdgeschoss - Fernseher geht aus
description: ''
trigger:
  - platform: device
    device_id: 91b4e4c94d2f446611a751515a5f30cd
    domain: media_player
    entity_id: media_player.samsung_q8_series_65
    type: turned_off
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: input_boolean.tageshelligkeit
            state: 'off'
        sequence:
          - choose:
              - conditions:
                  - condition: state
                    entity_id: binary_sensor.erdgeschoss_occupancy
                    state: 'on'
                sequence:
                  - service: light.turn_on
                    data: {}
                    target:
                      entity_id:
                        - light.stehlampe
                        - light.lampe_kuche
                  - service: cover.close_cover
                    data: {}
                    target:
                      entity_id: cover.rolladen_wohnzimmer_fernseher
            default:
              - service: light.turn_off
                data: {}
                target:
                  entity_id:
                    - light.lampe_kuche
                    - light.stehlampe
              - service: cover.close_cover
                data: {}
                target:
                  entity_id: cover.rolladen_wohnzimmer_fernseher
      - conditions:
          - condition: state
            entity_id: input_boolean.tageshelligkeit
            state: 'on'
        sequence:
          - choose:
              - conditions:
                  - condition: state
                    entity_id: binary_sensor.erdgeschoss_occupancy
                    state: 'on'
                sequence:
                  - choose:
                      - conditions:
                          - condition: state
                            entity_id: binary_sensor.sonnenstand_ostseite
                            state: 'on'
                        sequence:
                          - device_id: 656e3b35f60a8c124288a6b17d87db9d
                            domain: cover
                            entity_id: cover.rolladen_wohnzimmer_fernseher
                            type: set_position
                            position: 30
                          - service: light.turn_off
                            data: {}
                            target:
                              entity_id:
                                - light.stehlampe
                                - light.lampe_kuche
                      - conditions:
                          - condition: state
                            entity_id: binary_sensor.sonnenstand_ostseite
                            state: 'off'
                        sequence:
                          - device_id: 656e3b35f60a8c124288a6b17d87db9d
                            domain: cover
                            entity_id: cover.rolladen_wohnzimmer_fernseher
                            type: set_position
                            position: 100
                          - service: light.turn_off
                            data: {}
                            target:
                              entity_id:
                                - light.stehlampe
                                - light.lampe_kuche
                    default: []
              - conditions:
                  - condition: state
                    entity_id: binary_sensor.erdgeschoss_occupancy
                    state: 'off'
                sequence:
                  - choose:
                      - conditions:
                          - condition: state
                            entity_id: binary_sensor.sonnenstand_ostseite
                            state: 'on'
                        sequence:
                          - device_id: 656e3b35f60a8c124288a6b17d87db9d
                            domain: cover
                            entity_id: cover.rolladen_wohnzimmer_fernseher
                            type: set_position
                            position: 30
                          - service: light.turn_off
                            data: {}
                            target:
                              entity_id:
                                - light.stehlampe
                                - light.lampe_kuche
                      - conditions:
                          - condition: state
                            entity_id: binary_sensor.sonnenstand_ostseite
                            state: 'off'
                        sequence:
                          - device_id: 656e3b35f60a8c124288a6b17d87db9d
                            domain: cover
                            entity_id: cover.rolladen_wohnzimmer_fernseher
                            type: set_position
                            position: 0
                          - service: light.turn_off
                            data: {}
                            target:
                              entity_id:
                                - light.stehlampe
                                - light.lampe_kuche
                    default: []
            default: []
    default: []
mode: single

You could build the conditions you need into a template sensor and use that to trigger your blinds automation.

Thank you very much, I will try that.
Sounds like a solution I’ll have to think around a bit, but it seems promising.

I would have to figure out in advance what combinations of states are necessary to trigger a desired shutter position.
Then define the appropriate template triggers and build them into the automations accordingly.

Sounds like a nice project for next weekend :slight_smile:

Thanks a lot

It will require quite a bit of thought I imagine, including some additional helpers potentially. I’ve had a few situations recently where I’ve struggled to find a solution for something, then remembered that template sensors are a thing and allow me to customise exactly what I want - including attributes which can also be handy.

Good luck, and feel free to keep us updated on how you get on!

We now have trigger based template sensors, keep that in mind. :slight_smile: I as well tend to overlook these, as they are fairly new, and you know, old habbits… :smiley:

But what I’d do, or better what I am doing in my home, is using different input_selects and binary_sensors and set them to different “modes” and “states”.

Eg. I have a “light_mode”, that is on/off accoriding to my criteria. If the sun is below X, “light_mode” is on, otherwise off. Now the automations can check that mode, when needed. The automation for “coming home” now checks for the condition “light_mode” == on, then turn the lights on or leave it as they are.

I as well have a “residence_state”, that tells me, if someone is home, or we (wife and I) are home.

This gives you the advantage, that you don’t need to check for specific states of sensors. You just check the one or two modes or states in your automation. If something changes, you have several automations, that change the mode, and the automation to control your shutters knows exactly what to do, without rearranging things there.

As already said, it requires quite a bit of planning ahead, but on the other hand, you can always change or add things to the modes and states.

That’s great advice and exactly the kind of thing I’m currently looking to improve for various areas of my smart home. Every time something triggers when I don’t want it to (e.g. light going on/off) I locate the automation and look at how I could avoid mistriggers and streamline at the same time.

That was the reason, why I initially started such a “system”. I spent too much time in searching for things, that I couldn’t find first hand. :smiley: :rofl:

But, if I’m honest, for such a thing, you need to have a relatively good presence detection, otherwise you will run into strange things, like the covers close in the middle of the day. :rofl: :rofl:

Oh, and one thing turned out to be quite useful: before you actually let the “new” automations do anything, try it for one or two days just with a persistent notification, when and what changed in that moment. :slight_smile: Something like “The residence_state changed to XY, the automation would now do XY.” :wink:

1 Like

Thank you for your suggestions.

I will now try this approach:

I have mainly shutters on the east and west side of the house and have 3 floors. For each orientation and for each floor I define a template sensor with the respective target state of the shutter depending on the described sensors. Example:

Shutters first floor east side:
Shutters up if

  • Daylight AND
  • First floor occupied AND
  • TV is off AND
  • No direct sunlight

Else if
Shutter halfway up if

  • direct Sunlight detected AND
  • TV is off

Else
Shutter down

In my automation every change of state of the following binary sensors is a trigger for the automation:

  • Daylight
  • Occupancy
  • TV
  • Direct Sunlight

The action of the automation then checks the status of the template sensor and then controls the shutter.
This means that I need 6 automations (east/west orientation for 3 floors) to control my shutters.

I am curious if this will work. I am also happy to receive other suggestions.