Doorbell video
This commit is contained in:
@@ -47,6 +47,7 @@ class Climate(hass.Hass):
|
||||
self.turn_off("switch.plug_158d00010dd98d")
|
||||
|
||||
def split_on(self, mode, temp):
|
||||
self.split_state = "on"
|
||||
self.turn_on("switch.plug_158d00010dd98d")
|
||||
if (self.timer != None):
|
||||
self.cancel_timer(self.timer)
|
||||
@@ -88,14 +89,12 @@ class Climate(hass.Hass):
|
||||
if nest_y1 == "on":
|
||||
if self.check_door('FAN'):
|
||||
return
|
||||
self.split_state = "on"
|
||||
self.log("Turn on split for COOLING to {}.".format(nest_target_cool))
|
||||
self.split_on("COOLING", 16)
|
||||
|
||||
elif nest_w1 == "on":
|
||||
if self.check_door('OFF'):
|
||||
return
|
||||
self.split_state = "on"
|
||||
self.log("Turn on split for HEATING to {}".format(nest_target_hot))
|
||||
self.split_on("HEATING", 28)
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ class Doorbell(hass.Hass):
|
||||
ringtone = 10
|
||||
gw_mac = ''
|
||||
def initialize(self):
|
||||
if "notify" not in self.args or "sensor" not in self.args:
|
||||
self.error("Please provide notify, sensor in config!")
|
||||
if "notify" not in self.args or "sensor" not in self.args or "camera" not in self.args:
|
||||
self.error("Please provide notify, sensor, camera in config!")
|
||||
return
|
||||
if "gw_mac" in self.args:
|
||||
self.gw_mac = self.args['gw_mac']
|
||||
@@ -36,12 +36,20 @@ class Doorbell(hass.Hass):
|
||||
self.log("doorbell call")
|
||||
self.call_service("xiaomi_aqara/play_ringtone", gw_mac=self.gw_mac, ringtone_id=self.ringtone, ringtone_vol=100)
|
||||
self.notify("Звонок в дверь!!!", name = self.args['notify'])
|
||||
for x in range(3):
|
||||
self.send_image()
|
||||
# for x in range(3):
|
||||
self.send_image()
|
||||
|
||||
def send_video(self):
|
||||
file = '/config/www/doorbell_video.mp4'
|
||||
self.call_service("stream/record", stream_source=self.args['rtsp'], filename=file, duration=10)
|
||||
self.timer = self.run_in(self.run_in_send_video, 12, file=file)
|
||||
|
||||
def run_in_send_video(self, args):
|
||||
extra_data = {'video': {'file': args['file'], 'caption': 'Видео звонившего.'}}
|
||||
self.notify("Видео звонившего", name = self.args['notify'], data=extra_data)
|
||||
|
||||
|
||||
def send_image(self):
|
||||
self.call_service("camera/snapshot", entity_id="camera.enterance", filename="/config/www/camera_image.jpg")
|
||||
self.call_service("camera/snapshot", entity_id=self.args['camera'], filename="/config/www/camera_image.jpg")
|
||||
extra_data = {'photo': {'file':'/config/www/camera_image.jpg', 'capture': 'Фото звонившего.'}}
|
||||
self.notify("Фото звонившего", name = self.args['notify'], data=extra_data)
|
||||
|
||||
self.notify("Видео звонившего", name = self.args['notify'], data=extra_data)
|
||||
|
||||
@@ -5,6 +5,8 @@ doorbell:
|
||||
module: doorbell
|
||||
class: Doorbell
|
||||
sensor: binary_sensor.door_window_sensor_158d0001f34374
|
||||
camera: camera.entrance
|
||||
rtsp: !secret rtsp_entrance
|
||||
notify: telegram
|
||||
gw_mac: !secret aqara1_mac
|
||||
global_dependencies:
|
||||
|
||||
Reference in New Issue
Block a user