Stream Component: Confirmed Cameras and Configurations

The media player you are trying to stream to does not support the play_media service, which is used by play_stream.

Only confirmed to work on Chromecast and Apple TV.

I followed the guide in the first post, and this is the configuration that works for me. still_image_url points to the camera’s IP address, and stream_source to Unifi Protect’s IP address.

  - platform: generic
    name: Driveway
    still_image_url: https://192.168.5.x/snap.jpeg
    stream_source: rtsp://192.168.1.y:7447/abcdefgh
    verify_ssl: false

The corresponding Lovelace configuration looks like this. The still image updates every 20 seconds, and in full screen mode shows a moving image, but at just about 2 frames/second or so.

- entity: camera.driveway
  type: picture-entity

You may have already noticed that you are not actually watching the RTSP stream in your browser, but HA is proxying the video stream via HTTP. You could check if the proxy URL works in principle - it looks something like this: http://localhost:8123/api/camera_proxy_stream/camera.driveway?token=dce5b.... The full path and token is an attribute of the camera entity.

Hello,
I am using the mijia 1080p camera from this hack https://github.com/Filipowicz251/mijia-1080P-hacks.
If I enable the stream component and try to stream, no video is displayed and HA becomes unresponsive after 10-20 minutes. Without the stream component everything is fine.

Same for me, unresponsive after 10-20min but Whit other cam, so I don’t think it’s The camera

I’ve got a wyze v2 flashed with dafang hacks and it works well, but often it will show old video when I click on it to stream (with preload enabled). if I restart HA it will work again, but after 1 or 2 times trying to access the stream it like stays stuck on the last buffered preload.

It could be a bit off-topic but still related to camera.record which some people might find useful. This is still work in progress as I’m only able to test it remotely at the moment. The following automation is being triggered by hikvision binary sensors (line-crossing) which are set to only trigger once every 15 seconds and shall send a 15 seconds mp4 video clip (with 5 seconds lookback) via telegram bot:

- alias: Captune outdoor movement video
  initial_state: 'on'
  hide_entity: true
  trigger:
    - platform: state
      entity_id:
        - binary_sensor.saturn_nvr_line_crossing_1
        - binary_sensor.saturn_nvr_line_crossing_2
        - binary_sensor.saturn_nvr_line_crossing_3
        - binary_sensor.saturn_nvr_line_crossing_4
        - binary_sensor.saturn_nvr_line_crossing_5
      from: 'off'
      to: 'on'
  condition:
  - condition: state
    entity_id: input_boolean.outdoor_motion_notify_video
    state: 'on'
  action:
    - service: camera.record
      data_template:
        entity_id: "camera.{{ {
          '1' : 'side_passage',
          '2' : 'kitchen_side',
          '3' : 'porch_roof',
          '4' : 'kitchen_roof',
          '5' : 'back_garden'
        }[trigger.entity_id[-1]] }}"
        filename: "/tmp/capture_{{ as_timestamp(trigger.to_state.attributes.last_tripped_time) | int }}_{{ trigger.entity_id[-1] }}.mp4"
        lookback: 5
        duration: 15
    - delay:
        seconds: 20
    - service: telegram_bot.send_video
      data_template:
        target:
          - !secret telegram_chat_id_alexey
          - !secret telegram_chat_id_marina
        file: "/tmp/capture_{{ as_timestamp(trigger.to_state.attributes.last_tripped_time) | int }}_{{ trigger.entity_id[-1] }}.mp4"
        caption: "Movement in {{ trigger.to_state.attributes.friendly_name }}"

I’ve added a 20 seconds delay as a test to allow sufficient time for camera.record to finish writing data to the disk. I’m using last_tripped_time of the binary_sensor to generate unique filename since using now() in two different calls could result in different filenames.

I wish there was a way of knowing if recording has finished.

EDIT: With this approach there are a lot of errors, so so I should probably allow longer delay before attempting to send the video. Unfortunately this would also cause collisions with future automations.

Can't send file with kwargs: {'file': '/tmp/capture_1554820858_5.mp4', 'caption': 'Movement in Back Garden'}

Can't load data into ByteIO: [Errno 2] No such file or directory: '/tmp/capture_1554820858_5.mp4'

EDIT 2: As a dirty workaround one could use a Folder Watcher component to watch for newly created mp4 files and send them via telegram in a separate automation. Perhaps there are better ways of doing it.

4 Likes

I tried this with the last optoin, but when I paste my generic camera entity, it still just shows a still picture and updates after 10 or 15 seconds?

It’s a Sony Android TV with Chromecast built in .

remember the TV has 2 media players, one for the TV itself and the other for the cast device, the sony android tv itself will not play it, you need to use the cast device.

Didn’t know that, I Will try it .
Thank you.

Does lookback recording works for you?

I have a strange behavior on Xiaomi dafang.
I’ve noticed that when I watch the live feed and then I close it, after about 5 minutes HA frontend crash.
Had a look in the log with journalctl and I notice that home assistant crash when it try to stop the rtsp service.
Anyone with the same problem?
Also noticed that if I turn off the rtsp server via the dafang web interface HA return to work normally.

I haven’t tried yet.

Yes, I have been experiencing some crashes, and just figured out it was instigated after atempting to watch live stream of my wyze with dafang installed.

some of us had seen some freezing and documented it here, you guys shoudl do the same: https://github.com/home-assistant/home-assistant/issues/22840

I apologize for asking this if it was answered elsewhere. Are people still having issues with the stream not working in a browser or the iOS app? I see others with hikvision cameras on here, and I know others had reported issues when this component first came out, but have not seen much since.

my rtsp streams work in vlc, and when casted. The stream does not work in any browser, either in the HA URL, or even posting the rtsp stream in the address bar. Pasting in the address bar has never worked though, so maybe there is something else that needs to be done for this? browser plugin?

@ptdalen do you see any errors in the logs when you do that? Can you try adding ?latest to your HA url and loading that and trying again to see if the stream loads in HA?

Thank you @exxamalte!

Cheers for the pointer to the API URL - I checked it out, and it’s still showing a very high resolution snapshot. My picture entity configured as yours is (and mine above) definitely isn’t reading from the unifi stream - and it’s pretty easy to tell as these are the 4k Unifi cameras, as I’ve configured the low resolution RTSP stream for HA - which I can see in VLC is very “poor”.

The card above shows a full screen - very high resolution image - updating every second (ish).

Are you sure you’re not seeing a snapshot every second in the web browser? Do you know of a way to confirm via logs that it’s trying the RTSP stream? (visually it’s not…)

I went into the app to see if I could generate some errors, and low and behold it did come up (it took more than a minute). I’ll play around with the preload stream, and I’ll see if it works in a browser with patience.

Works like a charm.

Thank you very much.