How to best handle this infrequently used automation?

I used this automation while away on vacation and it worked as expected. I have a "Vacation Mode Switch" toggle that when I turn it on certain actions are performed. Then I also have other triggers which look at the sun's elevation, a light sensor value, and also the time of 11:30 PM.

My concern is if I leave the automation enabled after returning from vacation, the triggers will still be actively listening for these events but performing no action, since I have the condition "If vacation mode switch is on", so if switched off, no actions will be executed.

Should I simply disable this automation when I'm not on vacation? Or is there a better way to write it so the triggers are not still waiting for an event?

-Thanks



alias: Vacation Mode
description: ""
triggers:
  - trigger: state
    entity_id:
      - input_boolean.vacation_mode_toggle
    from:
      - "off"
    to:
      - "on"
    id: vacation mode on
  - trigger: state
    entity_id:
      - input_boolean.vacation_mode_toggle
    from:
      - "on"
    to:
      - "off"
    id: vacation mode off
  - trigger: numeric_state
    entity_id:
      - sun.sun
    attribute: elevation
    below: -1
    id: dusk elevation
  - alias: Dusk - When Aqara T1 Light Sensor is Below 75
    entity_id: sensor.aqara_t1_light_sensor
    below: 75
    trigger: numeric_state
    id: dusk lux
  - trigger: time
    at: "23:30:00"
    id: lights off
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - vacation mode on
        sequence:
          - action: automation.turn_off
            metadata: {}
            target:
              entity_id: automation.thermostat_scheduler_test
            data:
              stop_actions: true
            enabled: true
          - action: climate.set_temperature
            metadata: {}
            target:
              entity_id:
                - climate.t6_pro_z_wave_programmable_thermostat
                - climate.t6_pro_z_wave_programmable_thermostat_2
            data:
              hvac_mode: heat_cool
              target_temp_low: 66
              target_temp_high: 80
            enabled: true
      - conditions:
          - condition: trigger
            id:
              - vacation mode off
        sequence:
          - action: automation.turn_on
            metadata: {}
            target:
              entity_id: automation.thermostat_scheduler_test
            data: {}
          - action: climate.set_temperature
            metadata: {}
            target:
              entity_id:
                - climate.t6_pro_z_wave_programmable_thermostat
                - climate.t6_pro_z_wave_programmable_thermostat_2
            data:
              hvac_mode: heat_cool
              target_temp_low: 68
              target_temp_high: 78
            enabled: true
      - conditions:
          - condition: trigger
            id:
              - dusk lux
              - dusk elevation
          - condition: state
            entity_id: input_boolean.vacation_mode_toggle
            state:
              - "on"
            enabled: true
        sequence:
          - action: light.turn_on
            metadata: {}
            target:
              entity_id:
                - light.office_lamp_3
                - light.living_room_lamp
            data: {}
          - action: switch.turn_on
            metadata: {}
            target:
              entity_id:
                - switch.bedroom_lamp
                - switch.bernard_s_lamp
            data: {}
      - conditions:
          - condition: trigger
            id:
              - lights off
          - condition: state
            entity_id: input_boolean.vacation_mode_toggle
            state:
              - "on"
        sequence:
          - action: light.turn_off
            metadata: {}
            target:
              entity_id:
                - light.office_lamp_3
                - light.living_room_lamp
                - light.garage_lights
            data: {}
          - action: switch.turn_off
            metadata: {}
            target:
              entity_id:
                - switch.bedroom_lamp
                - switch.bernard_s_lamp
                - switch.porch_light
            data: {}
mode: single

There are varying opinions on this kind of thing. Personally, I just leave them and reserve the option to disable and enable automations for emergencies and maintenance. That would include, especially, not using the automation.turn_on and automation.turn_off action like you are using.

A couple extraneous triggers a day is not worth worrying about.

Thanks, I feel better now! :slightly_smiling_face:

I would tackle this very differently.

Firstly, I'd split the vacation on and off parts.

I would also get rid of the self-referential triggering, where changing the vacation mode will trigger the automation again. In future (with more changes), this can cause trouble and I think it makes debugging harder.

By separating the automations, you can then move the conditions you have under choose into the main condition blocks. You can also get rid of the trigger IDs.

It's also generally better to control automations via conditions and helpers, rather than turning automations on and off. It's not that it's wrong, because clearly it's allowed. It's more of a best practice.

I know you might like having a single automation, but you asked for feedback. :slight_smile: Up to you!

Thank you I will look into your suggestions. I was also thinking that having a separate automation which switches the helper Vacation Mode Switch off or on, I could disable AND enable the automation if I wanted which would eliminate the active triggers. But as Didgeridrew stated a couple of extraneous triggers a day is not worth worrying about.

I know you asked two specific questions at the end, but I think this is the thing you need to dig into more:

I think you gotta do some investigative approach–like the five whys–to get at what you're actually concerned about.

If you are really, truly, only concerned that no actions are happening; then yes it's fine if no actions are happening. You can apply conditions to automations to skip actions, why wouldn't it be fine for no actions to run? (rhetorical). But it feels like you're talking about a symptom, and I'm pretty sure there's a more specific cause to your concern. In which case, you want to ask, "Why are you concerned that no actions are happening when an automation runs?" (or something similar). That'll get you closer to answering your actual question, while also providing a better understanding of the system, so you're able to answer more of these questions yourself in the future.

Folks are telling you how to adjust your automation. These responses are are good, and answer your two specific questions. But, these answers are not helping with (what I think is) your underlying concern.

Thanks for the info. I guess what I'm searching for is an eclectic approach to optimizing my automations. And learning quite a bit along the way!

I have a similar automation. In my case, it pre-heats the house if we are away for a long time in the winter. That way, the house doesn't wait for us to return home before resuming its normal cadence.

I have separated the need for pre-heating from the actual process of pre-heating. On the dashboard, there are controls to set when we expect to return home, and a button to enable the pre-heating check. The button isn't really needed, but I prefer to keep automations as simple as possible. Enabling/disabling the automation avoids having checks in the automation.
Personal choice.

When I turn off the "Vacation Mode Switch" the normal HVAC schedule resumes, among other things. I shut off vacation mode about 2 hours before returning home, and the air conditioning cooled the upstairs and downstairs.

I love Home Assistant!