From fd69d971f56a67c70926360f3c9e1382c5095093 Mon Sep 17 00:00:00 2001 From: zorruno Date: Wed, 12 Oct 2022 11:20:47 +1300 Subject: [PATCH] Moved more to packages --- configuration.yaml | 20 ----------- packages/covid_count.yaml | 20 +++++++++++ packages/google_keep.yaml | 7 ++++ packages/grocy_api.yaml | 42 +++++++++++++++++++++++ packages/internet_traffic.yaml | 19 ++++++++++ packages/low_battery_device_quantity.yaml | 20 +++++++++++ packages/niwa_tides.yaml | 7 ++++ packages/tautulli.yaml | 5 +++ packages/total_power_sum_template.yaml | 7 ++++ sensor/coronavirus.yaml | 18 ---------- sensor/google_keep.yaml | 6 ---- sensor/grocy.yaml | 26 -------------- sensor/internet_traffic.yaml | 20 ----------- sensor/low_battery_template.yaml | 19 ---------- sensor/power_monitoring.yaml | 6 ---- sensor/tautulli.yaml | 4 --- sensor/tides.yaml | 6 ---- 17 files changed, 127 insertions(+), 125 deletions(-) create mode 100644 packages/google_keep.yaml create mode 100644 packages/grocy_api.yaml create mode 100644 packages/internet_traffic.yaml create mode 100644 packages/low_battery_device_quantity.yaml create mode 100644 packages/niwa_tides.yaml create mode 100644 packages/tautulli.yaml create mode 100644 packages/total_power_sum_template.yaml delete mode 100644 sensor/coronavirus.yaml delete mode 100644 sensor/google_keep.yaml delete mode 100644 sensor/grocy.yaml delete mode 100644 sensor/internet_traffic.yaml delete mode 100644 sensor/low_battery_template.yaml delete mode 100644 sensor/power_monitoring.yaml delete mode 100644 sensor/tautulli.yaml delete mode 100644 sensor/tides.yaml diff --git a/configuration.yaml b/configuration.yaml index b69732e..9302218 100644 --- a/configuration.yaml +++ b/configuration.yaml @@ -26,11 +26,6 @@ logger: custom_components.evnex: debug evnex: debug -# mqtt broker -#mqtt: -# broker: !secret mqtt1_broker -# port: !secret mqtt1_port - device_tracker: - platform: bluetooth_le_tracker @@ -44,18 +39,3 @@ input_boolean: away_occupied_routine: name: Automation for Lights etc when away icon: mdi:shield-lock - -rest_command: - chores1_request: - url: !secret grocy_api_uri_chore6 - method: PUT - headers: - accept: "*/*" - GROCY-API-KEY: !secret grocy_api_key - content_type: "application/json" - payload: '{ - "name" : "{{ name }}" , - "next_execution_assigned_to_user_id" : "{{ assigned_to }}" - }' - # payload: '{"name" : "{{ name }}" , "next_estimated_execution_time" : "{{ next_time }}", "next_execution_assigned_to_user_id" : "{{ assigned_to }}" }' - verify_ssl: false diff --git a/packages/covid_count.yaml b/packages/covid_count.yaml index 8f6d69f..c52fa2d 100644 --- a/packages/covid_count.yaml +++ b/packages/covid_count.yaml @@ -33,3 +33,23 @@ automation: data_template: entity_id: var.covid_yesterday_total value: "{{ states('sensor.new_zealand_coronavirus_confirmed') | float }}" + +sensor: + - platform: statistics + entity_id: sensor.coronavirus_totals_normalised + sampling_size: 200000 + state_characteristic: mean + max_age: + days: 1 + name: "Coronavirus Statistics" + - platform: template + sensors: + coronavirus_totals_normalised: + friendly_name: "NZ Coronavirus Totals (Normalised)" + value_template: > + {% set new_state = states('sensor.new_zealand_coronavirus_confirmed') | float %} + {% if new_state >= states('input_number.new_zealand_coronavirus_confirmed_previous_value') | float %} + {{ new_state }} + {% else %} + {{ states('input_number.new_zealand_coronavirus_confirmed_previous_value') | float }} + {% endif %} diff --git a/packages/google_keep.yaml b/packages/google_keep.yaml new file mode 100644 index 0000000..fa7d3b7 --- /dev/null +++ b/packages/google_keep.yaml @@ -0,0 +1,7 @@ +sensor: + - platform: google_keep + username: !secret google_keep.username + password: !secret google_keep.password + labels: + - "Home Assistant" + pinned: true diff --git a/packages/grocy_api.yaml b/packages/grocy_api.yaml new file mode 100644 index 0000000..af6f445 --- /dev/null +++ b/packages/grocy_api.yaml @@ -0,0 +1,42 @@ +rest_command: + chores1_request: + url: !secret grocy_api_uri_chore6 + method: PUT + headers: + accept: "*/*" + GROCY-API-KEY: !secret grocy_api_key + content_type: "application/json" + payload: '{ + "name" : "{{ name }}" , + "next_execution_assigned_to_user_id" : "{{ assigned_to }}" + }' + # payload: '{"name" : "{{ name }}" , "next_estimated_execution_time" : "{{ next_time }}", "next_execution_assigned_to_user_id" : "{{ assigned_to }}" }' + verify_ssl: false + +sensor: + - platform: rest + name: Dog Motel Cleaning + resource: !secret grocy_api_uri_chore3 + method: GET + value_template: "{{ (((as_timestamp(value_json.next_estimated_execution_time))-as_timestamp(now())) | int /60/1440) | round(0) }}" + json_attributes: + - last_tracked + - estimated_execution_time + headers: + Accept: application/json + Content-Type: application/json + GROCY-API-KEY: !secret grocy_api_key + unit_of_measurement: "Days" + - platform: rest + name: Red Bin Out + resource: !secret grocy_api_uri_chore2 + method: GET + value_template: "{{ (((as_timestamp(value_json.next_estimated_execution_time))-as_timestamp(now())) | int /60/1440) | round(0) }}" + json_attributes: + - last_tracked + - estimated_execution_time + headers: + Accept: application/json + Content-Type: application/json + GROCY-API-KEY: !secret grocy_api_key + unit_of_measurement: "Days" diff --git a/packages/internet_traffic.yaml b/packages/internet_traffic.yaml new file mode 100644 index 0000000..34c5958 --- /dev/null +++ b/packages/internet_traffic.yaml @@ -0,0 +1,19 @@ +sensor: + - platform: template + sensors: + sensor_internet_downtraffic: + friendly_name: "Internet Download Traffic" + unit_of_measurement: "kB/s" + value_template: "{{ state_attr('binary_sensor.edgeos_interface_pppoe0', 'KBytes/ps (Received)') }}" + - platform: template + sensors: + sensor_internet_uptraffic: + friendly_name: "Internet Upload Traffic" + unit_of_measurement: "kB/s" + value_template: "{{ state_attr('binary_sensor.edgeos_interface_pppoe0', 'KBytes/ps (Sent)') }}" + - platform: template + sensors: + sensor_internet_totaltraffic: + friendly_name: "Internet Total Traffic" + unit_of_measurement: "kB/s" + value_template: "{{ state_attr('binary_sensor.edgeos_interface_pppoe0', 'KBytes/ps (Received)') |float + state_attr('binary_sensor.edgeos_interface_pppoe0', 'KBytes/ps (Sent)') | float }}" diff --git a/packages/low_battery_device_quantity.yaml b/packages/low_battery_device_quantity.yaml new file mode 100644 index 0000000..5be0504 --- /dev/null +++ b/packages/low_battery_device_quantity.yaml @@ -0,0 +1,20 @@ +sensor: + - platform: template + sensors: + devices_with_low_battery: + friendly_name: "Devices with low battery" + unit_of_measurement: devices + value_template: >- + {{ states.sensor + | selectattr('attributes.device_class', 'eq', 'battery') + | map(attribute='state') + | reject('in', ['unknown', 'unavailable', 'Ok']) + | map('int', -1) | select('le', 97) + | list | count + }} + icon_template: >- + {% if is_state('sensor.devices_with_low_battery', '0') %} + mdi:check-circle + {% else %} + mdi:battery-alert + {% endif %} diff --git a/packages/niwa_tides.yaml b/packages/niwa_tides.yaml new file mode 100644 index 0000000..4771347 --- /dev/null +++ b/packages/niwa_tides.yaml @@ -0,0 +1,7 @@ +sensor: + - platform: niwa_tides + api_key: !secret niwa_tides_api_key + entity_id: "local_tides" + name: Local Tides + latitude: !secret latitude + longitude: !secret longitude diff --git a/packages/tautulli.yaml b/packages/tautulli.yaml new file mode 100644 index 0000000..77c5801 --- /dev/null +++ b/packages/tautulli.yaml @@ -0,0 +1,5 @@ +sensor: + - platform: tautulli + api_key: !secret tautulli_api_key + host: !secret tautulli_api_host + port: !secret tautulli_api_port diff --git a/packages/total_power_sum_template.yaml b/packages/total_power_sum_template.yaml new file mode 100644 index 0000000..48b61a2 --- /dev/null +++ b/packages/total_power_sum_template.yaml @@ -0,0 +1,7 @@ +sensor: + - platform: template + sensors: + electricity_power_total: + friendly_name: "Electricity Power Total" + unit_of_measurement: "W" + value_template: "{{ states('sensor.tasmo_wemosd1_7280_powermon_1_energy_power_0') |float + states('sensor.tasmo_wemosd1_7280_powermon_1_energy_power_1') | float + states('sensor.tasmo_wemosd1_7280_powermon_1_energy_power_2') | float }}" diff --git a/sensor/coronavirus.yaml b/sensor/coronavirus.yaml deleted file mode 100644 index 544a27e..0000000 --- a/sensor/coronavirus.yaml +++ /dev/null @@ -1,18 +0,0 @@ -- platform: statistics - entity_id: sensor.coronavirus_totals_normalised - sampling_size: 200000 - state_characteristic: mean - max_age: - days: 1 - name: "Coronavirus Statistics" -- platform: template - sensors: - coronavirus_totals_normalised: - friendly_name: "NZ Coronavirus Totals (Normalised)" - value_template: > - {% set new_state = states('sensor.new_zealand_coronavirus_confirmed') | float %} - {% if new_state >= states('input_number.new_zealand_coronavirus_confirmed_previous_value') | float %} - {{ new_state }} - {% else %} - {{ states('input_number.new_zealand_coronavirus_confirmed_previous_value') | float }} - {% endif %} diff --git a/sensor/google_keep.yaml b/sensor/google_keep.yaml deleted file mode 100644 index 57dc283..0000000 --- a/sensor/google_keep.yaml +++ /dev/null @@ -1,6 +0,0 @@ -- platform: google_keep - username: !secret google_keep.username - password: !secret google_keep.password - labels: - - "Home Assistant" - pinned: true diff --git a/sensor/grocy.yaml b/sensor/grocy.yaml deleted file mode 100644 index 4783c23..0000000 --- a/sensor/grocy.yaml +++ /dev/null @@ -1,26 +0,0 @@ -- platform: rest - name: Dog Motel Cleaning - resource: !secret grocy_api_uri_chore3 - method: GET - value_template: "{{ (((as_timestamp(value_json.next_estimated_execution_time))-as_timestamp(now())) | int /60/1440) | round(0) }}" - json_attributes: - - last_tracked - - estimated_execution_time - headers: - Accept: application/json - Content-Type: application/json - GROCY-API-KEY: !secret grocy_api_key - unit_of_measurement: "Days" -- platform: rest - name: Red Bin Out - resource: !secret grocy_api_uri_chore2 - method: GET - value_template: "{{ (((as_timestamp(value_json.next_estimated_execution_time))-as_timestamp(now())) | int /60/1440) | round(0) }}" - json_attributes: - - last_tracked - - estimated_execution_time - headers: - Accept: application/json - Content-Type: application/json - GROCY-API-KEY: !secret grocy_api_key - unit_of_measurement: "Days" diff --git a/sensor/internet_traffic.yaml b/sensor/internet_traffic.yaml deleted file mode 100644 index 377433e..0000000 --- a/sensor/internet_traffic.yaml +++ /dev/null @@ -1,20 +0,0 @@ -- platform: template - sensors: - sensor_internet_downtraffic: - friendly_name: "Internet Download Traffic" - unit_of_measurement: "kB/s" - value_template: "{{ state_attr('binary_sensor.edgeos_interface_pppoe0', 'KBytes/ps (Received)') }}" - -- platform: template - sensors: - sensor_internet_uptraffic: - friendly_name: "Internet Upload Traffic" - unit_of_measurement: "kB/s" - value_template: "{{ state_attr('binary_sensor.edgeos_interface_pppoe0', 'KBytes/ps (Sent)') }}" - -- platform: template - sensors: - sensor_internet_totaltraffic: - friendly_name: "Internet Total Traffic" - unit_of_measurement: "kB/s" - value_template: "{{ state_attr('binary_sensor.edgeos_interface_pppoe0', 'KBytes/ps (Received)') |float + state_attr('binary_sensor.edgeos_interface_pppoe0', 'KBytes/ps (Sent)') | float }}" diff --git a/sensor/low_battery_template.yaml b/sensor/low_battery_template.yaml deleted file mode 100644 index b294f1d..0000000 --- a/sensor/low_battery_template.yaml +++ /dev/null @@ -1,19 +0,0 @@ -- platform: template - sensors: - devices_with_low_battery: - friendly_name: "Devices with low battery" - unit_of_measurement: devices - value_template: >- - {{ states.sensor - | selectattr('attributes.device_class', 'eq', 'battery') - | map(attribute='state') - | reject('in', ['unknown', 'unavailable', 'Ok']) - | map('int', -1) | select('le', 97) - | list | count - }} - icon_template: >- - {% if is_state('sensor.devices_with_low_battery', '0') %} - mdi:check-circle - {% else %} - mdi:battery-alert - {% endif %} diff --git a/sensor/power_monitoring.yaml b/sensor/power_monitoring.yaml deleted file mode 100644 index 5e88648..0000000 --- a/sensor/power_monitoring.yaml +++ /dev/null @@ -1,6 +0,0 @@ -- platform: template - sensors: - electricity_power_total: - friendly_name: "Electricity Power Total" - unit_of_measurement: "W" - value_template: "{{ states('sensor.tasmo_wemosd1_7280_powermon_1_energy_power_0') |float + states('sensor.tasmo_wemosd1_7280_powermon_1_energy_power_1') | float + states('sensor.tasmo_wemosd1_7280_powermon_1_energy_power_2') | float }}" diff --git a/sensor/tautulli.yaml b/sensor/tautulli.yaml deleted file mode 100644 index 248d815..0000000 --- a/sensor/tautulli.yaml +++ /dev/null @@ -1,4 +0,0 @@ -- platform: tautulli - api_key: !secret tautulli_api_key - host: !secret tautulli_api_host - port: !secret tautulli_api_port diff --git a/sensor/tides.yaml b/sensor/tides.yaml deleted file mode 100644 index d68d91d..0000000 --- a/sensor/tides.yaml +++ /dev/null @@ -1,6 +0,0 @@ -- platform: niwa_tides - api_key: !secret niwa_tides_api_key - entity_id: "local_tides" - name: Local Tides - latitude: !secret latitude - longitude: !secret longitude