本帖最后由 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
|