From 7be90e411e666a4502f5a34f4f383aa70386785a Mon Sep 17 00:00:00 2001 From: 31c0fe9c6dbd74bcdde92e1d2aaa03e1d272f75f Date: Thu, 12 May 2022 13:08:48 +1000 Subject: [PATCH] Home Assistant Git Exporter --- addons/243ffc37_git-exporter.yaml | 6 +-- config/packages/export.yaml | 4 +- config/packages/media_centre.yaml | 2 +- config/packages/presence.yaml | 63 +++++++++++++++++++++------- lovelace/lovelace.bos_office.yaml | 3 +- lovelace/lovelace.lovelace_shed.yaml | 3 -- lovelace/lovelace_dashboards.yaml | 7 ---- 7 files changed, 55 insertions(+), 33 deletions(-) delete mode 100644 lovelace/lovelace.lovelace_shed.yaml diff --git a/addons/243ffc37_git-exporter.yaml b/addons/243ffc37_git-exporter.yaml index b636e35..adbe685 100644 --- a/addons/243ffc37_git-exporter.yaml +++ b/addons/243ffc37_git-exporter.yaml @@ -1,7 +1,7 @@ check: check_for_ips: false check_for_secrets: true - enabled: false + enabled: true dry_run: false exclude: - '*.db' @@ -38,7 +38,7 @@ export: repository: branch_name: main commit_message: Home Assistant Git Exporter - password: '!secret git_export_password' + password: '!secret git_export_token' pull_before_push: true url: '!secret git_export_url' - username: '!secret git_export_password' + username: '!secret git_export_token' diff --git a/config/packages/export.yaml b/config/packages/export.yaml index fe5c3b9..e154fd0 100644 --- a/config/packages/export.yaml +++ b/config/packages/export.yaml @@ -2,10 +2,10 @@ automation: - id: f0ca9ef44d3b606864eea88a4704baf60d33614b alias: Export HA config to git repo trigger: + # every hour, but not on the hour - platform: time_pattern - hours: "*" minutes: 25 action: - service: hassio.addon_start data: - addon: "core_letsencrypt" + addon: "243ffc37_git-exporter" diff --git a/config/packages/media_centre.yaml b/config/packages/media_centre.yaml index c84645e..53a1764 100644 --- a/config/packages/media_centre.yaml +++ b/config/packages/media_centre.yaml @@ -339,7 +339,7 @@ sensor: events: - state: ABC Jazz (Jazz Music) # Default background music start: "8:00:00" - end: "23:00:00" + end: "21:00:00" - state: Triple R 102.7 (Variety) # https://www.rrr.org.au/explore/programs/radiotherapy start: "10:00:00" diff --git a/config/packages/presence.yaml b/config/packages/presence.yaml index 10ebc6c..6ca4435 100644 --- a/config/packages/presence.yaml +++ b/config/packages/presence.yaml @@ -105,8 +105,15 @@ template: {{ state_attr(state_attr('sensor.template_room_ri_phone', 'entity_id') | string, 'distance') }} - trigger: - - platform: time_pattern - seconds: "/3" + - platform: state + entity_id: + - sensor.template_room_bo_phone + - sensor.template_room_ri_phone + not_to: + - unavailable + - unknown + for: + seconds: 5 binary_sensor: - unique_id: bos_office_is_occupied name: Bo's Office Is Occupied @@ -114,9 +121,9 @@ template: {{ is_state('sensor.template_room_bo_phone', 'bo_s_office') or is_state('sensor.template_room_ri_phone', 'bo_s_office') }} icon: | {% if is_state("binary_sensor.bo_s_office_is_occupied", "on") %} - mdi:person + mdi:account {% else %} - mdi:person-outline + mdi:account-outline {% endif %} device_class: occupancy @@ -126,9 +133,9 @@ template: {{ is_state('sensor.template_room_bo_phone', 'ri_s_office') or is_state('sensor.template_room_ri_phone', 'ri_s_office') }} icon: | {% if is_state("binary_sensor.ri_s_office_is_occupied", "on") %} - mdi:person + mdi:account {% else %} - mdi:person-outline + mdi:account-outline {% endif %} device_class: occupancy @@ -138,9 +145,9 @@ template: {{ is_state('sensor.template_room_bo_phone', 'bedroom') or is_state('sensor.template_room_ri_phone', 'bedroom') }} icon: | {% if is_state("binary_sensor.bedroom_is_occupied", "on") %} - mdi:person + mdi:account {% else %} - mdi:person-outline + mdi:account-outline {% endif %} device_class: occupancy @@ -150,20 +157,44 @@ template: {{ is_state('sensor.template_room_bo_phone', 'living_room') or is_state('sensor.template_room_ri_phone', 'living_room') }} icon: | {% if is_state("binary_sensor.living_room_is_occupied", "on") %} - mdi:person + mdi:account {% else %} - mdi:person-outline + mdi:account-outline {% endif %} device_class: occupancy - - unique_id: lounge_room_is_occupied - name: Lounge Room Is Occupied + - unique_id: analog_room_is_occupied + name: analog Room Is Occupied state: | - {{ is_state('sensor.template_room_bo_phone', 'lounge_room') or is_state('sensor.template_room_ri_phone', 'lounge_room') }} + {{ is_state('sensor.template_room_bo_phone', 'analog_room') or is_state('sensor.template_room_ri_phone', 'analog_room') }} icon: | - {% if is_state("binary_sensor.lounge_room_is_occupied", "on") %} - mdi:person + {% if is_state("binary_sensor.analog_room_is_occupied", "on") %} + mdi:account {% else %} - mdi:person-outline + mdi:account-outline {% endif %} device_class: occupancy + +automation: + - id: 20ca57c492451f62ab86cabb9e1e8fee00811e45 + alias: Restart ESPresense regularly # ESPresense seems to just stop reporting sometimes. Restarting regularly is a workaround. + trigger: + - platform: state + entity_id: + - sensor.espresense_bedroom_uptime + - sensor.espresense_living_room_uptime + - sensor.espresense_bos_office_count + - sensor.espresense_ris_office_uptime + - sensor.espresense_analog_room_uptime + not_from: + # after restarting it will go unavailable then back to previous uptime, until it receives a new uptime. + # so skipping `not_from` will result in boot loops + - unavailable + - unknown + variables: + button: "button.{{ trigger.to_state.entity_id | replace('_uptime', '_restart') | replace('sensor.', '') }}" + condition: "{{ trigger.to_state.state | int > 3600 }}" # one hour + action: + - service: button.press + target: + entity_id: "{{ button }}" diff --git a/lovelace/lovelace.bos_office.yaml b/lovelace/lovelace.bos_office.yaml index 54fc218..5eb3d45 100644 --- a/lovelace/lovelace.bos_office.yaml +++ b/lovelace/lovelace.bos_office.yaml @@ -10,7 +10,8 @@ config: type: entity use_entity_picture: false - entity: binary_sensor.bo_s_office_is_occupied - icon: mdi:motion-sensor + type: entity + - entity: binary_sensor.bo_s_office_motion type: entity - entity: sensor.ble_temperature_bos_office_a4c1380f0b98 type: entity diff --git a/lovelace/lovelace.lovelace_shed.yaml b/lovelace/lovelace.lovelace_shed.yaml deleted file mode 100644 index 7270d20..0000000 --- a/lovelace/lovelace.lovelace_shed.yaml +++ /dev/null @@ -1,3 +0,0 @@ -config: - title: Outdoors - views: [] diff --git a/lovelace/lovelace_dashboards.yaml b/lovelace/lovelace_dashboards.yaml index 9dfc57e..8f3f298 100644 --- a/lovelace/lovelace_dashboards.yaml +++ b/lovelace/lovelace_dashboards.yaml @@ -1,11 +1,4 @@ items: -- icon: mdi:greenhouse - id: lovelace_shed - mode: storage - require_admin: true - show_in_sidebar: true - title: Shed - url_path: lovelace-shed - icon: mdi:chair-rolling id: bos_office mode: storage