SgtBatten / HA_blueprints

Somewhere to store automation blueprints
151 stars 56 forks source link

[Bug]: Video/Clip in notification cannot be displayed #120

Open osworx opened 8 months ago

osworx commented 8 months ago

Description

Environement: Core 2023.11.2 Supervisor 2023.11.3 Operating System 11.1 Frontend 20231030.2

Android Samsung Galaxy A02s / Version 12

While the notification works perfectly (snapshot can be viewed), the clip cannot: showing just the media player and the "waiting" spinner .. nothing else happens.

Version

0.12.0.1r (latest dev version)

Automation Config

- id: '1699612873350'
  alias: Benachrichtigung Michi verlässt Haus
  description: ''
  use_blueprint:
    path: homeassistant/notify_leaving_zone.yaml
    input:
      person_entity: person.michael
      zone_entity: zone.home
      notify_device: 4ca9e5bf0d5ef544bda70801c6756ad2
- id: '1699885619512'
  alias: Tür geöffnet > Nachricht an HA & Mobil Michi
  description: Sendet eine Benachrichtigung an HA & Mobil Michi wenn Tür geöffnet
    wurde
  trigger:
  - type: opened
    platform: device
    device_id: 85cd9e69daf7f02bf35eaa6e7fa8a672
    entity_id: 653b73648008ee55da50e61449ca8711
    domain: binary_sensor
  condition: []
  action:
  - device_id: 4ca9e5bf0d5ef544bda70801c6756ad2
    domain: mobile_app
    type: notify
    message: Tür wurde geöffnet
    title: Tür wurde geöffnet
  - service: notify.persistent_notification
    data:
      message: Tür wurde geöffnet
      title: Tür wurde geöffnet
  mode: single
- id: '1699885752803'
  alias: Tür geschlossen
  description: Sendet eine Benachrichtigung an HA wenn Tür geschlossen wurde
  trigger:
  - type: not_opened
    platform: device
    device_id: 85cd9e69daf7f02bf35eaa6e7fa8a672
    entity_id: 653b73648008ee55da50e61449ca8711
    domain: binary_sensor
  condition: []
  action:
  - device_id: 4ca9e5bf0d5ef544bda70801c6756ad2
    domain: mobile_app
    type: notify
    message: Tür wurde geöffnet
    title: Tür wurde geöffnet
  - service: notify.persistent_notification
    data:
      message: Tür wurde geöffnet
      title: Tür wurde geöffnet
  mode: single
- id: '1699955362070'
  alias: 'Waschmaschine Keller : Waschvorgang gestartet'
  description: Benachrichtigung an HA & Mobil Michi wenn Waschmaschine im Keller eingeschaltet
    wurde
  trigger:
  - type: voltage
    platform: device
    device_id: 6b4d0f9e82ffd2e61c8510603f3dcf08
    entity_id: 8e0756ec480bf5366b962d699ad20c5d
    domain: sensor
    above: 10
  condition: []
  action:
  - service: notify.persistent_notification
    data:
      message: Waschmaschine eingeschaltet
  - device_id: 4ca9e5bf0d5ef544bda70801c6756ad2
    domain: mobile_app
    type: notify
    message: Waschmaschine eingeschaltet
  mode: single
- id: '1699956558892'
  alias: 'Waschmaschine Keller : Waschvorgang beendet'
  description: Sendet Nachricht an HA & Mobil Michi wenn Waschavorgang beendet ist
  trigger:
  - type: voltage
    platform: device
    device_id: 6b4d0f9e82ffd2e61c8510603f3dcf08
    entity_id: 8e0756ec480bf5366b962d699ad20c5d
    domain: sensor
    below: 10
  condition: []
  action:
  - service: notify.persistent_notification
    data:
      message: Waschmaschine > Waschvorgang beendet
  - device_id: 4ca9e5bf0d5ef544bda70801c6756ad2
    domain: mobile_app
    type: notify
    message: Waschmaschine > Waschvorgang beendet
  mode: single
- id: '1700063241214'
  alias: Michael kommt nach Hause / verlässt Haus
  description: Benachrichtigung wenn Michael die Zone HOME erreicht/verlässt
  use_blueprint:
    path: panhans/zone_notification_extended.yaml
    input:
      persons:
      - person.michael
      zones:
      - zone.home
      duration: 3
      notify_device: 4ca9e5bf0d5ef544bda70801c6756ad2
      title_arriving: '{{ person }} ist angekommen'
      message_arriving: '{{ person }} hat {{ zone }} erreicht.'
      title_leaving: '{{ person }} geht'
      message_leaving: '{{ person }} verlässt {{ zone }}.'
      notification_color:
      - 250
      - 90
      - 226
      custom_action_leaving:
      - service: notify.persistent_notification
        data:
          message: Michi kommt bzw. geht
