-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.yaml
185 lines (175 loc) · 5.85 KB
/
configuration.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
# Sources:
# https://github.com/Xorfor/Domoticz-PWS-Plugin/blob/master/plugin.py
# https://community.home-assistant.io/t/weather-station-recommendation/55353/23
# https://www.home-assistant.io/integrations/template/
#
template:
- trigger:
- platform: webhook
webhook_id: pws
allowed_methods:
- POST
local_only: true
sensor:
#
# --------------------------------------------------------------------------------
#
# Temperature
#
- name: "PWS - Temperature"
device_class: temperature
unit_of_measurement: "°C"
state: "{{ ((trigger.data.tempf | float - 32) / 1.8) | round(1) }}"
- name: "PWS - Temperature (indoor)"
device_class: temperature
unit_of_measurement: "°C"
state: "{{ ((trigger.data.tempinf | float - 32) / 1.8) | round(1) }}"
#
# --------------------------------------------------------------------------------
#
# Humidity
#
- name: "PWS - Humidity"
device_class: humidity
unit_of_measurement: "%"
state: "{{ trigger.data.humidity }}"
- name: "PWS - Humidity (indoor)"
device_class: humidity
unit_of_measurement: "%"
state: "{{ trigger.data.humidityin }}"
#
# --------------------------------------------------------------------------------
#
# Barometer
#
- name: "PWS - Barometer (relative)"
device_class: pressure
unit_of_measurement: "hPa"
state: "{{ (trigger.data.baromrelin | float * 33.86) | round(1) }}"
- name: "PWS - Barometer (absolute)"
device_class: pressure
unit_of_measurement: "hPa"
state: "{{ (trigger.data.baromabsin | float * 33.86) | round(1) }}"
#
# --------------------------------------------------------------------------------
#
# Rain
#
- name: "PWS - Rainrate"
unit_of_measurement: "mm/h"
state: "{{ (trigger.data.rainratein | float * 2.54 * 10) | round(1) }}"
- name: "PWS - Rain"
unit_of_measurement: "mm"
state: "{{ (trigger.data.dailyrainin | float * 2.54 * 10) | round(1) }}"
#
# --------------------------------------------------------------------------------
#
# Sun
#
- name: "PWS - Solar radiation"
device_class: illuminance
unit_of_measurement: "W/m²"
state: "{{ trigger.data.solarradiation | float }}"
- name: "PWS - UV"
device_class: illuminance
unit_of_measurement: "UV Index"
state: "{{ trigger.data.uv }}"
#
# --------------------------------------------------------------------------------
#
# Wind
#
- name: "PWS - Wind speed"
unit_of_measurement: "m/s"
state: "{{ (trigger.data.windspeedmph | float * 0.44704) | round(1) }}"
- name: "PWS - Wind gust"
unit_of_measurement: "m/s"
state: "{{ (trigger.data.windgustmph | float * 0.44704) | round(1) }}"
- name: "PWS - Wind direction"
unit_of_measurement: "°"
state: "{{ trigger.data.winddir }}"
- name: "PWS - Wind direction (text)"
state: >-
{% set direction = ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW', 'N'] %}
{% set degree = states('sensor.pws_wind_direction') | float %}
{{ direction[((degree + 11.25) / 22.5) | int] }}
#
# --------------------------------------------------------------------------------
#
# Misc
#
- name: "PWS - Stationtype"
state: "{{ trigger.data.stationtype }}"
- name: "PWS - Model"
state: "{{ trigger.data.model }}"
#
# --------------------------------------------------------------------------------
#
# Ecowitt does not support the extra information as with Wunderground, so lets calculate them
#
# Dewpoint
#
# https://www.ajdesigner.com/phphumidity/dewpoint_equation_dewpoint_temperature.php
#
- name: "PWS - Dewpoint"
device_class: temperature
unit_of_measurement: "°C"
state: "{{ ((trigger.data.humidity | float / 100) ** (1 / 8) * (112 + 0.9 * ((trigger.data.tempf | float - 32) / 1.8)) + 0.1 * ((trigger.data.tempf | float - 32) / 1.8) - 112) | round(1) }}"
#
# Windchill
#
# https://en.wikipedia.org/wiki/Wind_chill
#
- name: "PWS - Windchill"
device_class: temperature
unit_of_measurement: "°C"
state: >
{% set v = states('sensor.pws_wind_speed') | float %}
{% set t = states('sensor.pws_temperature') | float %}
{% if t > -46.0 and t < 10.0 and v > 1.3 and v < 49.0 %}
{% set w = v ** 0.16 %}
{{ (13.12 + 0.6215 * t - 13.96 * w + 0.4867 * t * w) | round(1) }}
{% else %}
{{ t }}
{% endif %}
#
# --------------------------------------------------------------------------------
#
# Extra
#
#
# Heat index
#
# https://en.wikipedia.org/wiki/Heat_index
#
- name: "PWS - Heat index"
device_class: temperature
unit_of_measurement: "°C"
state: >
{% set t = states('sensor.pws_temperature') | float %}
{% set h = states('sensor.pws_humidity') | float %}
{% if t >= 26 and h >= 0.0 and h <= 100.0 %}
{% set tp = t ** 2 %}
{% set hp = h ** 2 %}
{{ (-8.78469475556
+ 1.61139411 * t
+ 2.33854883889 * h
+ -0.14611605 * t * h
+ -0.012308094 * tp
+ -0.0164248277778 * hp
+ 0.002211732 * tp * h
+ 0.00072546 * t * hp
+ -0.000003582 * tp * hp
) | round(1) }}
{% else %}
{{ t }}
{% endif %}
#
# --------------------------------------------------------------------------------
#
# Data
#
- name: "PWS - platform"
state: "{{ trigger.platform }}"
- name: "PWS - webhook_id"
state: "{{ trigger.webhook_id }}"