Ring-mqtt bei Folge-Events

Hallo zusammen,

ich habe bei mir ring-mqtt im Einsatz und bis auf eine Kleinigkeit läuft das echt super.

Ich würde gerne die Motion-Events in HA archivieren und verwende hierfür die Automation aus der Anleitung ( Video Streaming · tsightler/ring-mqtt Wiki · GitHub ). Grundsätzlich funktioniert das auch alles, allerdings nicht bei mehreren Events direkt hintereinander.

Die Automation muss warten bis das Video in der Cloud fertig ist, soweit logisch, da alle Streams die ich mittels ffmpeg oder dergl. abgreifen könnte keinen Pre-Fetch haben. Somit ist das Video aus der Cloud das Beste.

Kommt aber jetzt der Postbote und klingelt (Event 1), Automation startet und wartet.
Der Postbote wartet aber auch, keiner macht auf, Benachrichtigung wird eingeworfen.
Aufgrund der Dauer löst das schon das nächste Event aus (Event 2).
In der Handy App sehe ich beide Ereignisse und kann beide Videos einzeln wiedergeben.
Die Automation lädt mir aber nur ein Video herunter und zwar das letzte.

Hat hier jemand eine Idee wie ich an beide Clips dran komme, sprich das die Automation parallel läuft und sich merkt welches Video zu welchem Ereignis sie herunterladen soll?

Vielen Dank
Patrick

Hallo nochmal,

damit hier keine Leichen im Forum liegen bleiben hier meine eigene (vorläufige) Antwort.

Ich hab mit das ganze mal im Detail angeguckt und dann (zugegeben mit KI-Hilfe) folgende Automation gebaut.

alias: Ring Haustür Video Download
triggers:
  - trigger: state
    entity_id: binary_sensor.haustur_motion
    from: "off"
    to: "on"
  - trigger: state
    entity_id: binary_sensor.haustur_ding
    from: "off"
    to: "on"
conditions:
  - condition: template
    value_template: >
      {{ (as_timestamp(now()) -
      as_timestamp(state_attr('automation.ring_haustur_video_download_pro','last_triggered')
      or 0)) > 20 }}
actions:
  - delay: "00:00:25"
  - action: system_log.write
    data:
      level: warning
      message: Ring Automation gestartet
  - repeat:
      count: 2
      sequence:
        - repeat:
            count: 10
            sequence:
              - choose:
                  - conditions:
                      - condition: template
                        value_template: "{{ repeat.index <= 5 }}"
                    sequence:
                      - action: select.select_option
                        target:
                          entity_id: select.haustur_event_select
                        data:
                          option: Motion {{ repeat.index }}
                  - conditions:
                      - condition: template
                        value_template: "{{ repeat.index > 5 }}"
                    sequence:
                      - action: select.select_option
                        target:
                          entity_id: select.haustur_event_select
                        data:
                          option: Ding {{ repeat.index - 5 }}
              - delay: "00:00:01"
              - variables:
                  event_id: "{{ state_attr('select.haustur_event_select','eventId') }}"
                  event_url: >-
                    {{ state_attr('select.haustur_event_select','recordingUrl')
                    }}
                  known_ids: "{{ states('input_text.ring_haustur_event_ids') }}"
              - action: system_log.write
                data:
                  level: warning
                  message: |
                    CHECK: ID={{ event_id }} | known={{ known_ids }}
              - condition: template
                value_template: |
                  {{ event_id is not none
                     and event_url is not none
                     and event_id not in known_ids }}
              - action: downloader.download_file
                data:
                  url: "{{ event_url }}"
                  subdir: |
                    Ring_Records/haustur/{{ now().strftime('%Y-%m-%d') }}
                  filename: >
                    {{ now().strftime('%Y%m%d_%H%M%S') }}_{{ 'ding' if
                    repeat.index > 5 else 'motion' }}.mp4
                  overwrite: false
              - action: input_text.set_value
                target:
                  entity_id: input_text.ring_haustur_event_ids
                data:
                  value: >
                    {% set current =
                    states('input_text.ring_haustur_event_ids').split(',') %} {%
                    set updated = (current + [event_id]) | reject('equalto','')
                    | unique | list %} {{ updated[-12:] | join(',') }}
        - delay: "00:00:05"
  - action: select.select_option
    target:
      entity_id: select.haustur_event_select
    data:
      option: Motion 1
mode: queued
max: 5

Das würde ich jetzt erstmal ein paar Tage laufen lassen und mir angucken was hierbei so als Ergebnis rum kommt.

Viele Grüße
Patrick