From 204599b4f47505d96ed97986d89677267fa874f9 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Thu, 28 Sep 2023 16:33:55 -0400 Subject: [PATCH] Switch methods of rain detection...again... #89 --- custom_templates/weather.jinja | 4 +- packages/custom_weather.yaml | 83 ++++++++++++------- packages/weatheralerts.yaml | 8 +- templates/speech/kallen_morning_briefing.yaml | 2 +- 4 files changed, 58 insertions(+), 39 deletions(-) diff --git a/custom_templates/weather.jinja b/custom_templates/weather.jinja index 6d1f8b8..49a3945 100644 --- a/custom_templates/weather.jinja +++ b/custom_templates/weather.jinja @@ -26,7 +26,7 @@ {% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %} There is lightning in the area. Nearest strike is {{ ltgdist }} miles away. {% endif %} - {% if is_state('binary_sensor.raining_bayesian','on') %} + {% if is_state('binary_sensor.raining','on') %} It is currently raining. Make sure all doors and windows are closed! {% endif %} {% if state_attr('weather.iron_nerd_weather_station','visibility') | int < 3 %} @@ -65,7 +65,7 @@ ] | random }} "The nearest lightning strike is {{ ltgdist }} miles away. " {% endif %} - {% if is_state('binary_sensor.raining_bayesian','on') %} + {% if is_state('binary_sensor.raining','on') %} {{ [ "I have looked outside and determined that it is raining. ", "If you look outside the window, you will notice, it wainin. ", diff --git a/packages/custom_weather.yaml b/packages/custom_weather.yaml index cd9399f..9f9b60c 100644 --- a/packages/custom_weather.yaml +++ b/packages/custom_weather.yaml @@ -159,38 +159,38 @@ weather: {{ states(result) | float }} precipitation_unit: in -binary_sensor: - - platform: bayesian - unique_id: 3e9640d9-57a0-4495-8731-e64b34774065 - name: Raining Bayesian - prior: 0.17 - probability_threshold: 0.6 - observations: - - entity_id: "sensor.myradar_precip" - prob_given_true: 0.99 - prob_given_false: 0.45 - platform: "state" - to_state: "rain" - - entity_id: "sensor.pirateweather_precip" - prob_given_true: 0.13 - prob_given_false: 0.005 - platform: "state" - to_state: "rain" - - entity_id: "sensor.openweathermap_precipitation_kind" - prob_given_true: 0.75 - prob_given_false: 0.005 - platform: "state" - to_state: "rain" - - entity_id: "sensor.tomorrow_io_stratton_ave_precipitation_type" - prob_given_true: 0.99 - prob_given_false: 0.2 - platform: "state" - to_state: "rain" - - entity_id: "sensor.stratton_ave_precipitation" - prob_given_true: 0.99 - prob_given_false: 0.2 - platform: "numeric_state" - above: 0 +# binary_sensor: +# - platform: bayesian +# unique_id: 3e9640d9-57a0-4495-8731-e64b34774065 +# name: Raining Bayesian +# prior: 0.17 +# probability_threshold: 0.6 +# observations: +# - entity_id: "sensor.myradar_precip" +# prob_given_true: 0.99 +# prob_given_false: 0.45 +# platform: "state" +# to_state: "rain" +# - entity_id: "sensor.pirateweather_precip" +# prob_given_true: 0.13 +# prob_given_false: 0.005 +# platform: "state" +# to_state: "rain" +# - entity_id: "sensor.openweathermap_precipitation_kind" +# prob_given_true: 0.75 +# prob_given_false: 0.005 +# platform: "state" +# to_state: "rain" +# - entity_id: "sensor.tomorrow_io_stratton_ave_precipitation_type" +# prob_given_true: 0.99 +# prob_given_false: 0.2 +# platform: "state" +# to_state: "rain" +# - entity_id: "sensor.stratton_ave_precipitation" +# prob_given_true: 0.99 +# prob_given_false: 0.2 +# platform: "numeric_state" +# above: 0 sensor: - platform: weatheralerts @@ -353,7 +353,26 @@ template: {% else %} common {% endif %} + - name: Raining + unique_id: 232b43a4-4598-4315-ab76-42348c11e6ff + state: > + {{ states('sensor.total_rain_sensors') | int > 1 }} + icon: "{{ 'mdi:weather-rainy' if states('sensor.total_rain_sensors') | int > 1 else 'mdi:weather-cloudy' }}" - sensor: + - name: Total Rain Sensors + unique_id: b7c2e709-8f5c-4263-aa1d-fa8280afcddb + state: > + {% set sensors = [ + states.sensor.pirateweather_precip, + states.sensor.openweathermap_precipitation_kind, + states.sensor.tomorrow_io_stratton_ave_precipitation_type + ] %} + {% set numeric_sensors = [ + states.sensor.stratton_ave_precipitation + ] %} + {% set c1 = sensors | selectattr('state','eq','rain') | list | count %} + {% set c2 = numeric_sensors | map(attribute='state') | map('float') | select('gt',0) | list | count %} + {{ (c1 + c2) | int }} - name: Current Forecast unique_id: c0faea33-2ac3-40f1-8558-584c3f5d6b16 icon: mdi:weather-sunny diff --git a/packages/weatheralerts.yaml b/packages/weatheralerts.yaml index 68d617b..a3a7b82 100644 --- a/packages/weatheralerts.yaml +++ b/packages/weatheralerts.yaml @@ -1593,7 +1593,7 @@ automation: alias: Rain Window Warning trigger: - platform: state - entity_id: binary_sensor.raining_bayesian + entity_id: binary_sensor.raining from: 'off' to: 'on' condition: @@ -1626,13 +1626,13 @@ automation: who: everywhere type: weather message: "It is raining and there are windows open in the house. Please close them!" - - wait_template: "{{ is_state('binary_sensor.windows','off') or is_state('binary_sensor.raining_bayesian','off') }}" + - wait_template: "{{ is_state('binary_sensor.windows','off') or is_state('binary_sensor.raining','off') }}" timeout: "00:15:00" continue_on_timeout: true - choose: - conditions: - condition: template - value_template: "{{ is_state('binary_sensor.windows','off') and is_state('binary_sensor.raining_bayesian','on') }}" + value_template: "{{ is_state('binary_sensor.windows','off') and is_state('binary_sensor.raining','on') }}" sequence: - service: script.text_notify data: @@ -1647,7 +1647,7 @@ automation: message: "Windows are now closed. Thank you, and enjoy your dry house." - conditions: - condition: template - value_template: "{{ is_state('binary_sensor.raining_bayesian','off') }}" + value_template: "{{ is_state('binary_sensor.raining','off') }}" sequence: - service: script.text_notify data: diff --git a/templates/speech/kallen_morning_briefing.yaml b/templates/speech/kallen_morning_briefing.yaml index 156f39b..6862d29 100644 --- a/templates/speech/kallen_morning_briefing.yaml +++ b/templates/speech/kallen_morning_briefing.yaml @@ -88,7 +88,7 @@ ] | random }} {% endif %} School today starts at {{ input_datetime_read('input_datetime.kallen_school_day_start') }} - {% if is_state('binary_sensor.raining_bayesian','on') %} + {% if is_state('binary_sensor.raining','on') %} It appears to be raining right now, so you might get wet on your way to school. {% endif %} {% if is_state('input_boolean.kallen_alternate_pickup','on') %}