From d182a84464bd94c8c9278ce833875cf4a7889456 Mon Sep 17 00:00:00 2001 From: Georgi Gardev Date: Wed, 26 May 2021 11:01:23 +0300 Subject: [PATCH] Automate bedroom camera --- .../home_dashboard/bedroom_dashboard.yaml | 6 +-- .../home_dashboard/main_dashboard.yaml | 2 +- config/lovelace/popup_cards.yaml | 8 +++ config/packages/devices/bedroom/tapo.yaml | 51 +++++++++++++++++++ config/packages/routines/coming_home.yaml | 2 + config/packages/routines/leaving_home.yaml | 2 + 6 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 config/packages/devices/bedroom/tapo.yaml diff --git a/config/lovelace/home_dashboard/bedroom_dashboard.yaml b/config/lovelace/home_dashboard/bedroom_dashboard.yaml index ba1ba78..403c7ad 100644 --- a/config/lovelace/home_dashboard/bedroom_dashboard.yaml +++ b/config/lovelace/home_dashboard/bedroom_dashboard.yaml @@ -157,9 +157,9 @@ title: Camera cards: - type: picture-glance - camera_image: camera.mercury_bedroom - entities: [] - + camera_image: camera.bedroom_hd + entities: + - switch.tapo_bedroom - type: vertical-stack title: Sensors diff --git a/config/lovelace/home_dashboard/main_dashboard.yaml b/config/lovelace/home_dashboard/main_dashboard.yaml index 548b632..a0c7237 100644 --- a/config/lovelace/home_dashboard/main_dashboard.yaml +++ b/config/lovelace/home_dashboard/main_dashboard.yaml @@ -157,7 +157,7 @@ name: Living Room - type: custom:button-card template: default - entity: camera.mercury_bedroom + entity: switch.tapo_bedroom name: Bedroom - type: custom:button-card template: [default, with_state_indicator] diff --git a/config/lovelace/popup_cards.yaml b/config/lovelace/popup_cards.yaml index a5586e3..66a4bdc 100644 --- a/config/lovelace/popup_cards.yaml +++ b/config/lovelace/popup_cards.yaml @@ -480,3 +480,11 @@ vacuum.vacuum: entity: vacuum.vacuum camera_calibration: true map_camera: camera.xiaomi_cloud_map_extractor + +switch.tapo_bedroom: + title: "Bedroom Camera" + card: + type: picture-glance + camera_image: camera.bedroom_hd + entities: + - switch.tapo_bedroom diff --git a/config/packages/devices/bedroom/tapo.yaml b/config/packages/devices/bedroom/tapo.yaml new file mode 100644 index 0000000..c8c37d0 --- /dev/null +++ b/config/packages/devices/bedroom/tapo.yaml @@ -0,0 +1,51 @@ +switch: + - platform: template + switches: + tapo_bedroom: + friendly_name: "Bedroom Camera" + value_template: "{{ state_attr('camera.bedroom_hd', 'privacy_mode') == 'off' }}" + turn_on: + service: script.tapo_bedroom_on + turn_off: + service: script.tapo_bedroom_off + icon_template: > + {%if state_attr('camera.bedroom_hd', 'privacy_mode') %} + mdi:video + {% else %} + mdi:video-off + {% endif %} + +script: + tapo_bedroom_toggle: + sequence: + - choose: + - conditions: + - condition: template + value_template: "{{ state_attr('camera.bedroom_hd', 'privacy_mode') == 'off' }}" + sequence: + - service: script.tapo_bedroom_off + + default: + - service: script.tapo_bedroom_on + + tapo_bedroom_on: + sequence: + - service: tapo_control.set_privacy_mode + entity_id: camera.bedroom_hd + data: + privacy_mode: "off" + - service: tapo_control.ptz + entity_id: camera.bedroom_hd + data: + preset: "live" + + tapo_bedroom_off: + sequence: + - service: tapo_control.ptz + entity_id: camera.bedroom_hd + data: + preset: "off" + - service: tapo_control.set_privacy_mode + entity_id: camera.bedroom_hd + data: + privacy_mode: "on" diff --git a/config/packages/routines/coming_home.yaml b/config/packages/routines/coming_home.yaml index 31d4e22..32dee17 100644 --- a/config/packages/routines/coming_home.yaml +++ b/config/packages/routines/coming_home.yaml @@ -29,6 +29,8 @@ script: # Cameras - service: switch.turn_on entity_id: switch.mercury_home_mode + - service: switch.turn_off + entity_id: switch.tapo_bedroom - service: script.routine_coming_home_during_daytime - service: script.routine_coming_home_after_sunset diff --git a/config/packages/routines/leaving_home.yaml b/config/packages/routines/leaving_home.yaml index 787e725..d4ada99 100644 --- a/config/packages/routines/leaving_home.yaml +++ b/config/packages/routines/leaving_home.yaml @@ -4,6 +4,8 @@ script: sequence: - service: switch.turn_off entity_id: switch.mercury_home_mode + - service: switch.turn_on + entity_id: switch.tapo_bedroom - service: homeassistant.turn_off entity_id: