#Automation reacts to next calander massage

10 messages · Page 1 of 1 (latest)

next moss
#

I have an automation to run my vacuum with a 3 way condition choose action based on my integrated Google calender.
When my calender says I have a holiday (vakantie) or it is my parttime day of from work (vrij) it runs my vacuum while I'm still sleeping, else it runs delayed while I'm at the office.

The problem I'm having is when my next calender appointment is one of the 2 conditions but not yet today it still runs as if it is the state of the moment.

Is there a good way to add the begin and end time and date of the calender state into the automation condition?

actions:
  - choose:
      - conditions:
          - condition: state
            entity_id: calendar....._gmail_com
            state: Vakantie
            attribute: message
        sequence:
          - action: switch.turn_on
            metadata: {}
            data: {}
            target:
              device_id: e16126fbe666a8369db986cad5ed1d6a
          - delay:
              seconds: 10
          - device_id: 26b290f5763e72a2c1ec8816561c5901
            domain: vacuum
            entity_id: 9b236a2cbcdce22ac2f80e9225479d7f
            type: clean
      - conditions:
          - condition: state
            entity_id: calendar....._gmail_com
            attribute: message
            state: Vrij
        sequence:
          - action: switch.turn_on
            metadata: {}
            data: {}
            target:
              device_id: e16126fbe666a8369db986cad5ed1d6a
          - delay:
              seconds: 10
          - device_id: 26b290f5763e72a2c1ec8816561c5901
            domain: vacuum
            entity_id: 9b236a2cbcdce22ac2f80e9225479d7f
            type: clean
      - conditions: []
        sequence:
          - delay:
              hours: 3
          - device_id: 26b290f5763e72a2c1ec8816561c5901
            domain: vacuum
            entity_id: 9b236a2cbcdce22ac2f80e9225479d7f
            type: clean 
turbid nacelle
#

also check if the calendar entity has the state on

#

That will indicate an even is currently ongoing

next moss
turbid nacelle
#

doesn't really matter, but it stops checking conctions as soon as the first one fails. So I would check on the state first

#

And I would place the last part under the default key, insted of under an empty list of condtions

#
actions:
  - choose:
      - conditions:
          - condition: state
            entity_id: calendar....._gmail_com
            state: "on"
          - condition: or
            conditions:
              - condition: state
                entity_id: calendar....._gmail_com
                state: Vakantie
                attribute: message
              - condition: state
                entity_id: calendar....._gmail_com
                state: Vrij
                attribute: message
        sequence:
          - action: switch.turn_on
            target:
              device_id: e16126fbe666a8369db986cad5ed1d6a
          - delay:
              seconds: 10
          - device_id: 26b290f5763e72a2c1ec8816561c5901
            domain: vacuum
            entity_id: 9b236a2cbcdce22ac2f80e9225479d7f
            type: clean
    default:
      - delay:
        hours: 3
      - device_id: 26b290f5763e72a2c1ec8816561c5901
        domain: vacuum
        entity_id: 9b236a2cbcdce22ac2f80e9225479d7f
        type: clean 
#

BTW, on office days you don't need to turn on that switch?

#

With the setup above you could also use an if action, for which the syntax is a bit easier to understand

#
actions:
  - if:
      - condition: state
        entity_id: calendar....._gmail_com
        state: "on"
      - condition: or
        conditions:
          - condition: state
            entity_id: calendar....._gmail_com
            state: Vakantie
            attribute: message
          - condition: state
            entity_id: calendar....._gmail_com
            state: Vrij
            attribute: message
    then:
      - action: switch.turn_on
        target:
          device_id: e16126fbe666a8369db986cad5ed1d6a
      - delay:
          seconds: 10
      - device_id: 26b290f5763e72a2c1ec8816561c5901
        domain: vacuum
        entity_id: 9b236a2cbcdce22ac2f80e9225479d7f
        type: clean
    else:
      - delay:
        hours: 3
      - device_id: 26b290f5763e72a2c1ec8816561c5901
        domain: vacuum
        entity_id: 9b236a2cbcdce22ac2f80e9225479d7f
        type: clean