- id: '1700067363526'
  alias: Frigate Benachrichtigung (Person entdeckt)
  description: Sendet Benachrichtigung an Mobil Michi wenn Person durch Kamera entdeckt
    wird
  use_blueprint:
    path: SgtBatten/Beta.yaml
    input:
      camera: camera.torkamera
      notify_device: 4ca9e5bf0d5ef544bda70801c6756ad2
      title: Torkamera Benachrichtigung
      message: Person entdeckt ..
      alert_once: true
      attachment: snapshot.jpg
      ios_live_view: camera.torkamera
      sticky: true
      zone_filter: false
      button_2: Bild ansehen
      debug: true
      url_1: '{{base_url}}/api/camera_proxy_stream/camera.{{trigger.payload_json[''after''][''camera'']
        | lower | replace(''-'',''_'')}}?token={{state_attr( ''camera.'' ~ camera,
        ''access_token'')}}'
      button_1: Aktuelles Bild
      button_3: Keine neue Benachrichtigung

Frigate Config

mqtt:
  enabled: true
  host: *****
  user: *****
  password: *****

# RPI CPU SETTINGS
ffmpeg:
  hwaccel_args: preset-rpi-64-h264

cameras:
  Torkamera:
    ui:
      dashboard: true
    ffmpeg:
      inputs:
        - path: rtsp://*****/Streaming/Channels/102
          roles:
            - detect
        - path: rtsp://*****/Streaming/Channels/101
          roles:
            - record
    detect:
      enabled: True
      width: 640
      height: 480
    record:
      enabled:  true
      retain:
        days: 5
        mode: motion
    snapshots:
      enabled: True
      timestamp: true
      retain:
        default: 5
        mode:  motion
    # mask and zone as manally defined 
    motion:
        mask:
          - 1159,368,1005,697,645,622,821,209
    zones:
      zone_0:
        coordinates: 630,235,576,73,161,183,192,300

birdseye:
  enabled: True
  mode: continuous

Any other relevant information

No response

SgtBatten commented 8 months ago

What format is the video on your record stream? Is it h.265?

osworx commented 8 months ago

It's H.264 (was before H.265 and changed last week after installing Frigate).

Normally all stored videos can be viewed without any problem when using Firefox (one of those browsers which cannot play H.265 encoded videos). So I do not see any reason why those videos are not working ..

And viewing them inside HA or Frigate, everything is working when using Firefox. Don't know what the mobile is using ..

osworx commented 8 months ago

UPDATE: added the (optional) Base URL and now it works (on Android, will check iPhone later and report here again).

The help text should be therefore updated, as it seems without the base url it does not work: The external url for your Home Assistant instance. Recommended for iOS and required for Android/Fire TV.

SgtBatten commented 8 months ago

It should work without the baseurl if it was opening in the app. However this behaviour seems to vary between devices.

Assuming it was opening in a browser I'd be interested in seeing the difference between the urls for the snapshot and the video given only the former worked

osworx commented 7 months ago

After many tests, here are the results (while not every test was successful, sometimes I recieved an 403 error, rarely "Event not found"). As device is used a Android Samsung with Firefox as browser and a iPhone with iOs 17.x.

A. with baseurl: cklicking on the defined action URLs, sometimes the above mentioned errors were displayed. In 90% the action was successful. But when as action a clip was defined, only the first 2 seconds are displayed, rest of video is frozen.

B. without baseurl: actions - view snapshot and stream) are (now) successfully performed (strange, before that did not work). View Clip does not work, it shows only the media player and the seconds how long - but no image (video).

If the baseurl is defined, the browser (here Firefox) on the Android (Samsung) is used, otherwise HA (I guess).

What I really do not understand, is that: Recommended for iOS and required for Android/Fire TV. at the field for the baseurl. I tried it without on both devices, and it worked perfectly! So why for iOS ??

It seems, that these "help" texts should be reworked ..

UPDATE: if one link in the notification (without baseurl) is Live (connected with the livestream - one option in the application) , the link seems to be valid only a few minutes!

grafik

Clicking on it after 10/15 Minutes lead to a 403 Error (forbidden) - therefore not useable.

SgtBatten commented 7 months ago

A. with baseurl: cklicking on the defined action URLs, sometimes the above mentioned errors were displayed. In 90% the action was successful. But when as action a clip was defined, only the first 2 seconds are displayed, rest of video is frozen.

what was the time period of clicking? If you click too fast the clip doesn't exist.

UPDATE: if one link in the notification (without baseurl) is Live (connected with the livestream - one option in the application) , the link seems to be valid only a few minutes!

Correct, the token expires. This nothing to do with the blueprint. Use a different action to open frigate if you need to.

What I really do not understand, is that: Recommended for iOS and required for Android/Fire TV. at the field for the baseurl. I tried it without on both devices, and it worked perfectly!

You have not mentioned using a TV at all do I do not know why you say both devices.

So why for iOS ??

You have one IOS device out of many. Not all behave the same. There have been hundreds of users with issues opening IOS link without Base URL set. It is a recommendation only. If it works for you without it, good.

It seems, that these "help" texts should be reworked ..

Twice you have suggested this without stating what is incorrect about it.

osworx commented 7 months ago

I am coming from the OpenSource scene, working with and for since about more than 20 years. Involved also in some translation projects out of them. When (!!) a help text is given, it should be

a. correct b. helpful

otherwise it leads to questions and irritations resulting in filling forum threads and issuses at Github which could be avoided.

No offending, just my experience from the last years. And I am used to offer my help in this scene - take it or let it .. but I (and I am sure many others) and you don't want to waste time with useless questions and answers and discussions ..