『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 19131|回复: 36

[经验分享] 让你的小方/大方摄像头在HA里彻底不卡

[复制链接]

39

主题

2049

帖子

7693

积分

元老级技术达人

积分
7693
金钱
5629
HASS币
110
发表于 2019-3-24 14:58:47 | 显示全部楼层 |阅读模式
之前有个帖[经验分享] 让你的小方/大方摄像头在HA里不那么卡

分享了另一种大方接入HA的方法(一共两种)
两种我都试了,最好的效果也就是1秒1~2帧的样子
升级HA到0.90,多了一种流的接入方式,这下可以不卡看视频了!

stream:
camera:
  - platform: generic
    name: DaFang3
    username: root
    password: ismart12
    authentication: basic
    still_image_url: https://dafangIP/cgi-bin/currentpic.cgi
    verify_ssl: false
    stream_source: rtsp://dafangIP:8554/unicast


这次是真·视频 不卡了~
另外提供了新的服务可以调用
捕获.PNG

附上官方调用效果

评分

参与人数 2金钱 +40 收起 理由
flashsoft + 20 厉害了word楼主!
+ 20 纳尼,还有这种操作?

查看全部评分

回复

使用道具 举报

21

主题

188

帖子

1481

积分

金牌会员

Rank: 6Rank: 6

积分
1481
金钱
1288
HASS币
60
发表于 2019-4-15 05:51:57 | 显示全部楼层
本帖最后由 chiunownow 于 2019-4-15 05:55 编辑

感谢,已经用上了。附上一段我的摄像头额外配置,算是做一点小参考

timer:
  motion_record_disable:
    duration: '00:00:30'

shell_command:
  rclone_sync_dafang_onedrive: rclone sync /home/chiunownow/DCIM/ dafang-onedriveAFANG-CAM

group:
  motion_record:
    name: 动作记录
    icon: mdi:camera-enhance
    entities:
      - automation.motion_record_20s
      - automation.motion_snapshot

automation:
  - alias: motion_record_20s
    trigger:
      entity_id: binary_sensor.dafang_motion_sensor
      platform: state
      from: 'off'
      to: 'on'
    condition:
      - condition: state
        entity_id: timer.motion_record_disable
        state: 'idle'
    action:
      - service: script.toggle
        entity_id: script.motion_record_v2
      - delay: 00:00:40
      - service: shell_command.rclone_sync_dafang_onedrive

  - alias: motion_snapshot
    trigger:
      entity_id: binary_sensor.dafang_motion_sensor
      platform: state
      from: 'off'
      to: 'on'
    action:
      - service: timer.start
        entity_id: timer.motion_record_disable
      - service: camera.snapshot
        data:
          entity_id: camera.dafangcgi
          filename: "/home/chiunownow/DCIM/Picture/{{ now().strftime('%y%m%d-%H%M%S') }}.jpg"

  - alias: turn_on_motion_record
    trigger:
      entity_id: group.device_tracker
      platform: state
      from: 'home'
      to: 'not_home'
      for: 
        minutes: 5
    action:
      - service: homeassistant.turn_on
        entity_id: group.motion_record
      - data:
          message: 监测到屋主不在家,打开动作记录
        service: notify.ios_nownows_iphone

  - alias: turn_off_motion_record
    trigger:
      entity_id: group.device_tracker
      platform: state
      from: 'not_home'
      to: 'home'
    action:
      - service: homeassistant.turn_off
        entity_id: group.motion_record
      - data:
          message: 监测到屋主到家,关闭动作记录
        service: notify.ios_nownows_iphone

script:
  motion_record_v2:
    sequence:
      - service: camera.record
        data_template:
          entity_id: camera.dafang3
          filename: "/home/chiunownow/DCIM/Video/{{ now().strftime('%y%m%d-%H%M%S') }}.mp4"
          duration: "20"
          lookback: "10"

ha监测到大方的动作传感器off-on时,录视频+快照,通过 rclone 同步到 OneDrive,再用 ifttt 监测 OneDrive 的图片和视频文件夹,新增文件时推送到 telegram

