diff --git a/.gitignore b/.gitignore index eb23999..58e042b 100644 --- a/.gitignore +++ b/.gitignore @@ -11,10 +11,12 @@ !/lovelace-views/ !/sensors/ !/www/ +!/scripts/ # "Force" Disallow .storage/ android/ +ssh-key/ ip_bans.yaml secrets.yaml diff --git a/configuration.yaml b/configuration.yaml index eb7370a..a4c644c 100644 --- a/configuration.yaml +++ b/configuration.yaml @@ -182,11 +182,11 @@ binary_sensor: name: Morning after: '05:00' before: '11:00' - - platform: ffmpeg_motion - input: '-rtsp_transport udp -i rtsp://192.168.2.31/ch0_0.h264' - name: camera_home1_motion - changes: 50 - reset: 20 + - platform: ping + name: desktop_ping + host: !secret desktop_ip + count: 2 + scan_interval: 15 weather: - platform: openweathermap @@ -205,8 +205,8 @@ stream: camera: - platform: ffmpeg - name: home1 - input: '-rtsp_transport tcp -i rtsp://192.168.2.31/ch0_0.h264' + name: office + input: !secret office_stream_url input_datetime: bedroom_alarm_clock_time: @@ -214,7 +214,18 @@ input_datetime: has_date: false has_time: true +shell_command: + ssh: 'ssh -o "StrictHostKeyChecking=no" -i {{ sshkey }} {{ host }} -l {{ user }} -p {{ port }} {{ command_or_param }}' + +rest_command: + shinobi_monitorstates: + url: "https://{{ host }}/{{ apikey }}/monitorStates/{{ group }}/{{ preset_name }}" + panel_iframe: + cctv: + title: 'CCTV' + url: !secret url_cctv + icon: mdi:cctv chronograf: title: 'Chronograf' url: !secret url_chronograf @@ -228,7 +239,7 @@ panel_iframe: url: !secret url_esphome icon: mdi:chip -alert: !include_dir_merge_list alerts/ +#alert: !include_dir_merge_list alerts/ alexa: !include alexa.yaml automation: !include_dir_merge_list automations/ #scene: !include scenes.yaml diff --git a/lovelace-views/cctv.yaml b/lovelace-views/cctv.yaml index 9c2d63f..ead70ce 100644 --- a/lovelace-views/cctv.yaml +++ b/lovelace-views/cctv.yaml @@ -1,6 +1,21 @@ icon: mdi:cctv path: cctv cards: - - type: picture-entity - name: Büro - entity: camera.home1 + - type: entities + show_header_toggle: false + entities: + - entity: switch.cctv_active + name: Kameras aktiviert + icon: mdi:power + - entity: switch.cctv_motion_detection + name: Aufnahmen bei Bewegung + icon: mdi:motion-sensor + - type: picture-glance + title: Büro + camera_image: camera.office + camera_view: live + entities: + - entity: switch.cctv_motion_detection + icon: mdi:motion-sensor + - entity: switch.cctv_active + icon: mdi:power diff --git a/lovelace-views/devices.yaml b/lovelace-views/devices.yaml index 40f5ad7..6166d65 100644 --- a/lovelace-views/devices.yaml +++ b/lovelace-views/devices.yaml @@ -26,3 +26,10 @@ cards: - entity: sensor.device_mobile_fb_battery name: Handy-Akku icon: mdi:battery + - type: entities + title: Wake On Lan + show_header_toggle: false + entities: + - entity: switch.desktop_wol + name: Desktop-PC + icon: mdi:desktop-classic diff --git a/scripts.yaml b/scripts.yaml index 87f4821..083bba7 100644 --- a/scripts.yaml +++ b/scripts.yaml @@ -1,3 +1,6 @@ +dummy: + sequence: + ambilight_off: alias: Ambilight schwarz schalten sequence: @@ -76,4 +79,77 @@ livingroom_netflix_on: command: - Ok device: 42849848 #FireTv - delay_secs: 0.6 \ No newline at end of file + delay_secs: 0.6 + +### Harmony Helper-Scripts + +harmony_denon_power: + alias: Denon Power + sequence: + - service: remote.send_command + data: + entity_id: remote.livingroom_harmony + command: + - PowerToggle + device: 42849850 #Denon + +harmony_denon_mute: + alias: Denon Stumm + sequence: + - service: remote.send_command + data: + entity_id: remote.livingroom_harmony + command: + - Mute + device: 42849850 #Denon + +harmony_volume_up: + alias: Denon Lauter + sequence: + - service: remote.send_command + data: + entity_id: remote.livingroom_harmony + command: + - VolumeUp + device: 42849850 #Denon + num_repeats: 5 + +harmony_volume_down: + alias: Denon Leiser + sequence: + - service: remote.send_command + data: + entity_id: remote.livingroom_harmony + command: + - VolumeDown + device: 42849850 #Denon + num_repeats: 5 + +# CCTV + +shinobi_idle: + sequence: + - service: rest_command.shinobi_monitorstates + data: + host: !secret shinobi_host + apikey: !secret shinobi_api_key + group: !secret shinobi_group + preset_name: Inactive (Idle) + +shinobi_active: + sequence: + - service: rest_command.shinobi_monitorstates + data: + host: !secret shinobi_host + apikey: !secret shinobi_api_key + group: !secret shinobi_group + preset_name: Active + Motion Detection OFF + +shinobi_active_with_motion: + sequence: + - service: rest_command.shinobi_monitorstates + data: + host: !secret shinobi_host + apikey: !secret shinobi_api_key + group: !secret shinobi_group + preset_name: Active + Motion Detection ON \ No newline at end of file diff --git a/scripts/install-wakeonlan-sshkey.sh b/scripts/install-wakeonlan-sshkey.sh new file mode 100755 index 0000000..e4ef25d --- /dev/null +++ b/scripts/install-wakeonlan-sshkey.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +DIR=$(dirname "$(readlink -f "$0")") + +KEYFILE="$DIR/../ssh-key/homeassistant-wakeonlan-sshkey" +TARGET="$HOME/.ssh/authorized_keys" + +if [ ! -f $KEYFILE ]; then + echo "You need to create the SSH-Key-File first: \"$KEYFILE\"" + echo "Use: \"ssh-keygen -t ed25519 -C homeassistant-wakeonlan-sshkey -f $KEYFILE\"" + exit 1 +fi + +if ! which wakeonlan > /dev/null; then + echo "You need to install \"wakeonlan\" first. Otherwise the ssh-key will be useless." + exit 1 +fi + +SSHKEY=$(<"$KEYFILE.pub") +echo "command=\"wakeonlan \$SSH_ORIGINAL_COMMAND\" $SSHKEY" >> $TARGET + +echo "Installed the ssh key into \"$TARGET\"." diff --git a/sensors/cctv.yaml b/sensors/cctv.yaml new file mode 100644 index 0000000..fc32519 --- /dev/null +++ b/sensors/cctv.yaml @@ -0,0 +1,8 @@ + - platform: rest + resource: !secret office_details_url + name: Camera Mode Office + value_template: '{{ value_json.mode }}' + - platform: rest + resource: !secret office_details_url + name: Camera Motion Office + value_template: '{{ value_json.details|string|regex_search("\"detector\":\"1\"", ignorecase=FALSE) }}' \ No newline at end of file diff --git a/ssh-key/.gitkeep b/ssh-key/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/switches.yaml b/switches.yaml index 654cc6f..d985905 100644 --- a/switches.yaml +++ b/switches.yaml @@ -1,10 +1,18 @@ -- platform: wake_on_lan - name: Computer - mac_address: "50-E5-49-C4-DF-B4" - host: "192.168.2.168" - - platform: template switches: + desktop_wol: + value_template: "{{ is_state('binary_sensor.desktop_ping', 'on') }}" + turn_on: + service: shell_command.ssh + data: + sshkey: !secret sshkey_wakeonlan + host: !secret nas_ip + user: !secret nas_ssh_user + port: !secret nas_ssh_port + command_or_param: !secret desktop_mac + turn_off: + service: script.dummy + harmony_music_bt: value_template: "{{ is_state_attr('remote.livingroom_harmony', 'current_activity', 'Musik Bluetooth') }}" turn_on: @@ -57,81 +65,34 @@ entity_id: remote.livingroom_harmony activity: 'PowerOff' - harmony_denon_mute: - friendly_name: Denon Stumm - value_template: "{{ state_attr('remote.livingroom_harmony', 'current_activity') != 'PowerOff' }}" - turn_on: - service: remote.send_command - data: - entity_id: remote.livingroom_harmony - command: - - Mute - device: 42849850 #Denon - turn_off: - service: remote.send_command - data: - entity_id: remote.livingroom_harmony - command: - - Mute - device: 42849850 #Denon - harmony_denon_power: friendly_name: Denon Power value_template: "{{ state_attr('remote.livingroom_harmony', 'current_activity') != 'PowerOff' }}" turn_on: - service: remote.send_command - data: - entity_id: remote.livingroom_harmony - command: - - PowerToggle - device: 42849850 #Denon + service: script.harmony_denon_power turn_off: - service: remote.send_command - data: - entity_id: remote.livingroom_harmony - command: - - PowerToggle - device: 42849850 #Denon + service: script.harmony_denon_power - harmony_volume_down: - friendly_name: Denon Leiser + harmony_denon_mute: + friendly_name: Denon Stumm value_template: "{{ state_attr('remote.livingroom_harmony', 'current_activity') != 'PowerOff' }}" turn_on: - service: remote.send_command - data: - entity_id: remote.livingroom_harmony - command: - - VolumeDown - device: 42849850 #Denon - num_repeats: 5 turn_off: - service: remote.send_command - data: - entity_id: remote.livingroom_harmony - command: - - VolumeDown - device: 42849850 #Denon - num_repeats: 5 + service: script.harmony_denon_mute harmony_volume_up: friendly_name: Denon Lauter value_template: "{{ state_attr('remote.livingroom_harmony', 'current_activity') != 'PowerOff' }}" turn_on: - service: remote.send_command - data: - entity_id: remote.livingroom_harmony - command: - - VolumeUp - device: 42849850 #Denon - num_repeats: 5 turn_off: - service: remote.send_command - data: - entity_id: remote.livingroom_harmony - command: - - VolumeUp - device: 42849850 #Denon - num_repeats: 5 + service: script.harmony_volume_up + + harmony_volume_down: + friendly_name: Denon Leiser + value_template: "{{ state_attr('remote.livingroom_harmony', 'current_activity') != 'PowerOff' }}" + turn_on: + turn_off: + service: script.harmony_volume_down livingroom_music: value_template: "{{ is_state_attr('remote.livingroom_harmony', 'current_activity', 'Musik Bluetooth') }}" @@ -148,4 +109,22 @@ service: remote.turn_on data: entity_id: remote.livingroom_harmony - activity: 'PowerOff' \ No newline at end of file + activity: 'PowerOff' + +### CCTV + + cctv_motion_detection: + friendly_name: CCTV Motion Detection + value_template: "{{ (is_state('sensor.camera_mode_office', 'start') or is_state('sensor.camera_mode_office', 'recording')) and is_state('sensor.camera_motion_office', 'True') }}" + turn_on: + service: script.shinobi_active_with_motion + turn_off: + service: script.shinobi_active + + cctv_active: + friendly_name: CCTV Active + value_template: "{{ is_state('sensor.camera_mode_office', 'start') or is_state('sensor.camera_mode_office', 'recording') }}" + turn_on: + service: script.shinobi_active + turn_off: + service: script.shinobi_idle \ No newline at end of file