- alias: Vacation Mode - Recovery efter restart
  trigger:
    - platform: homeassistant
      event: start

  condition:
    - condition: state
      entity_id: input_boolean.vacation_mode
      state: "on"

  action:
    - choose:
        - conditions:
            - condition: template
              value_template: >
                {% set dt = states('input_datetime.vacation_end') %}
                {{ dt not in ['unknown','unavailable',''] and
                   now() >= as_datetime(dt) }}
          sequence:
            - service: input_boolean.turn_off
              target:
                entity_id:
                  - input_boolean.vacation_mode
                  - input_boolean.presence_simulation
      default:
        - service: input_boolean.turn_on
          target:
            entity_id: input_boolean.presence_simulation
