lovelace - Camera card for baby monitor

This commit is contained in:
Thomas Lovén 2019-01-13 01:12:11 +01:00
parent 68d533bd1c
commit 9dca6af9e7
4 changed files with 86 additions and 60 deletions

View File

@ -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

View File

@ -13,6 +13,7 @@ views:
cards: cards:
- !include floorplan.yaml - !include floorplan.yaml
- !include coffee_card.yaml - !include coffee_card.yaml
- !include cameras/barnrum.yaml
{{ dev_card }} {{ dev_card }}
- title: Floorplan - title: Floorplan

View File

@ -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 }}"

View File

@ -28,6 +28,9 @@ homeassistant:
hidden: true hidden: true
icon: mdi:chevron-down icon: mdi:chevron-down
script.camera_ptz:
<<: *common
ffmpeg: ffmpeg:
camera: camera:
@ -52,37 +55,22 @@ camera:
username: !secret camera_barnrum_username username: !secret camera_barnrum_username
password: !secret camera_barnrum_password password: !secret camera_barnrum_password
# TODO: Move this to frontend # Script to step an onvif camera in the given direction.
switch: # Parameters:
- platform: template # entity_id - camera entity
switches: # dir - direction (left, right, up, down)
barnrum_ptz_left: script:
<<: &ptz_switch camera_ptz:
value_template: "{{ True }}" sequence:
turn_on: - service: camera.onvif_ptz
turn_off: data_template:
- service: script.camera_ptz entity_id: "{{ entity_id }}"
data: pan: >
entity_id: camera.barnrum {{ {"left":"LEFT", "right":"RIGHT", "up":"NONE", "down":"NONE"}[dir] }}
dir: left tilt: >
barnrum_ptz_right: {{ {"left":"NONE", "right":"NONE", "up":"UP", "down":"DOWN"}[dir] }}
<<: *ptz_switch - delay:
turn_off: milliseconds: 100
- service: script.camera_ptz - service: camera.onvif_ptz
data: data_template:
entity_id: camera.barnrum entity_id: "{{ entity_id }}"
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