回复

使用道具 举报

26

主题

2096

帖子

8510

积分

论坛元老

Rank: 8Rank: 8

积分
8510
金钱
6409
HASS币
30

论坛元老

发表于 2019-3-24 17:54:42 | 显示全部楼层
要不要说明一哈跟以前的方法的区别
回复

使用道具 举报

123

主题

4626

帖子

1万

积分

管理员

囧死

Rank: 9Rank: 9Rank: 9

积分
16015
金钱
11304
HASS币
45
发表于 2019-3-24 18:50:10 | 显示全部楼层
同问,原来怎么接的,好像是rtsp接的
回复

使用道具 举报

2

主题

291

帖子

1502

积分

论坛积极会员

积分
1502
金钱
1211
HASS币
0
发表于 2019-3-24 19:09:05 | 显示全部楼层
终于等到不卡了,以前真的惨不忍睹。
回复

使用道具 举报

7

主题

1975

帖子

5663

积分

论坛元老

流水无味

Rank: 8Rank: 8

积分
5663
金钱
3688
HASS币
145

灌水之王

发表于 2019-3-24 20:15:22 | 显示全部楼层
静待新玩法! 唯一遗憾是家里有只小兴看看  不能rtsp
回复

使用道具 举报

5

主题

89

帖子

461

积分

中级会员

Rank: 3Rank: 3

积分
461
金钱
372
HASS币
0
发表于 2019-3-24 21:31:21 | 显示全部楼层
是不是只有升级到0.90才能使用这个方法啊!
回复

使用道具 举报

8

主题

863

帖子

5126

积分

论坛元老

Rank: 8Rank: 8

积分
5126
金钱
4263
HASS币
0
发表于 2019-3-24 21:39:55 | 显示全部楼层
本帖最后由 新生活 于 2019-3-24 21:41 编辑

这么好,赞请问ffmpeg的rtsp可以这样使用吗?
回复

使用道具 举报

39

主题

2049

帖子

7693

积分

元老级技术达人

积分
7693
金钱
5629
HASS币
110
 楼主| 发表于 2019-3-25 08:49:15 | 显示全部楼层
情非殇 发表于 2019-3-24 17:54
要不要说明一哈跟以前的方法的区别

camera:

- platform: ffmpeg
  name: DaFang3
  input: -rtsp_transport tcp -i rtsp://dafang:8554/unicast

  - platform: generic
    name: DaFang3
    username: root
    password: ismart12
    authentication: basic
    still_image_url: https://dafang/cgi-bin/currentpic.cgi
    verify_ssl: false
    scan_interval: 5


第一种貌似是把视频通过ffmpeg转成图片显示出来,目测1~2帧/秒
第二种是大方自己提供的图,更新周期大概也是每秒1~2帧,并且这种方式对大方资源消耗更少(可能对HA的宿主机也好一点,毕竟不用转图了)
现在的话在缩略图下还是更新的慢,大概几秒一图
但是点进去就直接调用视频流了
回复

使用道具 举报

39

主题

2049

帖子

7693

积分

元老级技术达人

积分
7693
金钱
5629
HASS币
110
 楼主| 发表于 2019-3-25 08:50:35 | 显示全部楼层
tom663 发表于 2019-3-24 21:31
是不是只有升级到0.90才能使用这个方法啊!

是的,这个版本之后 0.90.1也可
从0.90版本加入的新特性
回复

使用道具 举报

39

主题

2049

帖子

7693

积分

元老级技术达人

积分
7693
金钱
5629
HASS币
110
 楼主| 发表于 2019-3-25 08:52:57 | 显示全部楼层
新生活 发表于 2019-3-24 21:39
这么好,赞请问ffmpeg的rtsp可以这样使用吗?

每太理解你的需求
0.90加入的这个特性,支持通用摄像头,只要有rtsp应该就可以
注意是- platform: generic不是- platform: ffmpeg
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-4-27 03:46 , Processed in 0.062775 second(s), 39 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表