From 9dca6af9e7311543b431ce35813b612323ff55f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Sun, 13 Jan 2019 01:12:11 +0100 Subject: [PATCH] lovelace - Camera card for baby monitor --- lovelace/cameras/barnrum.yaml | 63 +++++++++++++++++++++++++++++++++++ lovelace/main.yaml | 1 + packages/camera_ptz.yaml | 26 --------------- packages/cameras.yaml | 56 ++++++++++++------------------- 4 files changed, 86 insertions(+), 60 deletions(-) create mode 100644 lovelace/cameras/barnrum.yaml delete mode 100644 packages/camera_ptz.yaml diff --git a/lovelace/cameras/barnrum.yaml b/lovelace/cameras/barnrum.yaml new file mode 100644 index 0000000..1da81a0 --- /dev/null +++ b/lovelace/cameras/barnrum.yaml @@ -0,0 +1,63 @@ +{% set entity='"camera.barnrum"' %} +type: picture-elements +image: /local/images/placeholder-1280x720.png +elements: + - type: image + camera_image: {{ entity }} + style: + left: 50% + top: 50% + height: 100% + width: 100% + + - type: icon + icon: mdi:chevron-left + tap_action: + action: call-service + service: script.camera_ptz + service_data: + entity_id: {{ entity }} + dir: left + style: + left: 10% + top: 50% + color: yellow + + - type: icon + icon: mdi:chevron-right + tap_action: + action: call-service + service: script.camera_ptz + service_data: + entity_id: {{ entity }} + dir: right + style: + left: 90% + top: 50% + color: yellow + + - type: icon + icon: mdi:chevron-up + tap_action: + action: call-service + service: script.camera_ptz + service_data: + entity_id: {{ entity }} + dir: up + style: + left: 50% + top: 10% + color: yellow + + - type: icon + icon: mdi:chevron-down + tap_action: + action: call-service + service: script.camera_ptz + service_data: + entity_id: {{ entity }} + dir: down + style: + left: 50% + top: 90% + color: yellow diff --git a/lovelace/main.yaml b/lovelace/main.yaml index 13b325f..772f05b 100644 --- a/lovelace/main.yaml +++ b/lovelace/main.yaml @@ -13,6 +13,7 @@ views: cards: - !include floorplan.yaml - !include coffee_card.yaml + - !include cameras/barnrum.yaml {{ dev_card }} - title: Floorplan diff --git a/packages/camera_ptz.yaml b/packages/camera_ptz.yaml deleted file mode 100644 index b63597c..0000000 --- a/packages/camera_ptz.yaml +++ /dev/null @@ -1,26 +0,0 @@ -homeassistant: - customize: - script.camera_ptz: - package: "camera_ptz" - -# TODO: Merge into cameras.yaml - -# Script to step an onvif camera in the given direction. -# Parameters: -# entity_id - camera entity -# dir - direction (left, right, up, down) -script: - camera_ptz: - sequence: - - service: camera.onvif_ptz - data_template: - entity_id: "{{ entity_id }}" - pan: > - {{ {"left":"LEFT", "right":"RIGHT", "up":"NONE", "down":"NONE"}[dir] }} - tilt: > - {{ {"left":"NONE", "right":"NONE", "up":"UP", "down":"DOWN"}[dir] }} - - delay: - milliseconds: 100 - - service: camera.onvif_ptz - data_template: - entity_id: "{{ entity_id }}" diff --git a/packages/cameras.yaml b/packages/cameras.yaml index bbed35d..412e035 100644 --- a/packages/cameras.yaml +++ b/packages/cameras.yaml @@ -28,6 +28,9 @@ homeassistant: hidden: true icon: mdi:chevron-down + script.camera_ptz: + <<: *common + ffmpeg: camera: @@ -52,37 +55,22 @@ camera: username: !secret camera_barnrum_username password: !secret camera_barnrum_password -# TODO: Move this to frontend -switch: - - platform: template - switches: - barnrum_ptz_left: - <<: &ptz_switch - value_template: "{{ True }}" - turn_on: - turn_off: - - service: script.camera_ptz - data: - entity_id: camera.barnrum - dir: left - barnrum_ptz_right: - <<: *ptz_switch - turn_off: - - service: script.camera_ptz - data: - entity_id: camera.barnrum - dir: right - barnrum_ptz_up: - <<: *ptz_switch - turn_off: - - service: script.camera_ptz - data: - entity_id: camera.barnrum - dir: up - barnrum_ptz_down: - <<: *ptz_switch - turn_off: - - service: script.camera_ptz - data: - entity_id: camera.barnrum - dir: down +# Script to step an onvif camera in the given direction. +# Parameters: +# entity_id - camera entity +# dir - direction (left, right, up, down) +script: + camera_ptz: + sequence: + - service: camera.onvif_ptz + data_template: + entity_id: "{{ entity_id }}" + pan: > + {{ {"left":"LEFT", "right":"RIGHT", "up":"NONE", "down":"NONE"}[dir] }} + tilt: > + {{ {"left":"NONE", "right":"NONE", "up":"UP", "down":"DOWN"}[dir] }} + - delay: + milliseconds: 100 + - service: camera.onvif_ptz + data_template: + entity_id: "{{ entity_id }}"