diff options
Diffstat (limited to 'blueprints/script')
-rw-r--r-- | blueprints/script/camera/security_camera.yaml | 142 | ||||
-rw-r--r-- | blueprints/script/camera/send_photo.yaml | 37 | ||||
-rw-r--r-- | blueprints/script/devices/aircon.yaml | 135 | ||||
-rw-r--r-- | blueprints/script/devices/kodi-alarm.yaml | 29 | ||||
-rw-r--r-- | blueprints/script/homeassistant/confirmable_notification.yaml | 84 | ||||
-rw-r--r-- | blueprints/script/lights/turn_off_lights.yaml | 32 |
6 files changed, 459 insertions, 0 deletions
diff --git a/blueprints/script/camera/security_camera.yaml b/blueprints/script/camera/security_camera.yaml new file mode 100644 index 0000000..0430266 --- /dev/null +++ b/blueprints/script/camera/security_camera.yaml @@ -0,0 +1,142 @@ +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 diff --git a/blueprints/script/camera/send_photo.yaml b/blueprints/script/camera/send_photo.yaml new file mode 100644 index 0000000..2b14639 --- /dev/null +++ b/blueprints/script/camera/send_photo.yaml @@ -0,0 +1,37 @@ +blueprint: + name: Send Photo + description: Send a single photo from the camera + domain: script + input: + camera: + name: Camera + description: Camera + default: camera.192_168_50_51 + selector: + entity: + domain: camera + 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: '' + +variables: + camera: !input camera + smartpi: !input host + caption: !input caption +# caption: AubergineView +# delay: 5 +# fast_shots: 15 +# fast_delay: 1000 + +mode: single +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") }}' diff --git a/blueprints/script/devices/aircon.yaml b/blueprints/script/devices/aircon.yaml new file mode 100644 index 0000000..b2641be --- /dev/null +++ b/blueprints/script/devices/aircon.yaml @@ -0,0 +1,135 @@ +blueprint: + name: AirCon + description: Stream photos from security camera + domain: script + input: + power: + name: Power + description: Aircon Smart Power Plug + selector: + entity: + domain: switch + temperature: + name: Temperature + description: Temperature sensor + selector: + entity: + domain: sensor + device_class: temperature + cold_temp: + name: Cold Temp + description: Temperature threshold to turn on heating + default: 16 + selector: + number: + min: 8 + max: 20 + unit_of_measurement: C + hot_temp: + name: Hot Temp + description: Temperature threshold to turn on cooling + default: 20 + selector: + number: + min: 20 + max: 36 + unit_of_measurement: C + cool_scene: + name: Cool Scene + description: Cooling scene of Aircon + selector: + entity: + domain: scene + heat_scene: + name: Heat Scene + description: Warming scene of Aircon + selector: + entity: + domain: scene + off_scene: + name: Off Scene + description: Off scene of Aircon + selector: + entity: + domain: scene + confirm: + name: Confirm + description: Confirmation script + default: [] + selector: + action: + +variables: + temp: !input temperature + cold: !input cold_temp + hot: !input hot_temp + +alias: AirCon +sequence: + - if: + - condition: state + entity_id: !input power + state: 'on' + then: + - service: scene.turn_on + target: + entity_id: !input off_scene + - delay: + hours: 0 + minutes: 0 + seconds: 5 + milliseconds: 0 + - service: switch.turn_off + target: + entity_id: !input power + else: + - service: switch.turn_on + target: + entity_id: !input power + - delay: + hours: 0 + minutes: 0 + seconds: 5 + milliseconds: 0 + - choose: + - conditions: + - "{{ states('sensor.bedroom_temp_temperature') | float < cold }}" + sequence: + - service: scene.turn_on + target: + entity_id: !input heat_scene + - conditions: + - "{{ states('sensor.bedroom_temp_temperature') | float > hot }}" + sequence: + - service: scene.turn_on + target: + entity_id: !input cool_scene + default: + - service: switch.turn_off + target: + entity_id: !input power + - service: switch.turn_on + target: + entity_id: !input power + - choose: [] + default: !input "confirm" + +# - if: +# - condition: state +# entity_id: switch.bedroom_aircon +# state: 'off' +# then: +# - service: switch.turn_on +# data: {} +# target: +# entity_id: switch.bedroom_aircon +# - delay: +# hours: 0 +# minutes: 0 +# seconds: 5 +# milliseconds: 0 + - service: scene.turn_on + target: + entity_id: scene.hyundai_aircon_cool_18 + metadata: {} +mode: single diff --git a/blueprints/script/devices/kodi-alarm.yaml b/blueprints/script/devices/kodi-alarm.yaml new file mode 100644 index 0000000..48ecd1c --- /dev/null +++ b/blueprints/script/devices/kodi-alarm.yaml @@ -0,0 +1,29 @@ +blueprint: + name: Kodi - Play Alarm + description: Stream photos from security camera + domain: script + input: + player: + name: Player + description: KoDi Media Player + selector: + entity: + domain: media_player + song: + name: Player + description: KoDi Media Player + selector: + media: {} + +mode: restart +sequence: + - service: media_player.volume_set + data: + volume_level: 1 + target: + entity_id: !input player + - service: media_player.play_media + target: + entity_id: !input player + data: + !input song diff --git a/blueprints/script/homeassistant/confirmable_notification.yaml b/blueprints/script/homeassistant/confirmable_notification.yaml new file mode 100644 index 0000000..d52e5a6 --- /dev/null +++ b/blueprints/script/homeassistant/confirmable_notification.yaml @@ -0,0 +1,84 @@ +blueprint: + name: Confirmable Notification + description: >- + A script that sends an actionable notification with a confirmation before + running the specified action. + domain: script + source_url: https://github.com/home-assistant/core/blob/master/homeassistant/components/script/blueprints/confirmable_notification.yaml + input: + notify_device: + name: Device to notify + description: Device needs to run the official Home Assistant app to receive notifications. + selector: + device: + integration: mobile_app + title: + name: "Title" + description: "The title of the button shown in the notification." + default: "" + selector: + text: + message: + name: "Message" + description: "The message body" + selector: + text: + confirm_text: + name: "Confirmation Text" + description: "Text to show on the confirmation button" + default: "Confirm" + selector: + text: + confirm_action: + name: "Confirmation Action" + description: "Action to run when notification is confirmed" + default: [] + selector: + action: + dismiss_text: + name: "Dismiss Text" + description: "Text to show on the dismiss button" + default: "Dismiss" + selector: + text: + dismiss_action: + name: "Dismiss Action" + description: "Action to run when notification is dismissed" + default: [] + selector: + action: + +mode: restart + +sequence: + - alias: "Set up variables" + variables: + action_confirm: "{{ 'CONFIRM_' ~ context.id }}" + action_dismiss: "{{ 'DISMISS_' ~ context.id }}" + - alias: "Send notification" + domain: mobile_app + type: notify + device_id: !input notify_device + title: !input title + message: !input message + data: + actions: + - action: "{{ action_confirm }}" + title: !input confirm_text + - action: "{{ action_dismiss }}" + title: !input dismiss_text + - alias: "Awaiting response" + wait_for_trigger: + - platform: event + event_type: mobile_app_notification_action + event_data: + action: "{{ action_confirm }}" + - platform: event + event_type: mobile_app_notification_action + event_data: + action: "{{ action_dismiss }}" + - choose: + - conditions: "{{ wait.trigger.event.data.action == action_confirm }}" + sequence: !input confirm_action + - conditions: "{{ wait.trigger.event.data.action == action_dismiss }}" + sequence: !input dismiss_action diff --git a/blueprints/script/lights/turn_off_lights.yaml b/blueprints/script/lights/turn_off_lights.yaml new file mode 100644 index 0000000..e5538b7 --- /dev/null +++ b/blueprints/script/lights/turn_off_lights.yaml @@ -0,0 +1,32 @@ +blueprint: + name: turn_off_lights + description: Turns off a group of lights + domain: script + input: + lights: + name: Affected class of lights + description: "Which class of lights to turn off: all, bedroom, living, hall" + default: "all" + +variables: + name: !input lights + std: "switch.lights_{{ name }}" + manual: "switch.lights_{{ name }}_manual" + + +mode: single + +sequence: + - service: switch.turn_off + target: + entity_id: "{{ std, manual }}" + + - delay: + hours: 0 + minutes: 0 + seconds: 3 + milliseconds: 0 + + - service: switch.turn_on + target: + entity_id: "{{ [ manual ] }}" |