Stream Component: Confirmed Cameras and Configurations

I can’t tell you for sure how it works for your device(camera). It’s not related to homeassistant configuration. For example if I am using Hikvision device the first and second stream have different url’s. There is a big url’s resource on ispyconnect.com.
rtsp://testuser:[email protected]/videoMain
rtsp://testuser:[email protected]/videoSub
rtsp://testuser:[email protected]/audio
double check your port settings

Thanks so much your reply, i can watch rtsp in VLC. I have xiaomi Yi camera too can watch via rtsp in VLC. But in stream it not work.

Hello @rafaborges sorry no I have not had any further luck yet with getting it working. I was hoping that @hunterjm had some feedback but I know he is very busy currently. Not sure if its a codec issue because VLC reports its h.264 and have tried ti change some of the setting in the camera but nothing still. I don’t have any other IP cameras to test with but might try to pul the streams from the NVR and not the camera driect but just have not had time yet. Let me know if you find anything.

AT&T/Sercomm oc432

  - platform: generic
    still_image_url: http://CAMERA_IP/img/snapshot.cgi?size=3
    stream_source: rtsp://CAMERA_IP/img/media.sav
    name: Camera 1 #OC432
1 Like

Wow, nice, this would deserve a thread of its own!

I got it working on my one camera setup.

Now - if it only would be possible to delete the file from the disk after it has been sent to Telegram?
Actually, this could be done with a shell script to delete all .mp4 files from the same directory - only thing I’m not so sure is that how can I make sure that the file isn’t deleted until the file has really been sent to Telegram - maybe a daily automation to remove files dated older than xx ?

@salle I’ve actually managed to sort out the matter of delay by using Folder Watcher:

Setup File Watcher in configuration.yaml:

folder_watcher:
  - folder: /tmp
    patterns:
      - '*.mp4'

Automations:

- alias: Capture 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_saturn_{{ as_timestamp(now()) | int }}_{{ trigger.entity_id[-1] }}.mp4"
        lookback: 5
        duration: 15

- alias: Send outdoor movement video via Telegram
  initial_state: 'on'
  hide_entity: true
  trigger:
    platform: event
    event_type: folder_watcher
    event_data:
      event_type: created
  condition:
    - condition: template
      value_template: "{{ trigger.event.data.file.startswith('capture_saturn_') }}"
  action:
    - service: telegram_bot.send_video
      data_template:
        target:
          - !secret telegram_chat_id_alexey
          - !secret telegram_chat_id_marina
        file: "{{ trigger.event.data.path }}"
        caption: "Movement in {{ state_attr('binary_sensor.saturn_nvr_line_crossing_' + trigger.event.data.file[-5:-4], 'friendly_name') }}"

You could use tmpreaper to clean up /tmp directory of the old files. If you are using Ubuntu/Debian:

apt-get install tmpreaper
nano /etc/tmpreaper.conf

Tweak the config to meat your needs.

EDIT: You could actually call a shell script in the second automation to delete the file if you wish.

1 Like

How do you watch via rtsp on a yi camera? And which one you have?
Thanks!

Using folder watcher didn’t resolve the delay issue for me. I have 10 seconds lookback and 10 seconds duration - the folder watcher will trigger the upload before the recording is complete, so it will send only a few seconds strip from the 20 second video.

I tried adding a 5 second delay to the folder watcher automation, but received the following error way too often:
Error sending file: urllib3 HTTPError (‘Connection aborted.’, timeout(‘The write operation timed out’)).

Increasing the delay to 15 seconds helped with this.

Use this guide

Thanks!
I found out another one which looks to be under heavy development:

https://github.com/TheCrypt0/yi-hack-v4

Please help my foscam R2, can not watch stream in Hass. I can want rtsp via VLC.

The recording is not exact length since we are not transcoding the video. It’s more of a suggestion.

I hope I understood what you just said, correctly - but I meant that if I received a ~4 second video in Telegram, the video file itself was around 20 seconds long when opened afterwards

reply here to make a bookmark.

I have same issue and try to figure out in couple months but no luck

@hoatienii
Check if this works for you. Earlier from the chain:

Opticam i4 v2 camera confirmed to work in lovelace. RTSP need to be activated separately in the camera settings.

  - platform: foscam
    ip: 192.168.x.x
    username: user
    password: password
    rtsp_port: 554 (might depend on camera)

I have the same thing happening but in a different camera. Have you managed to find out the culprit?

Hi all,
@BlinkyLights I have the same experience as you. Beside that I want to add that the streaming on Chromecast does not work. There is no error, everything starts as it should, but I don’t see anything. I can see that something is trying to cast(black screen with the cast logo), but it will stay like that a few minutes after which the screensaver of the Chromecast will start. :confused:

@anyone is there a way to revert to the old habit? I liked the old way, the “slideshow” way with the refresh in 10s. I like the idea with the Cromecast :+1: but in my frontend I would like the old way.

Thank you

As much as I like being able to cast to my Apple TVs I think I am going to have to turn stream off… Even the 15s delay is annoying my wife to no end, the delay would need to be more like 5 seconds to be acceptable for “EVENTS”.

I have been keeping track of doorbell rings lately and checking the push notification with video feed is mostly useless we can walk to the door and see who it is before the video catches up to show us and delivery people will not even hang around 15s to confirm you are there to sign a package.

I would love to turn it on selectively but it appears that all cameras that support stream use it if available? Is that correct? Is it possible to selectively enable?

Yes, I have the same impression it’s “default all”. I give a +1 for selective enable, I would use this for 1 or 2 camera max, the rest should not be involved.

Btw, I had in my configuration a mjpeg camera. This is an old android device, which was configured mainly for testing. The device was off, but the configuration in hass was still on. Each time I wanted to start the stream(with different cameras, none with the entity of the mjpeg camera), all the streams were routed to the mjpeg camera. In the logs I was able to see an error: No route to host. This is strange, maybe a case for developers.
I had to remove the configuration of the mjpeg to use the other cameras.(And now it is as described in my previous post)

Q-See 958 HD Analog 8 camera DVR

It’s an 8 camera, 720P BNC connector style DVR with a 1TB hard drive, with software that’s kind of OK and has terribly hard to use search features. It’s got an ethernet jack on the back, and the firmware was last updated in 2016. There are plenty of these things out there, and putting them on HASS and off the internet adds a lot more useful life and increases security.

The online resources and documentation that ARE out there, the iSpy resources, and Q-see documentation are typically hard to find, wrong, or nonexistent. It’s an uphill battle to get one dumb URL. For example, no channel number in the ispy resources for the JPEG stream, but some fudging revealed the true URL format. Also to note, the channel numbers for the RTSP stream start at 1, but the HTTP JPEG stream start at 0 - The authbasic=YWRtaW46YWRtaW4= is a base64 incarnation of the login:password, admin:admin which is default for these highly suspect and probably malware and backdoor laden devices. I converted the plain text at https://base64encode.org which seems to work fine. I never changed the default password because the DVR isn’t on the internet. Note that the RTSP port is 554, the default, but necessarily called out, and the HTTP JPEG port is 85. I may have changed that, check your DVR settings to be sure, yours might be 80 or 88 or 8080 or whatever.

Here’s my cameras.yaml, just the first two cameras for the sake of space

#########################################################################
#  Cameras
#########################################################################


#Nobody told us we had to put the stream component in there, but we do. 
stream:

# Do some cameras
camera:
  - platform: generic
    name: Back Garden
    stream_source: rtsp://10.44.63.206:554/cam/realmonitor?channel=1&subtype=00&authbasic=YWRtaW46YWRtaW4=
    still_image_url: http://10.44.63.206:85/cgi-bin/snapshot.cgi?channel=0&u=admin&p=admin


  - platform: generic
    name: Front Gate
    stream_source: rtsp://10.44.63.206:554/cam/realmonitor?channel=2&subtype=00&authbasic=YWRtaW46YWRtaW4=
    still_image_url: http://10.44.63.206:85/cgi-bin/snapshot.cgi?channel=1&u=admin&p=admin

If I did NOT include the stream: component in camera.yaml or configuration.yaml, the cameras would show up in STATES and show as being idle, but would not stream any images or video. Just a blank gray rectangle that looked like a text box, with no errors in any log files that I could see.

So there you have it. I also got these cameras working in Motion / MotionEye, and you can test your own URLS the standard way - HTTP jpegs in a browser, and RTSP in VLC media player. It’s faster than rebooting HASS over and over and over and over while you tweak everything.

1 Like