From 59750bf6e8af5055feef7e9408974b3339313ae1 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Wed, 30 Mar 2022 15:46:54 -0400 Subject: [PATCH 1/9] Added a temnplate weather integration --- packages/custom_weather.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 packages/custom_weather.yaml diff --git a/packages/custom_weather.yaml b/packages/custom_weather.yaml new file mode 100644 index 0000000..1165a29 --- /dev/null +++ b/packages/custom_weather.yaml @@ -0,0 +1,12 @@ +weather: + - platform: template + name: "Iron Nerd Weather Station" + condition_template: "{{ states('weather.stratton_ave') }}" + temperature_template: "{{ states('sensor.temperature') | float }}" + humidity_template: "{{ states('sensor.humidity') | float }}" + forecast_template: "{{ state_attr('weather.stratton_ave', 'forecast') }}" + pressure_template: "{{ states('sensor.barometric_pressure') | float }}" + wind_speed_template: "{{ states('sensor.wind_speed') | float }}" + wind_bearing_template: "{{ states('sensor.wind_direction') | float }}" + visibility_template: "{{ states('sensor.kdfi_visibility') | float }}" + attribution_template: "Weather data from Iron Nerd's custom weather station template" \ No newline at end of file From 452bcdedee7bd3fe6860cf3a2b7cb7175c126b94 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Wed, 30 Mar 2022 17:01:07 -0400 Subject: [PATCH 2/9] Added Pirate Weather custom integration --- packages/custom_weather.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/custom_weather.yaml b/packages/custom_weather.yaml index 1165a29..8b9ec4e 100644 --- a/packages/custom_weather.yaml +++ b/packages/custom_weather.yaml @@ -9,4 +9,8 @@ weather: wind_speed_template: "{{ states('sensor.wind_speed') | float }}" wind_bearing_template: "{{ states('sensor.wind_direction') | float }}" visibility_template: "{{ states('sensor.kdfi_visibility') | float }}" - attribution_template: "Weather data from Iron Nerd's custom weather station template" \ No newline at end of file + attribution_template: "Weather data from Iron Nerd's custom weather station template" + - platform: pirateweather + api_key: !secret pirate_weather_api + mode: "daily" + name: Iron Nerd Studios From acc6d5ff39c6d1e6de416b94d7e4b59fe0786ef1 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Wed, 30 Mar 2022 17:18:23 -0400 Subject: [PATCH 3/9] Added Pirate Weather sensor --- packages/custom_weather.yaml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/packages/custom_weather.yaml b/packages/custom_weather.yaml index 8b9ec4e..d7d6ed7 100644 --- a/packages/custom_weather.yaml +++ b/packages/custom_weather.yaml @@ -14,3 +14,39 @@ weather: api_key: !secret pirate_weather_api mode: "daily" name: Iron Nerd Studios + +sensor: + - platform: pirateweather + api_key: !secret pirate_weather_api + scan_interval: '00:15:00' + monitored_conditions: + - icon + - temperature + - precip_probability + - precip_type + - humidity + - cloud_cover + - nearest_storm_distance + - precip_intensity + - wind_speed + - precip_accumulation + - apparent_temperature + - dew_point + - wind_gust + - wind_bearing + - pressure + - ozone + - minutely_summary + - hourly_summary + - daily_summary + - temperature_high + - temperature_low + - apparent_temperature_high + - apparent_temperature_low + - precip_intensity_max + - uv_index + - moon_phase + - sunrise_time + - sunset_time + - nearest_storm_bearing + - alerts From 45a25a64e0fdf64958de7658cbcaed74b2c6d404 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Wed, 30 Mar 2022 17:22:28 -0400 Subject: [PATCH 4/9] Moved weatheralerts sensor to keep weather things together --- packages/custom_weather.yaml | 4 ++++ sensor.yaml | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/custom_weather.yaml b/packages/custom_weather.yaml index d7d6ed7..a5a5c4c 100644 --- a/packages/custom_weather.yaml +++ b/packages/custom_weather.yaml @@ -50,3 +50,7 @@ sensor: - sunset_time - nearest_storm_bearing - alerts + - platform: weatheralerts + state: OH + zone: 4 + county: 39 diff --git a/sensor.yaml b/sensor.yaml index 9b76832..a741dfc 100644 --- a/sensor.yaml +++ b/sensor.yaml @@ -1,7 +1,3 @@ -- platform: weatheralerts - state: OH - zone: 4 - county: 39 - platform: twitch_helix client_id: !secret twitch_client_id client_secret: !secret twitch_client_secret From 2229c8d4b968380542828d329ff5dfb28c84f767 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Wed, 30 Mar 2022 18:10:09 -0400 Subject: [PATCH 5/9] Moved average sensors to custom_weather.yaml --- sensor.yaml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/sensor.yaml b/sensor.yaml index a741dfc..446eb3c 100644 --- a/sensor.yaml +++ b/sensor.yaml @@ -11,24 +11,6 @@ - STPeach - BroteinGaming404 - NotoriosPenguin -- platform: average - name: 'Average Temperature' - duration: - days: 7 - entities: - - sensor.temperature -- platform: average - name: 'Average Feels Like' - duration: - days: 7 - entities: - - sensor.feels_like -- platform: average - name: 'Average Wind Speed' - duration: - days: 7 - entities: - - sensor.wind_speed - platform: rest name: Household Tasks method: GET From 51488fe7f8a20e52eb599e254910acd86cdfde4a Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Wed, 30 Mar 2022 19:26:55 -0400 Subject: [PATCH 6/9] Added time of day sensors --- binary_sensor.yaml | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/binary_sensor.yaml b/binary_sensor.yaml index 86299b6..5deee16 100644 --- a/binary_sensor.yaml +++ b/binary_sensor.yaml @@ -2,7 +2,43 @@ country: US province: OH workdays: [mon, tue, wed, thu, fri] + - platform: tod name: School - after: "09:00" - before: "15:30" + after: '09:00' + before: '15:30' + +- platform: tod + name: Night + after: sunset + before: sunrise + +- platform: tod + name: Day + after: sunrise + before: sunset + +- platform: tod + name: Quiet time + after: '21:00' + before: '07:30' + +- platform: tod + name: Morning + after: '07:30' + before: '09:00' + +- platform: tod + name: Midday + after: '09:00' + before: '16:00' + +- platform: tod + name: Evening + after: '16:00' + before: '21:00' + +- platform: tod + name: Overnight + after: '18:00' + before: '07:30' From f1322d021c6f5545625fd165341ea4ca5cd8557d Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Wed, 30 Mar 2022 19:34:17 -0400 Subject: [PATCH 7/9] Adapted file for my needs, WIP more to come --- packages/custom_weather.yaml | 709 ++++++++++++++++++++++++++++++++++- 1 file changed, 703 insertions(+), 6 deletions(-) diff --git a/packages/custom_weather.yaml b/packages/custom_weather.yaml index a5a5c4c..8840ff9 100644 --- a/packages/custom_weather.yaml +++ b/packages/custom_weather.yaml @@ -1,21 +1,29 @@ weather: - platform: template name: "Iron Nerd Weather Station" - condition_template: "{{ states('weather.stratton_ave') }}" - temperature_template: "{{ states('sensor.temperature') | float }}" - humidity_template: "{{ states('sensor.humidity') | float }}" - forecast_template: "{{ state_attr('weather.stratton_ave', 'forecast') }}" + condition_template: "{{ states('weather.iron_nerd_studios') }}" + temperature_template: "{{ states('sensor.pirateweather_temperature') | float }}" + humidity_template: "{{ states('sensor.pirateweather_humidity') | float }}" + forecast_template: "{{ state_attr('weather.iron_nerd_studios', 'forecast') }}" pressure_template: "{{ states('sensor.barometric_pressure') | float }}" - wind_speed_template: "{{ states('sensor.wind_speed') | float }}" - wind_bearing_template: "{{ states('sensor.wind_direction') | float }}" + wind_speed_template: "{{ states('sensor.pirateweather_wind_speed') | float }}" + wind_bearing_template: "{{ states('sensor.pirateweather_wind_bearing') | float }}" visibility_template: "{{ states('sensor.kdfi_visibility') | float }}" attribution_template: "Weather data from Iron Nerd's custom weather station template" + ozone_template: "{{ states('sensor.pirateweather_ozone') | float }}" - platform: pirateweather api_key: !secret pirate_weather_api mode: "daily" name: Iron Nerd Studios sensor: + # - platform: template + # sensors: + # pirateweather_pressure_inhg: + # friendly_name: Pirateweather Pressure inHg + # device_class: pressure + # unit_of_measurement: 'inHg' + # value_template: "{{ (states('sensor.pirateweather_pressure') | float * 0.029529983071445) | round(2) }}" - platform: pirateweather api_key: !secret pirate_weather_api scan_interval: '00:15:00' @@ -50,7 +58,696 @@ sensor: - sunset_time - nearest_storm_bearing - alerts + units: us - platform: weatheralerts state: OH zone: 4 county: 39 + + - platform: average + name: 'Average Temperature' + duration: + days: 7 + entities: + - sensor.pirateweather_temperature + - platform: average + name: 'Average Feels Like' + duration: + days: 7 + entities: + - sensor.pirateweather_apparent + - platform: average + name: 'Average Wind Speed' + duration: + days: 7 + entities: + - sensor.pirateweather_wind_speed + + + - platform: template + sensors: + current_forecast: + friendly_name: Current Forecast + unit_of_measurement: '' + icon_template: mdi:weather-sunny + value_template: >- + {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[0] %} + {{ forecast.condition }} + attribute_templates: + high_temp: >- + {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[0] %} + {{ forecast.temperature }} + overnight_low: >- + {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[1] %} + {{ forecast.templow }} + wind_bearing: >- + {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[0] %} + {{ forecast.wind_bearing }} + wind_speed: >- + {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[0] %} + {{ forecast.wind_speed }} + precipitation: >- + {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[0] %} + {{ forecast.precipitation }} + current_forecast_detail: + friendly_name: Current Forecast Detail + unit_of_measurement: '' + icon_template: mdi:weather-sunny + value_template: >- + {%- macro getReport() -%} + {{ [ + 'Today in Defiance ', + 'Later Today ', + 'For the rest of the day' + ] | random }} + expect a high of {{ state_attr('sensor.current_forecast','high_temp') }} + {%- if states('sensor.current_forecast') == 'sunny' and is_state('binary_sensor.night','off')%} + {{ [ + 'and sunny.', + 'with sun.', + 'with sunny conditions prevailing.' + ] | random }} + {%- elif states('sensor.current_forecast') == 'sunny' and is_state('binary_sensor.night','on') %} + {{ [ + 'and clear.', + 'with clear skies.' + ] | random }} + {%- elif states('sensor.current_forecast') == 'clear-night' %} + {{ [ + 'and clear.', + 'with clear skies.' + ] | random }} + {%- elif states('sensor.current_forecast') == 'rainy' %} + {{ [ + 'with rain.', + 'with showers.', + 'and rainy.' + ] | random }} + {{ [ + 'Rainfall accumulations ', + 'Total Rainfall amounts ' + ] | random }} + near {{ state_attr('sensor.current_forecast','precipitation') }} inches + possible. + {%- elif states('sensor.current_forecast') == 'snowy' %} + {{ [ + 'with snow.', + 'with snow showers.' + ] | random }} + {{ [ + 'Snowfall accumulations ', + 'Total snowfall amounts ' + ] | random }} + near {{ state_attr('sensor.current_forecast','precipitation') }} inches + possible. + {%- elif states('sensor.current_forecast') == 'snowy-rainy' %} + {{ [ + 'with mix preciptation possible.', + 'with snow and rain showers.' + ] | random }} + Total accumulation near {{ state_attr('sensor.current_forecast','precipitation') }} inches + possible. + {%- elif states('sensor.current_forecast') == 'windy' %} + {{ [ + 'and windy.', + 'with lots of wind.' + ] | random }} + {%- elif states('sensor.current_forecast') == 'fog' %} + {{ [ + 'and foggy.', + 'with some fog.' + ] | random }} + {% elif states('sensor.current_forecast') == 'cloudy' %} + {{ [ + 'with clouds.', + 'with cloudy skies.' + ] | random }} + {% elif states('sensor.current_forecast') == 'partlycloudy' %} + {{ [ + 'with some clouds.', + 'with partly cloudy skies.', + 'with scattered clouds' + ] | random }} + {%- elif states('sensor.current_forecast') == 'hail' %} + {{ [ + 'with severve thunderstorms possible.', + 'with hail possible.' + ] | random }} + {{ [ + 'Rainfall accumulations ', + 'Total Rainfall amounts ' + ] | random }} + near {{ state_attr('sensor.current_forecast','precipitation') }} inches + possible. + {%- elif states('sensor.current_forecast') == 'lightning' %} + {{ [ + 'with thunderstorms possible.', + 'with the potential of thunderstorms.' + ] | random }} + {{ [ + 'Rainfall accumulations ', + 'Total Rainfall amounts ' + ] | random }} + near {{ state_attr('sensor.current_forecast','precipitation') }} inches + possible. + {% endif -%} + {{ [ + 'Later tonight expect a low of ', + 'Overnight expect a low of ' + ] | random }} + {{ state_attr('sensor.current_forecast','overnight_low') }} degrees. + {%- endmacro -%} + {# a macro that removes all newline characters, empty spaces, and returns formatted text #} + {%- macro cleanup(data) -%} + {%- for item in data.split("\n") if item | trim != "" -%} + {{ item | trim }} {% endfor -%} + {%- endmacro -%} + {# a macro to call all macros :) #} + {%- macro mother_of_all_macros() -%} + {{ getReport() }} + {%- endmacro -%} + + {# Call the macro #} + {{- cleanup(mother_of_all_macros()) -}} + tomorrow_forecast: + friendly_name: Tomorrows Forecast + unit_of_measurement: '' + icon_template: mdi:weather-sunny + value_template: >- + {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[1] %} + {{ forecast.condition }} + attribute_templates: + high_temp: >- + {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[1] %} + {{ forecast.temperature }} + overnight_low: >- + {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[2] %} + {{ forecast.templow }} + wind_bearing: >- + {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[1] %} + {{ forecast.wind_bearing }} + wind_speed: >- + {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[1] %} + {{ forecast.wind_speed }} + precipitation: >- + {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[1] %} + {{ forecast.precipitation }} + tomorrow_forecast_detail: + friendly_name: Tomorrow Forecast Detail + unit_of_measurement: '' + icon_template: mdi:weather-sunny + value_template: >- + {%- macro getReport() -%} + {{ [ + 'Tomorrow in Defiance ', + 'For the next day ', + 'Tomorrow ' + ] | random }} + expect a high of {{ state_attr('sensor.tomorrow_forecast','high_temp') }} + {%- if states('sensor.tomorrow_forecast') == 'sunny' %} + {{ [ + 'and sunny.', + 'with sun.', + 'with sunny conditions prevailing.' + ] | random }} + {%- elif states('sensor.tomorrow_forecast') == 'rainy' %} + {{ [ + 'with rain.', + 'with showers.', + 'and rainy.' + ] | random }} + {{ [ + 'Rainfall accumulations ', + 'Total Rainfall amounts ' + ] | random }} + near {{ state_attr('sensor.tomorrow_forecast','precipitation') }} inches + possible. + {%- elif states('sensor.tomorrow_forecast') == 'snowy' %} + {{ [ + 'with snow.', + 'with snow showers.' + ] | random }} + {{ [ + 'Snowfall accumulations ', + 'Total snowfall amounts ' + ] | random }} + near {{ state_attr('sensor.tomorrow_forecast','precipitation') }} inches + possible. + {%- elif states('sensor.tomorrow_forecast') == 'snowy-rainy' %} + {{ [ + 'with mix preciptation possible.', + 'with snow and rain showers.' + ] | random }} + Total accumulation near {{ state_attr('sensor.tomorrow_forecast','precipitation') }} inches + possible. + {%- elif states('sensor.tomorrow_forecast') == 'windy' %} + {{ [ + 'and windy.', + 'with lots of wind.' + ] | random }} + {%- elif states('sensor.current_forecast') == 'fog' %} + {{ [ + 'and foggy.', + 'with some fog.' + ] | random }} + {% elif states('sensor.tomorrow_forecast') == 'cloudy' %} + {{ [ + 'with clouds.', + 'with cloudy skies.' + ] | random }} + {% elif states('sensor.tomorrow_forecast') == 'partlycloudy' %} + {{ [ + 'with some clouds.', + 'with partly cloudy skies.', + 'with scattered clouds' + ] | random }} + {%- elif states('sensor.tomorrow_forecast') == 'hail' %} + {{ [ + 'with severve thunderstorms possible.', + 'with hail possible.' + ] | random }} + {{ [ + 'Rainfall accumulations ', + 'Total Rainfall amounts ' + ] | random }} + near {{ state_attr('sensor.current_forecast','precipitation') }} inches + possible. + {%- elif states('sensor.current_forecast') == 'lightning' %} + {{ [ + 'with thunderstorms possible.', + 'with the potential of thunderstorms.' + ] | random }} + {{ [ + 'Rainfall accumulations ', + 'Total Rainfall amounts ' + ] | random }} + near {{ state_attr('sensor.current_forecast','precipitation') }} inches + possible. + {% endif -%} + {{ [ + ' Tomorrow night expect a low of ' + ] | random }} + {{ state_attr('sensor.tomorrow_forecast','overnight_low') }} degrees. + {%- endmacro -%} + {# a macro that removes all newline characters, empty spaces, and returns formatted text #} + {%- macro cleanup(data) -%} + {%- for item in data.split("\n") if item | trim != "" -%} + {{ item | trim }} {% endfor -%} + {%- endmacro -%} + {# a macro to call all macros :) #} + {%- macro mother_of_all_macros() -%} + {{ getReport() }} + {%- endmacro -%} + + {# Call the macro #} + {{- cleanup(mother_of_all_macros()) -}} + current_conditions: + friendly_name: Current Conditions + unit_of_measurement: '' + icon_template: mdi:weather-sunny + value_template: >- + {%- macro getReport() -%} + The Weather in Defiance + {{ [ + ' is ', + ' is currently ' + ] | random }} + {{states('sensor.pirateweather_temperature')|round}} degrees + {% if is_state('weather.iron_nerd_weather_station', 'rainy') %} + {{ [ + 'with rain.', + 'with showers.' + ] | random }} + {% elif is_state('weather.iron_nerd_weather_station', 'cloudy') %} + {{ [ + 'with clouds.', + 'with cloudy skies.' + ] | random }} + {% elif is_state('weather.iron_nerd_weather_station', 'partlycloudy') %} + {{ [ + 'with some clouds.', + 'with partly cloudy skies.', + 'with scatterd clouds' + ] | random }} + {% elif is_state('weather.iron_nerd_weather_station', 'sunny') %} + {% if is_state('sun.sun', 'above_horizon') %} + {{ [ + 'and sunny.', + 'with sun.' + ] | random }} + {% else %} + {{ [ + 'and clear.', + 'with clear skies.' + ] | random }} + {% endif %} + {% else %} + and {{ states.weather.iron_nerd_weather_station.state }} + {% endif %} + {%- endmacro -%} + {# a macro that removes all newline characters, empty spaces, and returns formatted text #} + {%- macro cleanup(data) -%} + {%- for item in data.split("\n") if item | trim != "" -%} + {{ item | trim }} {% endfor -%} + {%- endmacro -%} + {# a macro to call all macros :) #} + {%- macro mother_of_all_macros() -%} + {{ getReport() }} + {%- endmacro -%} + + {# Call the macro #} + {{- cleanup(mother_of_all_macros()) -}} + current_conditions_detail: + friendly_name: Current Conditions Detail + unit_of_measurement: '' + icon_template: mdi:weather-sunny + value_template: >- + {%- macro getReport() -%} + The Weather in Defiance + {{ [ + ' is ', + ' is currently ' + ] | random }} + {{states('sensor.pirateweather_temperature')|round}} degrees + {% if is_state('weather.iron_nerd_weather_station', 'rainy') %} + {{ [ + 'with rain.', + 'with showers.' + ] | random }} + {% elif is_state('weather.iron_nerd_weather_station', 'cloudy') %} + {{ [ + 'with clouds.', + 'with cloudy skies.' + ] | random }} + {% elif is_state('weather.iron_nerd_weather_station', 'partlycloudy') %} + {{ [ + 'with some clouds.', + 'with partly cloudy skies.', + 'with scatterd clouds' + ] | random }} + {% elif is_state('weather.iron_nerd_weather_station', 'sunny') %} + {% if is_state('sun.sun', 'above_horizon') %} + {{ [ + 'and sunny.', + 'with sun.' + ] | random }} + {% else %} + {{ [ + 'and clear.', + 'with clear skies.' + ] | random }} + {% endif %} + {% else %} + and {{ states.weather.iron_nerd_weather_station.state }} + {% endif %} + {%- if is_state('binary_sensor.night','off')%} + {{ [ + 'Later Today ', + 'For the rest of the day' + ] | random }} + expect a high of {{ state_attr('sensor.current_forecast','high_temp') }} + {%- if states('sensor.current_forecast') == 'sunny' and is_state('binary_sensor.night','off')%} + {{ [ + 'and sunny.', + 'with sun.', + 'with sunny conditions prevailing.' + ] | random }} + {%- elif states('sensor.current_forecast') == 'sunny' and is_state('binary_sensor.night','on') %} + {{ [ + 'and clear.', + 'with clear skies.' + ] | random }} + {%- elif states('sensor.current_forecast') == 'clear-night' %} + {{ [ + 'and clear.', + 'with clear skies.' + ] | random }} + {%- elif states('sensor.current_forecast') == 'rainy' %} + {{ [ + 'with rain.', + 'with showers.', + 'and rainy.' + ] | random }} + {{ [ + 'Rainfall accumulations ', + 'Total Rainfall amounts ' + ] | random }} + near {{ state_attr('sensor.current_forecast','precipitation') }} inches + possible. + {%- elif states('sensor.current_forecast') == 'snowy' %} + {{ [ + 'with snow.', + 'with snow showers.' + ] | random }} + {{ [ + 'Snowfall accumulations ', + 'Total snowfall amounts ' + ] | random }} + near {{ state_attr('sensor.current_forecast','precipitation') }} inches + possible. + {%- elif states('sensor.current_forecast') == 'snowy-rainy' %} + {{ [ + 'with mix preciptation possible.', + 'with snow and rain showers.' + ] | random }} + Total accumulation near {{ state_attr('sensor.current_forecast','precipitation') }} inches + possible. + {%- elif states('sensor.current_forecast') == 'windy' %} + {{ [ + 'and windy.', + 'with lots of wind.' + ] | random }} + {%- elif states('sensor.current_forecast') == 'fog' %} + {{ [ + 'and foggy.', + 'with some fog.' + ] | random }} + {% elif states('sensor.current_forecast') == 'cloudy' %} + {{ [ + 'with clouds.', + 'with cloudy skies.' + ] | random }} + {% elif states('sensor.current_forecast') == 'partlycloudy' %} + {{ [ + 'with some clouds.', + 'with partly cloudy skies.', + 'with scattered clouds' + ] | random }} + {%- elif states('sensor.current_forecast') == 'hail' %} + {{ [ + 'with severve thunderstorms possible.', + 'with hail possible.' + ] | random }} + {{ [ + 'Rainfall accumulations ', + 'Total Rainfall amounts ' + ] | random }} + near {{ state_attr('sensor.current_forecast','precipitation') }} inches + possible. + {%- elif states('sensor.current_forecast') == 'lightning' %} + {{ [ + 'with thunderstorms possible.', + 'with the potential of thunderstorms.' + ] | random }} + {{ [ + 'Rainfall accumulations ', + 'Total Rainfall amounts ' + ] | random }} + near {{ state_attr('sensor.current_forecast','precipitation') }} inches + possible. + {% endif -%} + {{ [ + 'Later tonight expect a low of ', + 'Overnight expect a low of ' + ] | random }} + {{ state_attr('sensor.current_forecast','overnight_low') }} degrees. + {%- else -%} + {{ [ + 'Tonight expect a low of ', + 'Overnight expect a low of ' + ] | random }} + {{ state_attr('sensor.current_forecast','overnight_low') }} degrees. + {% endif %} + {%- endmacro -%} + {# a macro that removes all newline characters, empty spaces, and returns formatted text #} + {%- macro cleanup(data) -%} + {%- for item in data.split("\n") if item | trim != "" -%} + {{ item | trim }} {% endfor -%} + {%- endmacro -%} + {# a macro to call all macros :) #} + {%- macro mother_of_all_macros() -%} + {{ getReport() }} + {%- endmacro -%} + + {# Call the macro #} + {{- cleanup(mother_of_all_macros()) -}} + outside_pressure: + friendly_name: 'Outside Pressure' + value_template: '{{ state_attr(''weather.iron_nerd_weather_station'',''pressure'') }}' + unit_of_measurement: '' + todays_high_temp: + friendly_name: "Today's High Temp" + unit_of_measurement: '' + device_class: temperature + value_template: >- + {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[0] %} + {{ forecast.temperature }} + tonights_low_temp: + friendly_name: "Tonight's Low Temp" + unit_of_measurement: '' + device_class: temperature + value_template: >- + {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[1] %} + {{ forecast.lowtemp }} + clothing_forecast: + friendly_name: "Clothing Forecast" + unit_of_measurement: '' + value_template: >- + {% if is_state('binary_sensor.overnight', 'off') %} + {% set temp = states('sensor.todays_high_temp')|int %} + {% else %} + {% set temp = states('sensor.pirateweather_temperature')|round %} + {% endif %} + {%- if states('sensor.todays_high_temp')|int > 63 %} + {%- if states('sensor.todays_high_temp')|int < 80 %} + Nice + {% elif states('sensor.todays_high_temp')|int > 95 %} + Hot + {% else %} + Toasty + {%- endif %} + {% elif states('sensor.todays_high_temp')|int < 64 %} + {%- if states('sensor.todays_high_temp')|int < 32 %} + Freezing + {% elif states('sensor.todays_high_temp')|int > 50 %} + Chilly + {% else %} + Cold + {%- endif %} + {% else %} + Unknown + {%- endif %} + clothing_forecast_detail: + friendly_name: "Clothing Forecast Detail" + unit_of_measurement: '' + value_template: >- + {% if is_state('binary_sensor.morning','on') %} + Based on the forecasted high temperature, + {% if is_state('sensor.clothing_forecast', 'Freezing') %} + It is going to be freezing today. so I suggest wearing long pants and a heavy coat. + {% elif is_state('sensor.clothing_forecast','Cold') %} + It is going to be cold today. so I suggest wearing long pants and a light jacket. + {% elif is_state('sensor.clothing_forecast', 'Chilly') %} + It is going to be chilly today. so I suggest wearing at least long pants. + {% elif is_state('sensor.clothing_forecast', 'Nice') %} + It is going to be + {{ [ 'nice outside. ', + 'pretty nice outside. ', + 'a good day to be outside. ', + 'rather enjoyable outside. ', + ] | random }} + So I suggest wearing shorts. + {% elif is_state('sensor.clothing_forecast', 'Toasty') %} + It is going to be + {{ [ 'bit warm ', + ' rather warm outside ', + ' almost too hot outside ', + ' a little warm ', + ] | random }} + today. So I suggest wearing shorts. + {% elif is_state('sensor.clothing_forecast', 'Hot') %} + It is going to be + {{ [ 'hot', + 'hotter than the sun ', + 'hotter than hot. but in a lot of bad ways ', + 'hotter than the sun outside ', + 'super hot ', + 'hotter than the inside of a volcano ' + ] | random }} + today. So I suggest wearing shorts. + {% else %} + It is going to be {{ states.sensor.clothing_forecast.state }} today so I suggest wearing shorts. + {% endif %} + {% else %} + Based on the current temperature, + {% if is_state('sensor.clothing_forecast', 'Freezing') %} + It is freezing. so I suggest wearing long pants and a heavy coat if you are going out. + {% elif is_state('sensor.clothing_forecast','Cold') %} + It is cold outside. so I suggest wearing long pants and a light jacket. + {% elif is_state('sensor.clothing_forecast', 'Chilly') %} + It is chilly right now. so I suggest wearing at least long pants + if you are going to venture outside. + {% elif is_state('sensor.clothing_forecast', 'Nice') %} + It is + {{ [ 'nice outside. ', + 'pretty nice outside. ', + 'a good day to be outside. ', + 'rather enjoyable outside. ', + ] | random }} + So I suggest wearing shorts. + {% elif is_state('sensor.clothing_forecast', 'Toasty') %} + It is + {{ [ 'bit warm ', + ' rather warm outside ', + ' almost too hot outside ', + ' a little warm ', + ] | random }} + outside. So I suggest wearing shorts. + {% elif is_state('sensor.clothing_forecast', 'Hot') %} + It is + {{ [ 'hot', + 'hotter than the sun ', + 'hotter than hot. but in a lot of bad ways ', + 'hotter than the sun outside ', + 'super hot ', + 'hotter than the inside of a volcano ' + ] | random }} + outside. So I suggest wearing shorts. + {% else %} + It is {{ states.sensor.clothing_forecast.state }} right now so I suggest wearing shorts. + {% endif %} + {% endif %} + nws_current_visibility: + friendly_name: "Current Visibility" + value_template: "{{ ((state_attr('weather.iron_nerd_studios','visibility') | int) * 0.621371) | round }}" + + current_inside_humidity: + friendly_name: "Current Inside Humidity" + unit_of_measurement: '%' + value_template: "{{ state_attr('climate.home','current_humidity') }}" + # lighting_stike_count: + # friendly_name: "Lightning Strike Count" + # value_template: "{{ states('sensor.acurite_6045m_3078_strcnt') }}" + yesterday_rainfall_in: + friendly_name: "Yesterday Rainfall" + value_template: "{{ state_attr('sensor.daily_rainfall_in', 'last_period') }}" + previous_rainfall: + friendly_name: "Past 48h Rainfall" + value_template: "{{ states('sensor.daily_rainfall_in') | float + state_attr('sensor.daily_rainfall_in', 'last_period') | float }}" + # lightning_warning: + # friendly_name: "Lightning Warning" + # value_template: >- + # {%- if states('sensor.recent_lightning_strikes') | int > 0 %} + # Unsafe + # {% else %} + # Safe + # {%- endif %} + +input_boolean: + freeze_warning: + name: Freeze Warning + icon: mdi:snowflake-alert + weather_alert_texts: + name: Weather Alert Texts + icon: mdi:telegram + lightning_warning: + name: Lightning Warning + icon: mdi:flash-alert + tornado_alarm: + name: Tornado Alarm + icon: mdi:speaker-wireless + tstorm_alarm: + name: T-Storm Alarm + icon: mdi:speaker-wireless + raining: + name: Raining From 1f38822a07589ebbc5b280e46d22fc6346eb756a Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Wed, 30 Mar 2022 19:37:35 -0400 Subject: [PATCH 8/9] Was using the wrong weather provider. Switched to my own template. --- packages/custom_weather.yaml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/custom_weather.yaml b/packages/custom_weather.yaml index 8840ff9..6ae268f 100644 --- a/packages/custom_weather.yaml +++ b/packages/custom_weather.yaml @@ -1,10 +1,10 @@ weather: - platform: template name: "Iron Nerd Weather Station" - condition_template: "{{ states('weather.iron_nerd_studios') }}" + condition_template: "{{ states('weather.iron_nerd_weather_station') }}" temperature_template: "{{ states('sensor.pirateweather_temperature') | float }}" humidity_template: "{{ states('sensor.pirateweather_humidity') | float }}" - forecast_template: "{{ state_attr('weather.iron_nerd_studios', 'forecast') }}" + forecast_template: "{{ state_attr('weather.iron_nerd_weather_station', 'forecast') }}" pressure_template: "{{ states('sensor.barometric_pressure') | float }}" wind_speed_template: "{{ states('sensor.pirateweather_wind_speed') | float }}" wind_bearing_template: "{{ states('sensor.pirateweather_wind_bearing') | float }}" @@ -91,23 +91,23 @@ sensor: unit_of_measurement: '' icon_template: mdi:weather-sunny value_template: >- - {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[0] %} + {% set forecast = state_attr('weather.iron_nerd_weather_station','forecast')[0] %} {{ forecast.condition }} attribute_templates: high_temp: >- - {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[0] %} + {% set forecast = state_attr('weather.iron_nerd_weather_station','forecast')[0] %} {{ forecast.temperature }} overnight_low: >- - {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[1] %} + {% set forecast = state_attr('weather.iron_nerd_weather_station','forecast')[1] %} {{ forecast.templow }} wind_bearing: >- - {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[0] %} + {% set forecast = state_attr('weather.iron_nerd_weather_station','forecast')[0] %} {{ forecast.wind_bearing }} wind_speed: >- - {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[0] %} + {% set forecast = state_attr('weather.iron_nerd_weather_station','forecast')[0] %} {{ forecast.wind_speed }} precipitation: >- - {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[0] %} + {% set forecast = state_attr('weather.iron_nerd_weather_station','forecast')[0] %} {{ forecast.precipitation }} current_forecast_detail: friendly_name: Current Forecast Detail @@ -234,23 +234,23 @@ sensor: unit_of_measurement: '' icon_template: mdi:weather-sunny value_template: >- - {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[1] %} + {% set forecast = state_attr('weather.iron_nerd_weather_station','forecast')[1] %} {{ forecast.condition }} attribute_templates: high_temp: >- - {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[1] %} + {% set forecast = state_attr('weather.iron_nerd_weather_station','forecast')[1] %} {{ forecast.temperature }} overnight_low: >- - {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[2] %} + {% set forecast = state_attr('weather.iron_nerd_weather_station','forecast')[2] %} {{ forecast.templow }} wind_bearing: >- - {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[1] %} + {% set forecast = state_attr('weather.iron_nerd_weather_station','forecast')[1] %} {{ forecast.wind_bearing }} wind_speed: >- - {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[1] %} + {% set forecast = state_attr('weather.iron_nerd_weather_station','forecast')[1] %} {{ forecast.wind_speed }} precipitation: >- - {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[1] %} + {% set forecast = state_attr('weather.iron_nerd_weather_station','forecast')[1] %} {{ forecast.precipitation }} tomorrow_forecast_detail: friendly_name: Tomorrow Forecast Detail @@ -590,14 +590,14 @@ sensor: unit_of_measurement: '' device_class: temperature value_template: >- - {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[0] %} + {% set forecast = state_attr('weather.iron_nerd_weather_station','forecast')[0] %} {{ forecast.temperature }} tonights_low_temp: friendly_name: "Tonight's Low Temp" unit_of_measurement: '' device_class: temperature value_template: >- - {% set forecast = state_attr('weather.iron_nerd_studios','forecast')[1] %} + {% set forecast = state_attr('weather.iron_nerd_weather_station','forecast')[1] %} {{ forecast.lowtemp }} clothing_forecast: friendly_name: "Clothing Forecast" @@ -709,7 +709,7 @@ sensor: {% endif %} nws_current_visibility: friendly_name: "Current Visibility" - value_template: "{{ ((state_attr('weather.iron_nerd_studios','visibility') | int) * 0.621371) | round }}" + value_template: "{{ ((state_attr('weather.iron_nerd_weather_station','visibility') | int) * 0.621371) | round }}" current_inside_humidity: friendly_name: "Current Inside Humidity" From 9ef3e215be22e134a65a0d417fe6da15df4a139f Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Wed, 30 Mar 2022 19:40:52 -0400 Subject: [PATCH 9/9] This is why we don't mass-replace things... --- packages/custom_weather.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/custom_weather.yaml b/packages/custom_weather.yaml index 6ae268f..3d8e316 100644 --- a/packages/custom_weather.yaml +++ b/packages/custom_weather.yaml @@ -1,10 +1,10 @@ weather: - platform: template name: "Iron Nerd Weather Station" - condition_template: "{{ states('weather.iron_nerd_weather_station') }}" + condition_template: "{{ states('weather.iron_nerd_studios') }}" temperature_template: "{{ states('sensor.pirateweather_temperature') | float }}" humidity_template: "{{ states('sensor.pirateweather_humidity') | float }}" - forecast_template: "{{ state_attr('weather.iron_nerd_weather_station', 'forecast') }}" + forecast_template: "{{ state_attr('weather.iron_nerd_studios', 'forecast') }}" pressure_template: "{{ states('sensor.barometric_pressure') | float }}" wind_speed_template: "{{ states('sensor.pirateweather_wind_speed') | float }}" wind_bearing_template: "{{ states('sensor.pirateweather_wind_bearing') | float }}"