Skip to content

Instantly share code, notes, and snippets.

@tubalainen
Created February 5, 2020 10:26
Show Gist options
  • Save tubalainen/14d9e1811d851277b4ca699124f0a0a5 to your computer and use it in GitHub Desktop.
Save tubalainen/14d9e1811d851277b4ca699124f0a0a5 to your computer and use it in GitHub Desktop.
Camera Loop (camloop.yaml) package file
### packages/camloop.yaml ###
input_boolean:
loop_the_cameras:
name: Loop The Cameras
initial: off
icon: mdi:camera-burst
# The automation that starts the loop
automation:
- id: 'start_camera_loop'
alias: start camera loop
initial_state: 'on'
trigger:
- platform: state
entity_id: input_boolean.loop_the_cameras
to: 'on'
condition: []
action:
- data:
entity_id: script.cam_main
service: script.turn_on
# The automation that stops the loop
- id: 'stop_camera_loop'
alias: stop camera loop
initial_state: 'on'
trigger:
- platform: state
entity_id: input_boolean.loop_the_cameras
to: 'off'
# Can be stopped by a Philips dimmer remote control as well (Zigbee)
- event_data:
id: dimmer_switch
event: 4002
platform: event
event_type: deconz_event
condition: []
action:
- data:
entity_id: script.cam_main
service: script.turn_off
- data:
entity_id: script.cam_loop
service: script.turn_off
- data:
entity_id: input_boolean.cam_loop
service: input_boolean.turn_off
- delay:
seconds: 1
- data:
entity_id: media_player.gh_hub_kontor
service: media_player.turn_off
# The looping scripts
script:
cam_main:
alias: Loop the cams on Google Hub
sequence:
- data:
entity_id: camera.cam1_uppfart
media_player: media_player.gh_hub_kontor
service: camera.play_stream
- delay:
seconds: 5
- data:
entity_id: camera.cam3_framsidan
media_player: media_player.gh_hub_kontor
service: camera.play_stream
# jump to the script below and restart the sequence
- service: script.turn_on
data:
entity_id: script.cam_loop
# (re)starts the main script
cam_loop:
alias: Camera loop
sequence:
- delay:
seconds: 5
- service: script.turn_on
data:
entity_id: script.cam_main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment