From 45d8f9cd5b34a53a392ebbda4f0f2203b8b40540 Mon Sep 17 00:00:00 2001 From: Georgi Gardev Date: Sun, 10 May 2020 01:28:59 +0300 Subject: [PATCH] Add github module --- .../lovelace/advanced_dashboard/00_home.yaml | 8 ++ .../advanced_dashboard/10_system.yaml | 1 + .../home_dashboard/living_room_dashboard.yaml | 1 - config/packages/devices/titanium.yaml | 1 - config/packages/modules/github.yaml | 75 +++++++++++++++++++ .../modules/lighting/setup/groups.yaml | 2 - config/secrets.example.yaml | 2 + 7 files changed, 86 insertions(+), 4 deletions(-) create mode 100644 config/packages/modules/github.yaml diff --git a/config/lovelace/advanced_dashboard/00_home.yaml b/config/lovelace/advanced_dashboard/00_home.yaml index 9b3bb4c..b82ec0f 100644 --- a/config/lovelace/advanced_dashboard/00_home.yaml +++ b/config/lovelace/advanced_dashboard/00_home.yaml @@ -21,6 +21,14 @@ cards: cards: - type: vertical-stack cards: + - type: entities + title: Github + icon: mdi:github-circle + entities: + - entity: sensor.time_picker_card_downloads + icon: mdi:clock + - entity: sensor.folder_card_downloads + icon: mdi:folder - type: entities title: Quarantine icon: mdi:biohazard diff --git a/config/lovelace/advanced_dashboard/10_system.yaml b/config/lovelace/advanced_dashboard/10_system.yaml index e853d13..b4cec94 100644 --- a/config/lovelace/advanced_dashboard/10_system.yaml +++ b/config/lovelace/advanced_dashboard/10_system.yaml @@ -23,6 +23,7 @@ cards: show_header_toggle: false entities: - automation.titanium_turn_off_when_idle + - automation.github_download - type: divider # Presence - type: custom:fold-entity-row diff --git a/config/lovelace/home_dashboard/living_room_dashboard.yaml b/config/lovelace/home_dashboard/living_room_dashboard.yaml index 12e3507..5f87063 100644 --- a/config/lovelace/home_dashboard/living_room_dashboard.yaml +++ b/config/lovelace/home_dashboard/living_room_dashboard.yaml @@ -50,7 +50,6 @@ - height: 46px - - type: horizontal-stack title: Devices cards: diff --git a/config/packages/devices/titanium.yaml b/config/packages/devices/titanium.yaml index 90b8945..240453c 100644 --- a/config/packages/devices/titanium.yaml +++ b/config/packages/devices/titanium.yaml @@ -253,4 +253,3 @@ automation: data: push: thread-id: "titanium" - diff --git a/config/packages/modules/github.yaml b/config/packages/modules/github.yaml new file mode 100644 index 0000000..338c2f9 --- /dev/null +++ b/config/packages/modules/github.yaml @@ -0,0 +1,75 @@ +sensor: + - platform: rest + resource: "https://api.github.com/repos/GeorgeSG/lovelace-time-picker-card/releases/latest" + name: Time Picker Card downloads + value_template: '{{ value_json.assets[0].download_count }}' + scan_interval: 60 + headers: + Authorization: !secret github_access_token + - platform: rest + resource: "https://api.github.com/repos/GeorgeSG/lovelace-folder-card/releases/latest" + name: Folder Card downloads + value_template: '{{ value_json.assets[0].download_count }}' + scan_interval: 60 + headers: + Authorization: !secret github_access_token + + +automation: + - alias: Github Download + trigger: + platform: state + entity_id: + - sensor.time_picker_card_downloads + - sensor.folder_card_downloads + condition: + condition: template + value_template: "{{ not is_state('input_select.house_mode', 'night') }}" + action: + # Stoe powered state + - service: scene.create + data: + scene_id: pre_github_notify_1 + snapshot_entities: + - light.bedside + - light.living_room_ambient_main + - service: light.turn_on + entity_id: + - light.bedside + - light.living_room_ambient_main + + - delay: 00:00:01 + # Store color after power on + - service: scene.create + data: + scene_id: pre_github_notify_2 + snapshot_entities: + - light.bedside + - light.living_room_ambient_main + - service: light.turn_on + entity_id: + - light.bedside + - light.living_room_ambient_main + data: + rgb_color: [0, 255, 63] + + - service: script.say + data_template: + message: >- + + {% if trigger %} + {% set diff = trigger.to_state - trigger.from_state %} + Hey, {% if diff > 1 %}{{diff}} people{% else %}1 person{% endif%} just downloaded + {% if tigger.entity_id == 'sensor.folder_card_downloads' %} folder card + {% elif trigger.entity_id == 'sensor.time_picker_card_downloads' %} time picker card + {% else %} something, but I don't know what. This should never happen! + {% endif %} + {% else %} + Just testing + {% endif %} + + - delay: 00:00:06 + - service: scene.turn_on + entity_id: scene.pre_github_notify_2 + - service: scene.turn_on + entity_id: scene.pre_github_notify_1 diff --git a/config/packages/modules/lighting/setup/groups.yaml b/config/packages/modules/lighting/setup/groups.yaml index ef3cbe9..c1cb944 100644 --- a/config/packages/modules/lighting/setup/groups.yaml +++ b/config/packages/modules/lighting/setup/groups.yaml @@ -185,5 +185,3 @@ homeassistant: friendly_name: Hallway 1 light.light_le_8: friendly_name: Hallway 2 - - diff --git a/config/secrets.example.yaml b/config/secrets.example.yaml index aba58f4..b82a0f3 100644 --- a/config/secrets.example.yaml +++ b/config/secrets.example.yaml @@ -104,3 +104,5 @@ tuya_username: email tuya_password: pass twitch_client_id: client-id + +github_access_token: token