Untitled

 avatar
unknown
plain_text
a month ago
3.3 kB
5
Indexable
alias: Person occupancy
description: ""
triggers:
  - entity_id:
      - binary_sensor.front_yard_person_occupancy
      - binary_sensor.backyard_person_occupancy
    to: "on"
    trigger: state
    from: "off"
conditions:
  - condition: state
    for:
      hours: 0
      minutes: 0
      seconds: 20
    entity_id: binary_sensor.esphome_front_door
    state: "off"
  - condition: template
    value_template: >-
      {{ now() - state_attr('automation.parcel_person_occupancy',
      'last_triggered') > timedelta(seconds=30) }}
actions:
  - variables:
      snapshot_file: "{{ now().timestamp() | timestamp_custom('%Y%m%d%H%M%S') }}-snapshot.jpg"
  - action: image.snapshot
    metadata: {}
    data:
      filename: /media/snapshots/{{ snapshot_file }}
    target:
      entity_id: "{{ state_attr(trigger.entity_id, 'zone_snapshot') }}"
  - if:
      - condition: state
        entity_id: input_boolean.voice_alerts
        state: "on"
        enabled: true
    then:
      - choose:
          - conditions:
              - condition: state
                entity_id: media_player.speaker_alert_group
                state: "off"
            sequence:
              - metadata: {}
                data:
                  is_volume_muted: true
                target:
                  entity_id: media_player.speaker_alert_group
                action: media_player.volume_mute
              - metadata: {}
                data: {}
                target:
                  entity_id: media_player.speaker_alert_group
                action: media_player.turn_on
              - wait_template: "{{ is_state('media_player.speaker_alert_group', 'idle') }}"
                continue_on_timeout: true
              - delay:
                  hours: 0
                  minutes: 0
                  seconds: 1
                  milliseconds: 0
              - target:
                  entity_id: media_player.speaker_alert_group
                data:
                  is_volume_muted: false
                action: media_player.volume_mute
          - conditions:
              - condition: state
                entity_id: media_player.speaker_alert_group
                state: idle
            sequence:
              - target:
                  entity_id: media_player.speaker_alert_group
                data:
                  is_volume_muted: false
                action: media_player.volume_mute
        enabled: false
      - action: automation.trigger
        metadata: {}
        data:
          skip_condition: true
        target:
          entity_id: automation.google_speaker_quiet_activation
      - data:
          message: Someone is in frontyard
          cache: true
          entity_id: media_player.speaker_alert_group
        enabled: true
        action: tts.google_say
    enabled: true
  - action: notify.mobile_app_galaxy_s24
    metadata: {}
    data:
      message: Someone is on the {{ state_attr(trigger.entity_id, 'zone_name') }}
      data:
        clickAction: "{{ state_attr(trigger.entity_id, 'zone_link') }}"
        image: /media/local/snapshots/{{ snapshot_file }}
        actions:
          - action: URI
            title: Open camera
            uri: "{{ state_attr(trigger.entity_id, 'zone_link') }}"
      title: Home
mode: single
Leave a Comment