-
Notifications
You must be signed in to change notification settings - Fork 37
/
weather.yaml
230 lines (207 loc) · 11.5 KB
/
weather.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# Download the BOM icons from https://github.com/DavidFW1960/bom_forecast/blob/master/bom_icons.zip
# and save them under <config-dir>/www/icons/bom_icons/ (Note this is for the example in the ftp component. This is different to the animated card.)
# For the animated card follow the instructions and put the icons in <config-dir>/www/icons/weather_icons. This is a DIFFERENT icon file to the above.
# Show BOM Satellite and Radar
sensor:
- platform: template
sensors:
bom_current_text:
value_template: >
{% set val = states('sensor.kariong_short_text_0').split('.')[0] %}
{{ val | title }}
uv_cat_formatted:
value_template: "{{ states('sensor.kariong_uv_category_0') | replace('veryhigh', 'Very High') | title }}"
bom_uv_alert:
value_template: >
UV Today: Sun Protection
{{ as_timestamp(states('sensor.kariong_uv_start_time_0'),default='n/a') | timestamp_custom(' %I:%M%p',default='n/a') | lower | replace(" 0", "") }} to {{ as_timestamp(states('sensor.kariong_uv_end_time_0'),default='n/a') | timestamp_custom(' %I:%M%p',default='n/a') | lower | replace(" 0", "") }}, UV Index predicted to reach {{ states('sensor.kariong_uv_max_index_0') }} [{{ states('sensor.uv_cat_formatted') }}]
bom_fire_danger:
value_template: "Fire Danger Today: {{ states('sensor.kariong_fire_danger_0') }}"
# Beaufort
# https://en.wikipedia.org/wiki/Beaufort_scale
beaufort:
value_template: >
{%- if states('sensor.gosford_wind_speed_kilometre') | float(default='n/a') >= 118 -%}
12
{%- elif states('sensor.gosford_wind_speed_kilometre') | float(default='n/a') >= 103 -%}
11
{%- elif states('sensor.gosford_wind_speed_kilometre') | float(default='n/a') >= 89 -%}
10
{%- elif states('sensor.gosford_wind_speed_kilometre') | float(default='n/a') >= 75 -%}
9
{%- elif states('sensor.gosford_wind_speed_kilometre') | float(default='n/a') >= 62 -%}
8
{%- elif states('sensor.gosford_wind_speed_kilometre') | float(default='n/a') >= 50 -%}
7
{%- elif states('sensor.gosford_wind_speed_kilometre') | float(default='n/a') >= 39 -%}
6
{%- elif states('sensor.gosford_wind_speed_kilometre') | float(default='n/a') >= 29 -%}
5
{%- elif states('sensor.gosford_wind_speed_kilometre') | float(default='n/a') >= 20 -%}
4
{%- elif states('sensor.gosford_wind_speed_kilometre') | float(default='n/a') >= 12 -%}
3
{%- elif states('sensor.gosford_wind_speed_kilometre') | float(default='n/a') >= 6 -%}
2
{%- elif states('sensor.gosford_wind_speed_kilometre') | float(default='n/a') >= 2 -%}
1
{%- else -%}
0
{%- endif -%}
# Heatindex
# https://en.wikipedia.org/wiki/Heat_index
heatindex:
unit_of_measurement: °C
device_class: temperature
value_template: >
{%- if states('sensor.gosford_temp') | float(default='n/a') > 27 and states('sensor.gosford_humidity') | float(default='n/a') > 40 -%}
{% set T = states('sensor.gosford_temp') | float(default='n/a') %}
{% set R = states('sensor.gosford_humidity') | float(default='n/a') %}
{% set c1 = -8.78469475556 %}
{% set c2 = 1.61139411 %}
{% set c3 = 2.33854883889 %}
{% set c4 = -0.14611605 %}
{% set c5 = -0.012308094 %}
{% set c6 = -0.0164248277778 %}
{% set c7 = 0.002211732 %}
{% set c8 = 0.00072546 %}
{% set c9 = -0.000003582 %}
{% set HI = c1 + (c2 * T ) + (c3 * R) + ( c4 * T * R ) + ( c5 * T**2 ) + ( c6 * R**2 ) + ( c7 * T**2 * R ) + ( c8 * T * R**2 ) + ( c9 * T**2 * R**2 ) %}
{{ HI | round }}
{%- else -%}
n/a
{%- endif -%}
heatindexrating:
value_template: >
{%- if states('sensor.heatindex') == 'n/a' -%}
Out of range
{%- elif states('sensor.heatindex') | float(default='n/a') >= 54 -%}
Extreme danger: heat stroke imminent
{%- elif states('sensor.heatindex') | float(default='n/a') >= 41 -%}
Danger: cramps, exhaustion heat stroke probable
{%- elif states('sensor.heatindex') | float(default='n/a') >= 32 -%}
Extreme caution: cramps and exhaustion possible
{%- elif states('sensor.heatindex') | float(default='n/a') >= 26 -%}
Caution: fatigue possible
{%- else -%}
Normal
{%- endif -%}
bom_forecast_0:
friendly_name: "Today"
value_template: >
{% if states('sensor.kariong_temp_min_0') == 'unknown' %} {% set min = states('sensor.bom_today_min') %} {% else %} {% set min = states('sensor.kariong_temp_min_0') %} {% endif %}
{% if states('sensor.kariong_temp_max_0') == 'unknown' %} {% set max = states('sensor.bom_today_max') %} {% else %} {% set max = states('sensor.kariong_temp_max_0') %} {% endif %}
{{ max|round(0,default='none')}}°/{{ min|round(0,default='none')}}°/{{states('sensor.kariong_rain_chance_0')|round(0,default='none')}}%
entity_picture_template: >-
{%- if states('sun.sun') == 'below_horizon' and (states('sensor.kariong_icon_descriptor_0') == 'fog' or states('sensor.kariong_icon_descriptor_0') == 'haze' or states('sensor.kariong_icon_descriptor_0') == 'hazy' or states('sensor.kariong_icon_descriptor_0') == 'light-showers' or states('sensor.kariong_icon_descriptor_0') == 'partly-cloudy' or states('sensor.kariong_icon_descriptor_0') == 'showers' or states('sensor.kariong_icon_descriptor_0') == 'shower' or states('sensor.kariong_icon_descriptor_0') == 'light_showers' or states('sensor.kariong_icon_descriptor_0') == 'light_shower' or states('sensor.kariong_icon_descriptor_0') == 'partly_cloudy' or states('sensor.kariong_icon_descriptor_0') == 'mostly_sunny') -%}
{{ '/local/icons/bom_icons/' ~ states('sensor.kariong_icon_descriptor_0') ~ '-night.png' }}
{%- else -%}
{{ '/local/icons/bom_icons/' ~ states('sensor.kariong_icon_descriptor_0') ~ '.png' }}
{%- endif -%}
bom_forecast_1:
friendly_name_template: >
{%- set date = as_timestamp(now(),default='n/a') + (1 * 86400 ) -%}
{{ date | timestamp_custom('Tomorrow (%-d/%-m)',default='n/a') }}
value_template: >
{{states('sensor.kariong_temp_max_1')|round(0)}}°/{{states('sensor.kariong_temp_min_1')|round(0)}}°/{{states('sensor.kariong_rain_chance_1')|round(0)}}%
entity_picture_template: >-
{{ '/local/icons/bom_icons/' ~ states('sensor.kariong_icon_descriptor_1') ~ '.png' }}
bom_forecast_2:
friendly_name_template: >
{%- set date = as_timestamp(now(),default='n/a') + (2 * 86400 ) -%}
{{ date | timestamp_custom('%A (%-d/%-m)',default='n/a') }}
value_template: >
{{states('sensor.kariong_temp_max_2')|round(0)}}°/{{states('sensor.kariong_temp_min_2')|round(0)}}°/{{states('sensor.kariong_rain_chance_2')|round(0)}}%
entity_picture_template: >-
{{ '/local/icons/bom_icons/' ~ states('sensor.kariong_icon_descriptor_2') ~ '.png' }}
bom_forecast_3:
friendly_name_template: >
{%- set date = as_timestamp(now(),default='n/a') + (3 * 86400 ) -%}
{{ date | timestamp_custom('%A (%-d/%-m)',default='n/a') }}
value_template: >
{{states('sensor.kariong_temp_max_3')|round(0)}}°/{{states('sensor.kariong_temp_min_3')|round(0)}}°/{{states('sensor.kariong_rain_chance_3')|round(0)}}%
entity_picture_template: >-
{{ '/local/icons/bom_icons/' ~ states('sensor.kariong_icon_descriptor_3') ~ '.png' }}
bom_forecast_4:
friendly_name_template: >
{%- set date = as_timestamp(now(),default='n/a') + (4 * 86400 ) -%}
{{ date | timestamp_custom('%A (%-d/%-m)',default='n/a') }}
value_template: >
{{states('sensor.kariong_temp_max_4')|round(0)}}°/{{states('sensor.kariong_temp_min_4')|round(0)}}°/{{states('sensor.kariong_rain_chance_4')|round(0)}}%
entity_picture_template: >-
{{ '/local/icons/bom_icons/' ~ states('sensor.kariong_icon_descriptor_4') ~ '.png' }}
bom_forecast_5:
friendly_name_template: >
{%- set date = as_timestamp(now(),default='n/a') + (5 * 86400 ) -%}
{{ date | timestamp_custom('%A (%-d/%-m)',default='n/a') }}
value_template: >
{{states('sensor.kariong_temp_max_5')|round(0)}}°/{{states('sensor.kariong_temp_min_5')|round(0)}}°/{{states('sensor.kariong_rain_chance_5')|round(0)}}%
entity_picture_template: >-
{{ '/local/icons/bom_icons/' ~ states('sensor.kariong_icon_descriptor_5') ~ '.png' }}
bom_forecast_6:
friendly_name_template: >
{%- set date = as_timestamp(now(),default='n/a') + (6 * 86400 ) -%}
{{ date | timestamp_custom('%A (%-d/%-m)',default='n/a') }}
value_template: >
{{states('sensor.kariong_temp_max_6')|round(0,default='unknown')}}°/{{states('sensor.kariong_temp_min_6')|round(0,default='unknown')}}°/{{states('sensor.kariong_rain_chance_6')|round(0,default='unknown')}}%
entity_picture_template: >-
{{ '/local/icons/bom_icons/' ~ states('sensor.kariong_icon_descriptor_6') ~ '.png' }}
# ONLY USE ONE bom_today_max below:
bom_today_max:
value_template: >
{{ state_attr('sensor.today_temp_bom', 'max_value') }}
# bom_today_max:
# value_template: >
# {%- if states('sensor.kariong_temp_max_0') == 'unknown' -%}
# {{ state_attr('sensor.today_temp_bom', 'max_value') }}
# {% else %}
# {{ states('sensor.kariong_temp_max_0') }}
# {% endif %}
# ONLY USE ONE bom_today_min below:
bom_today_min:
value_template: >
{{ state_attr('sensor.today_temp_bom', 'min_value') }}
# bom_today_min:
# value_template: >
# {%- if states('sensor.kariong_temp_min_0') == 'unknown' -%}
# {{ state_attr('sensor.today_temp_bom', 'min_value') }}
# {% else %}
# {{ states('sensor.kariong_temp_min_0') }}
# {% endif %}
# IMPORTANT NOTE IF YOU USE average, you must comment out the below statistics sensor. Both cannot exist
# https://github.com/Limych/ha-average
- platform: average
name: today_temp_bom
entities:
- sensor.gosford_temp
start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
end: '{{ now() }}'
# IMPORTANT NOTE IF YOU USE statistics, you must comment out the above average sensor. Both cannot exist
# - platform: statistics
# name: today_temp_bom_min
# sampling_size: 150
# entity_id: sensor.gosford_temp
# state_characteristic: value_min
# max_age:
# hours: 24
# - platform: statistics
# name: today_temp_bom_max
# sampling_size: 150
# entity_id: sensor.gosford_temp
# state_characteristic: value_max
# max_age:
# hours: 24
automation:
- alias: 'Update BOM Icons'
trigger:
- event: start
platform: homeassistant
- entity_id: sun.sun
platform: state
to: 'above_horizon'
- entity_id: sun.sun
platform: state
to: 'below_horizon'
action:
- service: homeassistant.update_entity
entity_id: sensor.bom_forecast_0, sensor.bom_forecast_1, sensor.bom_forecast_2, sensor.bom_forecast_3, sensor.bom_forecast_4, sensor.bom_forecast_5 #, sensor.bom_forecast_6