blueprint: name: Security Camera Streamer description: Stream photos from security camera domain: script input: camera: name: Camera description: Camera default: camera.192_168_50_51 selector: entity: domain: camera motion_sensor: name: Motion Sensor description: Sensor detecting if there are motions to trigger the camera selector: entity: domain: binary_sensor device_class: motion host: name: Host description: Host running camera server default: http://127.0.0.1:8123 caption: name: Caption description: Caption to send in telegram message default: 'Intusion Alert: ' lights_on: name: Lights On description: List of lights to turn on default: [] selector: entity: multiple: true domain: [light, switch] lights_off: name: Lights Off description: List of lights to turn off default: [] selector: entity: multiple: true domain: [light, switch] prepare: name: prepare description: Actions to perform before shooting photos default: [] selector: action: delay: name: Delay description: Delay between shots (seconds) default: 5 selector: number: min: 1 max: 3600 unit_of_measurement: s fast_shots: name: Fast Shots description: Number of initial shots with short delay default: 10 selector: number: min: 0 max: 50 fast_delay: name: Fast Delay description: Delay between fast shots (milliseconds) default: 1000 selector: number: min: 100 max: 10000 unit_of_measurement: ms variables: camera: !input camera smartpi: !input host caption: !input caption delay: !input delay fast_shots: !input fast_shots fast_delay: !input fast_delay mode: restart sequence: - parallel: - service: homeassistant.turn_on target: entity_id: !input lights_on - service: homeassistant.turn_off target: entity_id: !input lights_off - choose: [] default: !input "prepare" - sequence: - service: telegram_bot.send_photo data: disable_notification: false caption: '{{ caption }} at {{ states("sensor.date_time_iso") }}' url: '{{ smartpi + state_attr(camera, "entity_picture") }}' - repeat: while: - condition: template value_template: '{{ repeat.index < fast_shots }}' sequence: - service: telegram_bot.send_photo data: disable_notification: true caption: '{{ caption }} {{ repeat.index }} (fast)' url: '{{ smartpi + state_attr(camera, "entity_picture") }}' - delay: hours: 0 minutes: 0 seconds: 0 milliseconds: '{{ fast_delay }}' - repeat: # About 30 seconds delay before occupancy clears (both ways via state or device) until: - condition: state entity_id: !input motion_sensor state: 'off' # for: # seconds: 2 # - type: is_no_motion # condition: device # device_id: 6deb0a6fb7a4a849ba22afc166cf9919 # device_id: '{{ device_id("binary_sensor.0x00158d0004485e0b_occupancy") }}' # entity_id: binary_sensor.0x00158d0004485e0b_occupancy # domain: binary_sensor sequence: - service: telegram_bot.send_photo data: disable_notification: true caption: '{{ caption }} {{ repeat.index + fast_shots - 1 }}' url: '{{ smartpi + state_attr(camera, "entity_picture") }}' - delay: hours: 0 minutes: 0 seconds: '{{ delay }}' milliseconds: 0