Swaping out Darksky for NWS....

This commit is contained in:
Jeffrey Stone 2020-04-02 19:16:50 -04:00
parent 0e3f774d43
commit a494704e36
5 changed files with 376 additions and 260 deletions

View File

@ -45,9 +45,12 @@ wemo:
- 192.168.7.99 - 192.168.7.99
weather: weather:
- platform: darksky # REMOVING darksky integration since API is EOL in 18 months. Migrated to NWS
api_key: !secret darksky_api # - platform: darksky
name: Grayson # api_key: !secret darksky_api
# name: Grayson
- platform: nws
api_key: !secret nws_api_key
conversation: conversation:
@ -177,6 +180,7 @@ tplink:
- host: 192.168.7.116 - host: 192.168.7.116
- host: 192.168.7.120 - host: 192.168.7.120
- host: 192.168.7.136 - host: 192.168.7.136
- host: 192.168.7.137
ifttt: ifttt:
key: !secret IFTTT_API_KEY key: !secret IFTTT_API_KEY

View File

@ -64,8 +64,12 @@ automation:
initial_state: true initial_state: true
trigger: trigger:
- platform: state - platform: state
entity_id: media_player.theater entity_id: media_player.ha_speaker
to: 'unavailable' to: 'unavailable'
condition:
- condition: state
entity_id: binary_sensor.day
state: 'on'
action: action:
- service: input_boolean.turn_off - service: input_boolean.turn_off
entity_id: input_boolean.audible_notifications entity_id: input_boolean.audible_notifications
@ -80,15 +84,20 @@ automation:
initial_state: true initial_state: true
trigger: trigger:
- platform: state - platform: state
entity_id: media_player.theater entity_id: media_player.ha_speaker
from: 'unavailable' from: 'unavailable'
to: 'off' to: 'off'
condition:
- condition: state
entity_id: binary_sensor.day
state: 'on'
action: action:
- service: script.text_notify - service: script.text_notify
data_template: data_template:
who: "jeff" who: "jeff"
title: "Audio Issue Cleared" title: "Audio Issue Cleared"
message: "Main hromecast is back on" message: "Main hromecast is back on"
- service: script.turn_on_ha_speaker
@ -213,10 +222,10 @@ script:
payload: 'This message is from {{ now().strftime("%-I") }}:{{ now().strftime("%M") }} {{ now().strftime("%p") }}. {{ message | truncate(220)}}' payload: 'This message is from {{ now().strftime("%-I") }}:{{ now().strftime("%M") }} {{ now().strftime("%p") }}. {{ message | truncate(220)}}'
retain: true retain: true
- service: media_player.turn_on - service: media_player.turn_on
entity_id: media_player.theater entity_id: media_player.ha_speaker
- service: media_player.volume_set - service: media_player.volume_set
data_template: data_template:
entity_id: media_player.theater entity_id: media_player.ha_speaker
volume_level: > volume_level: >
{% if states.input_boolean.audible_notifications.state == 'on' %} {% if states.input_boolean.audible_notifications.state == 'on' %}
.50 .50
@ -228,7 +237,7 @@ script:
data_template: data_template:
entity_id: > entity_id: >
{% if states.input_boolean.audible_notifications.state == 'on' %} {% if states.input_boolean.audible_notifications.state == 'on' %}
media_player.theater media_player.ha_speaker
{% else %} {% else %}
media_player.house media_player.house
{% endif %} {% endif %}
@ -292,10 +301,10 @@ script:
# - service: switch.turn_on # - service: switch.turn_on
# entity_id: switch.ha_speaker # entity_id: switch.ha_speaker
- service: media_player.turn_on - service: media_player.turn_on
entity_id: media_player.theater entity_id: media_player.ha_speaker
- service: media_player.volume_set - service: media_player.volume_set
data_template: data_template:
entity_id: media_player.theater entity_id: media_player.ha_speaker
volume_level: > volume_level: >
{% if states.input_boolean.audible_notifications.state == 'on' %} {% if states.input_boolean.audible_notifications.state == 'on' %}
.65 .65
@ -307,7 +316,7 @@ script:
data_template: data_template:
entity_id: > entity_id: >
{% if states.input_boolean.audible_notifications.state == 'on' %} {% if states.input_boolean.audible_notifications.state == 'on' %}
media_player.theater media_player.ha_speaker
{% else %} {% else %}
media_player.house media_player.house
{% endif %} {% endif %}
@ -441,9 +450,12 @@ script:
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}
{% macro weather_alerts() %} {% macro weather_alerts() %}
{% if states.sensor.nws_alerts.state | int > 0 %}
There are currently {{states.sensor.nws_alerts.state }} active weather alerts for our area. There are currently {{states.sensor.nws_alerts.state }} active weather alerts for our area.
The National Weather Service Has issued, The National Weather Service Has issued,
{% if states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[5] is defined %} {% if states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[5] is defined %}
@ -459,6 +471,7 @@ script:
{% else %} {% else %}
a {{ states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[0] }}. a {{ states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[0] }}.
{% endif %} {% endif %}
{% endif %}
{% endmacro %} {% endmacro %}
{% macro todays_events() %} {% macro todays_events() %}
@ -469,7 +482,7 @@ script:
Merry Christmas Everyone! Merry Christmas Everyone!
{% endif %} {% endif %}
{% if is_state('sensor.anniversary_our_wedding','0') %} {% if is_state('sensor.anniversary_our_wedding','0') %}
Happy Anniversary! It has been an amazing {{ states.sensor.anniversary_our_wedding.attributes.years }} years! Happy Anniversary! It been an amazing {{ states.sensor.anniversary_our_wedding.attributes.years }} years!
{% endif %} {% endif %}
{% if is_state('calendar.holidays_in_united_states', 'on') %} {% if is_state('calendar.holidays_in_united_states', 'on') %}
Today is {{states.calendar.holidays_in_united_states.attributes.message}}. Today is {{states.calendar.holidays_in_united_states.attributes.message}}.
@ -492,7 +505,7 @@ script:
'You should tell someone it is ', 'You should tell someone it is ',
'Everyday can be a holiday. So today is ' 'Everyday can be a holiday. So today is '
]|random }} ]|random }}
{{states.calendar.national_holidays.attributes.message}}. {{states.calendar.national_holidays.attributes.message | replace("&"," and ") }}.
{{ [ {{ [
'We should celebrate.', 'We should celebrate.',
'I will leave the party planning up to <emphasis>you</emphasis>', 'I will leave the party planning up to <emphasis>you</emphasis>',
@ -515,8 +528,13 @@ script:
]|random }} ]|random }}
{%- endmacro -%} {%- endmacro -%}
{% macro current_conditions_outisde() %} {% macro current_conditions_outside() %}
It is currently {{states.sensor.dark_sky_summary.state}} and {{states.sensor.dark_sky_temperature.state|round}} degrees in Grayson. {{ [
'According to the National Weather Service,',
'Checking my weather sensors,',
'Looking outside,'
]|random }}
It is currently {{states.weather.home_2.state}} and {{states.nws_current_temperature.state|round}} degrees in Grayson.
The back porch is {{states.sensor.accurite_back_porch_temperature.state|round}} degrees. The back porch is {{states.sensor.accurite_back_porch_temperature.state|round}} degrees.
{% endmacro %} {% endmacro %}
@ -536,20 +554,28 @@ script:
{% endmacro %} {% endmacro %}
{% macro daily_forecast() %} {% macro daily_forecast() %}
The rest of the day should be {{states.sensor.dark_sky_summary_0d.state}} with a high of {{states.sensor.dark_sky_daytime_high_temperature_0d.state|round}} degrees. There is a {{states.sensor.dark_sky_precip_probability_0d.state|round}} percent chance of rain. {{ [
'The National Weather Service says,',
'According to the latest forecast,'
]|random }}
The rest of the day should be {{ states.sensor.nws_current_forecast.state }}
{% endmacro %} {% endmacro %}
{% macro overnight_forecast() %} {% macro overnight_forecast() %}
The low tonight will be {{states.sensor.dark_sky_overnight_low_temperature_0d.state | round}} degrees and there is a {{states.sensor.dark_sky_precip_probability_0d.state|round}} percent chance of rain. {{ [
'Tonight we can expect,',
'According to tonights forecast we can expect,'
]|random }}
{{ states.sensor.nws_overnight_forecast.state }}
{% endmacro %} {% endmacro %}
{% macro future_forecast() %} {% macro future_forecast() %}
{{ [ 'Looking into the future you can expect, ', {{ [ 'Looking into the future plan for tomorrow to be, ',
' According to the forecast, there might be ', ' According to tomorrows forecast we can expect it to be, ',
'If you have not seen the forecast, you might want to plan for ' 'If you have not seen tomorrows forecast it is expected to be, '
] | random }} ] | random }}
{{states.sensor.dark_sky_daily_summary.state}}. {{states.sensor.nws_future_forecast.state}}.
{% endmacro %} {% endmacro %}
{% macro freeze_warning() %} {% macro freeze_warning() %}
@ -1036,12 +1062,17 @@ script:
] | random }} ] | random }}
{%- endmacro -%} {%- 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 -%}
{# ********************************************* #} {# ********************************************* #}
{# ******** Start the Speech routines ******** #} {# ******** Start the Speech routines ******** #}
{# ********************************************* #} {# ********************************************* #}
{# a macro to call all macros :) #}
{%- macro mother_of_all_macros() -%}
{% if call_greeting == 1 %} {% if call_greeting == 1 %}
{{ greeting() }} {{ greeting() }}
{% endif %} {% endif %}
@ -1221,7 +1252,9 @@ script:
{% if call_snark_door_open == 1 %} {% if call_snark_door_open == 1 %}
{{ snark_door_open() }} {{ snark_door_open() }}
{% endif %} {% endif %}
{%- endmacro -%}
{{- cleanup(mother_of_all_macros()) -}}
############################################################################### ###############################################################################
# Twitter # Twitter
@ -1281,7 +1314,7 @@ script:
- service: script.ah_report - service: script.ah_report
data: data:
call_weather_alerts: 1 call_weather_alerts: 1
call_current_conditions_outisde: 1 call_current_conditions_outside: 1
call_current_conditions_inside: 1 call_current_conditions_inside: 1
call_current_conditions_garage: 1 call_current_conditions_garage: 1
call_daily_forecast: 1 call_daily_forecast: 1

View File

@ -227,7 +227,10 @@ automation:
initial_state: 'on' initial_state: 'on'
trigger: trigger:
- platform: numeric_state - platform: numeric_state
entity_id: sensor.dark_sky_overnight_low_temperature_0d entity_id: sensor.nws_overnight_low
below: 35
- platform: numeric_state
entity_id: sensor.nws_current_temperature
below: 35 below: 35
condition: condition:
- condition: state - condition: state
@ -241,14 +244,14 @@ automation:
initial_state: 'on' initial_state: 'on'
trigger: trigger:
- platform: numeric_state - platform: numeric_state
entity_id: sensor.accurite_back_porch_temperature entity_id: sensor.nws_overnight_low
above: 33 above: 33
condition: condition:
- condition: state - condition: state
entity_id: input_boolean.freeze_warning entity_id: input_boolean.freeze_warning
state: 'on' state: 'on'
- condition: numeric_state - condition: numeric_state
entity_id: sensor.dark_sky_overnight_low_temperature_0d entity_id: sensor.nws_overnight_low
above: 35 above: 35
action: action:
- service: input_boolean.turn_off - service: input_boolean.turn_off
@ -276,7 +279,7 @@ automation:
- service: script.turn_off - service: script.turn_off
entity_id: script.tornado_alarm entity_id: script.tornado_alarm
- service: media_player.media_stop - service: media_player.media_stop
entity_id: media_player.theater entity_id: media_player.ha_speaker
script: script:
@ -304,14 +307,14 @@ script:
- delay: - delay:
seconds: 15 seconds: 15
- service: media_player.play_media - service: media_player.play_media
entity_id: media_player.theater entity_id: media_player.ha_speaker
data: data:
media_content_id: http://192.168.7.40/audio/tornado_alarm.mp3 media_content_id: http://192.168.7.40/audio/tornado_alarm.mp3
media_content_type: "music" media_content_type: "music"
- delay: - delay:
seconds: 110 seconds: 110
- service: media_player.play_media - service: media_player.play_media
entity_id: media_player.theater entity_id: media_player.ha_speaker
data: data:
media_content_id: http://192.168.7.40/audio/tornado_alarm.mp3 media_content_id: http://192.168.7.40/audio/tornado_alarm.mp3
media_content_type: "music" media_content_type: "music"

View File

@ -1,6 +1,13 @@
# Sensor to get Flu near you: https://www.home-assistant.io/integrations/flunearyou/
- platform: flunearyou
# MQTT Sensor for Washing Machine Status.
- platform: mqtt - platform: mqtt
name: "Washer Status" name: "Washer Status"
state_topic: "house/washer/status" state_topic: "house/washer/status"
# MQTT Sensor for getting Various COVID-19 Stats. Data is sourced from pythonn scripts scaping
# various COVID data sites running on a secondary machine.
- platform: mqtt - platform: mqtt
name: "COVID19 Confirmed" name: "COVID19 Confirmed"
state_topic: "covid/sensor/confirmed" state_topic: "covid/sensor/confirmed"
@ -173,12 +180,24 @@
duration: duration:
hours: 24 hours: 24
- platform: statistics - platform: statistics
name: Cloud Coverage Stats name: Wind Speed Stats
entity_id: sensor.dark_sky_cloud_coverage entity_id: sensor.nws_current_windspeed
sampling_size: 500 sampling_size: 500
- platform: statistics - platform: statistics
name: Visibility Stats name: Visibility Stats
entity_id: sensor.dark_sky_visibility entity_id: sensor.nws_current_visibility
sampling_size: 500
- platform: statistics
name: Temperature Stats
entity_id: sensor.nws_current_temperature
sampling_size: 500
- platform: statistics
name: Humidity Stats
entity_id: sensor.nws_current_humidity
sampling_size: 500
- platform: statistics
name: Washer Power Stats
entity_id: sensor.washer_power
sampling_size: 500 sampling_size: 500
- platform: history_stats - platform: history_stats
name: Cooling Last Month name: Cooling Last Month
@ -272,4 +291,3 @@
value_template: "{{states.climate.home.attributes.hvac_action}}" value_template: "{{states.climate.home.attributes.hvac_action}}"

View File

@ -1,38 +1,39 @@
- platform: darksky # REMOVING Darksky - Commented out to disable.
api_key: !secret FORCAST_API_KEY # - platform: darksky
forecast: # api_key: !secret FORCAST_API_KEY
- 0 # forecast:
monitored_conditions: # - 0
- summary # monitored_conditions:
- icon # - summary
- nearest_storm_distance # - icon
- nearest_storm_bearing # - nearest_storm_distance
- precip_type # - nearest_storm_bearing
- precip_intensity # - precip_type
- precip_probability # - precip_intensity
- temperature # - precip_probability
- temperature_high # - temperature
- temperature_low # - temperature_high
- apparent_temperature # - temperature_low
- dew_point # - apparent_temperature
- wind_speed # - dew_point
- wind_bearing # - wind_speed
- cloud_cover # - wind_bearing
- humidity # - cloud_cover
- pressure # - humidity
- visibility # - pressure
- ozone # - visibility
- minutely_summary # - ozone
- hourly_summary # - minutely_summary
- daily_summary # - hourly_summary
- precip_intensity_max # - daily_summary
scan_interval: # - precip_intensity_max
# At least one of these must be specified: # scan_interval:
days: 0 # # At least one of these must be specified:
hours: 0 # days: 0
minutes: 5 # hours: 0
seconds: 0 # minutes: 5
milliseconds: 0 # seconds: 0
# milliseconds: 0
## Accurite 158 - Back Porch ## Accurite 158 - Back Porch
- platform: mqtt - platform: mqtt
name: "Accurite Back Porch Temperature" name: "Accurite Back Porch Temperature"
@ -71,18 +72,18 @@
friendly_name: "Clothing Forecast" friendly_name: "Clothing Forecast"
unit_of_measurement: '' unit_of_measurement: ''
value_template: >- value_template: >-
{%- if states('sensor.dark_sky_daytime_high_temperature_0d')|float > 63 %} {%- if states('sensor.nws_daytime_temperature')|float > 63 %}
{%- if states('sensor.dark_sky_daytime_high_temperature_0d')|float < 80 %} {%- if states('sensor.nws_daytime_temperature')|float < 80 %}
Nice Nice
{% elif states('sensor.dark_sky_daytime_high_temperature_0d')|float > 95 %} {% elif states('sensor.nws_daytime_temperature')|float > 95 %}
Hot Hot
{% else %} {% else %}
Toasty Toasty
{%- endif %} {%- endif %}
{% elif states('sensor.dark_sky_daytime_high_temperature_0d')|float < 64 %} {% elif states('sensor.nws_daytime_temperature')|float < 64 %}
{%- if states('sensor.dark_sky_daytime_high_temperature_0d')|float < 32 %} {%- if states('sensor.nws_daytime_temperature')|float < 32 %}
Freezing Freezing
{% elif states('sensor.dark_sky_daytime_high_temperature_0d')|float > 50 %} {% elif states('sensor.nws_daytime_temperature')|float > 50 %}
Chilly Chilly
{% else %} {% else %}
Cold Cold
@ -90,3 +91,60 @@
{% else %} {% else %}
Unknown Unknown
{%- endif %} {%- endif %}
nws_current_forecast:
friendly_name: 'Current Forecast'
value_template: "{{ states.weather.klzu.attributes.forecast[0].detailed_description }}"
nws_current_temperature:
friendly_name: 'Current Temperature'
value_template: "{{ states.weather.klzu.attributes.temperature }}"
nws_daytime_temperature:
friendly_name: 'Daytime Temperature'
value_template: >-
{% if states.weather.klzu.attributes.forecast[0].daytime == True %}
{{ states.weather.klzu.attributes.forecast[0].temperature }}
{% elif states.weather.klzu.attributes.forecast[1].daytime == True %}
{{ states.weather.klzu.attributes.forecast[1].temperature }}
{% endif %}
nws_current_condition:
friendly_name: 'Current Condition'
value_template: "{{ states.weather.klzu.state }}"
nws_current_humidity:
friendly_name: 'Current Humidity'
value_template: "{{ states.weather.klzu.attributes.humidity }}"
nws_current_visibility:
friendly_name: "Current Visability"
value_template: "{{ states.weather.klzu.attributes.visibility }}"
nws_current_windspeed:
friendly_name: "Current Windspeed"
value_template: "{{ states.weather.klzu.attributes.wind_speed }}"
nws_overnight_low:
friendly_name: "Overnight Low"
unit_of_measurement: ''
value_template: >-
{% if states.weather.klzu.attributes.forecast[0].daytime == False %}
{{ states.weather.klzu.attributes.forecast[0].temperature }}
{% elif states.weather.klzu.attributes.forecast[1].daytime == False %}
{{ states.weather.klzu.attributes.forecast[1].temperature }}
{% endif %}
nws_overnight_forecast:
friendly_name: "Overnight Forecast"
unit_of_measurement: ''
value_template: >-
{% if states.weather.klzu.attributes.forecast[0].daytime == False %}
{{ states.weather.klzu.attributes.forecast[0].detailed_description }}
{% elif states.weather.klzu.attributes.forecast[1].daytime == False %}
{{ states.weather.klzu.attributes.forecast[1].detailed_description }}
{% elif states.weather.klzu.attributes.forecast[2].daytime == False %}
{{ states.weather.klzu.attributes.forecast[2].detailed_description }}
{% endif %}
nws_future_forecast:
friendly_name: "Future Forecast"
unit_of_measurement: ''
value_template: >-
{%- if states.weather.klzu.attributes.forecast[1].daytime == True %}
{{ states.weather.klzu.attributes.forecast[1].detailed_description }}
before becoming {{ states.weather.klzu.attributes.forecast[2].detailed_description }} tomorrow night
{% elif states.weather.klzu.attributes.forecast[2].daytime == True %}
{{ states.weather.klzu.attributes.forecast[2].detailed_description }}
before becoming {{ states.weather.klzu.attributes.forecast[3].detailed_description }} tomorrow night
{%- endif %}