-
Notifications
You must be signed in to change notification settings - Fork 96
/
sensor.yaml
301 lines (284 loc) · 13.6 KB
/
sensor.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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
- platform: dnsip
- platform: season
type: astronomical
- platform: uptime
- platform: version
- platform: mqtt
state_topic: "owntracks/Nico/Nico"
name: "Batteria Telefono Nico"
unit_of_measurement: "%"
value_template: '{{ value_json.batt }}'
- platform: mqtt
state_topic: "owntracks/mamma/mamma"
name: "Batteria Telefono Mamma"
unit_of_measurement: "%"
value_template: '{{ value_json.batt }}'
- platform: darksky
api_key: !secret darksky
forecast:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
monitored_conditions:
- summary
- icon
- temperature
- temperature_low
- temperature_high
- apparent_temperature
- humidity
- hourly_summary
- daily_summary
- precip_type
- precip_intensity
- precip_probability
#- precip_accumulation
- wind_speed
- wind_bearing
- pressure
- visibility
- ozone
- uv_index
- sunrise_time
- sunset_time
scan_interval:
# At least one of these must be specified:
days: 0
hours: 1
minutes: 0
seconds: 0
milliseconds: 0
- platform: template
sensors:
data_e_ora:
entity_id: sensor.time
value_template: >
{{now().strftime("%d/%m/%Y - %H:%M")}}
friendly_name: "Data e Ora"
icon_template: mdi:calendar-clock
dark_sky_summary_tmpl:
friendly_name_template: Condizione
value_template: >
{{ states('sensor.dark_sky_summary') }}
entity_picture_template: >-
{{ '/local/icons/dark_sky/' ~ states.sensor.dark_sky_icon.state ~ '.png'}}
dark_sky_hourly_summary_tmpl:
friendly_name_template: Condizione Giornaliera
value_template: >
{{ states('sensor.dark_sky_hourly_summary') }}
entity_picture_template: >-
{{ '/local/icons/dark_sky/' ~ states.sensor.dark_sky_hourly_summary.attributes.entity_picture | replace("/static/images/darksky/","") | replace(".svg","") ~ '.png'}}
dark_sky_wind_dir:
friendly_name: 'Direzione Vento'
value_template: >-
{% set wind_dir = states.weather.dark_sky_wind_bearing.state %}
{% if wind_dir | float<=23 %}Nord [Tramontana]
{% elif wind_dir | float>338 %}Nord [Tramontana]
{% elif 23 < (wind_dir|float) <=68 %}NE [Grecale]
{% elif 68 < (wind_dir|float) <=113 %}Est [Levante]
{% elif 113 < (wind_dir|float) <=158 %}SE [Scirocco]
{% elif 158 < (wind_dir|float) <=203 %}Sud [Ostro]
{% elif 203 < (wind_dir|float) <=248 %}SO [Libeccio]
{% elif 248 < (wind_dir|float) <=293 %}Ovest [Ponente]
{% elif 293 < (wind_dir|float) <=338 %}NO [Maestrale]
{%- endif %}
icon_template: mdi:compass
forecast_0:
friendly_name_template: Giorno
value_template: Max | Min | Pioggia
icon_template: mdi:weather-partlycloudy
forecast_1:
friendly_name_template: >
{%- set date = as_timestamp(now()) + (1 * 86400 ) -%}
{% set giorno = ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato"] %}
{% set mese = ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"] %}
{% set m_ok = date | timestamp_custom("%m") | int %}
{% set g_ok = date | timestamp_custom("%w") | int %}
{{giorno[g_ok] + ' ' + date | timestamp_custom("%d") + ' ' + mese[m_ok - 1]}}
value_template: >
{{states.sensor.dark_sky_daytime_high_temperature_1d.state|round(0)}}°|{{states.sensor.dark_sky_overnight_low_temperature_1d.state|round(0)}}°|{{states.sensor.dark_sky_precip_probability_1d.state|round(0)}}%
entity_picture_template: >-
{{ '/local/icons/dark_sky/' ~ states.sensor.dark_sky_icon_1d.state ~ '.png'}}
entity_id: sensor.dark_sky_daytime_high_temperature_1d, sensor.dark_sky_overnight_low_temperature_1d, sensor.dark_sky_precip_probability_1d, sensor.date
forecast_2:
friendly_name_template: >
{%- set date = as_timestamp(now()) + (2 * 86400 ) -%}
{% set giorno = ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato"] %}
{% set mese = ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"] %}
{% set m_ok = date | timestamp_custom("%m") | int %}
{% set g_ok = date | timestamp_custom("%w") | int %}
{{giorno[g_ok] + ' ' + date | timestamp_custom("%d") + ' ' + mese[m_ok - 1]}}
value_template: >
{{states.sensor.dark_sky_daytime_high_temperature_2d.state|round(0)}}°|{{states.sensor.dark_sky_overnight_low_temperature_2d.state|round(0)}}°|{{states.sensor.dark_sky_precip_probability_2d.state|round(0)}}%
entity_picture_template: >-
{{ '/local/icons/dark_sky/' ~ states.sensor.dark_sky_icon_2d.state ~ '.png'}}
entity_id: sensor.dark_sky_daytime_high_temperature_2d, sensor.dark_sky_overnight_low_temperature_2d, sensor.dark_sky_precip_probability_2d, sensor.date
forecast_3:
friendly_name_template: >
{%- set date = as_timestamp(now()) + (3 * 86400 ) -%}
{% set giorno = ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato"] %}
{% set mese = ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"] %}
{% set m_ok = date | timestamp_custom("%m") | int %}
{% set g_ok = date | timestamp_custom("%w") | int %}
{{giorno[g_ok] + ' ' + date | timestamp_custom("%d") + ' ' + mese[m_ok - 1]}}
value_template: >
{{states.sensor.dark_sky_daytime_high_temperature_3d.state|round(0)}}°|{{states.sensor.dark_sky_overnight_low_temperature_3d.state|round(0)}}°|{{states.sensor.dark_sky_precip_probability_3d.state|round(0)}}%
entity_picture_template: >-
{{ '/local/icons/dark_sky/' ~ states.sensor.dark_sky_icon_3d.state ~ '.png'}}
entity_id: sensor.dark_sky_daytime_high_temperature_3d, sensor.dark_sky_overnight_low_temperature_3d, sensor.dark_sky_precip_probability_3d, sensor.date
forecast_4:
friendly_name_template: >
{%- set date = as_timestamp(now()) + (4 * 86400 ) -%}
{% set giorno = ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato"] %}
{% set mese = ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"] %}
{% set m_ok = date | timestamp_custom("%m") | int %}
{% set g_ok = date | timestamp_custom("%w") | int %}
{{giorno[g_ok] + ' ' + date | timestamp_custom("%d") + ' ' + mese[m_ok - 1]}}
value_template: >
{{states.sensor.dark_sky_daytime_high_temperature_4d.state|round(0)}}°|{{states.sensor.dark_sky_overnight_low_temperature_4d.state|round(0)}}°|{{states.sensor.dark_sky_precip_probability_4d.state|round(0)}}%
entity_picture_template: >-
{{ '/local/icons/dark_sky/' ~ states.sensor.dark_sky_icon_4d.state ~ '.png'}}
entity_id: sensor.dark_sky_daytime_high_temperature_4d, sensor.dark_sky_overnight_low_temperature_4d, sensor.dark_sky_precip_probability_4d, sensor.date
forecast_5:
friendly_name_template: >
{%- set date = as_timestamp(now()) + (5 * 86400 ) -%}
{% set giorno = ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato"] %}
{% set mese = ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"] %}
{% set m_ok = date | timestamp_custom("%m") | int %}
{% set g_ok = date | timestamp_custom("%w") | int %}
{{giorno[g_ok] + ' ' + date | timestamp_custom("%d") + ' ' + mese[m_ok - 1]}}
value_template: >
{{states.sensor.dark_sky_daytime_high_temperature_5d.state|round(0)}}°|{{states.sensor.dark_sky_overnight_low_temperature_5d.state|round(0)}}°|{{states.sensor.dark_sky_precip_probability_5d.state|round(0)}}%
entity_picture_template: >-
{{ '/local/icons/dark_sky/' ~ states.sensor.dark_sky_icon_5d.state ~ '.png'}}
entity_id: sensor.dark_sky_daytime_high_temperature_5d, sensor.dark_sky_overnight_low_temperature_5d, sensor.dark_sky_precip_probability_5d, sensor.date
forecast_6:
friendly_name_template: >
{%- set date = as_timestamp(now()) + (6 * 86400 ) -%}
{% set giorno = ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato"] %}
{% set mese = ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"] %}
{% set m_ok = date | timestamp_custom("%m") | int %}
{% set g_ok = date | timestamp_custom("%w") | int %}
{{giorno[g_ok] + ' ' + date | timestamp_custom("%d") + ' ' + mese[m_ok - 1]}}
value_template: >
{{states.sensor.dark_sky_daytime_high_temperature_6d.state|round(0)}}°|{{states.sensor.dark_sky_overnight_low_temperature_6d.state|round(0)}}°|{{states.sensor.dark_sky_precip_probability_6d.state|round(0)}}%
entity_picture_template: >-
{{ '/local/icons/dark_sky/' ~ states.sensor.dark_sky_icon_6d.state ~ '.png'}}
entity_id: sensor.dark_sky_daytime_high_temperature_6d, sensor.dark_sky_overnight_low_temperature_6d, sensor.dark_sky_precip_probability_6d, sensor.date
forecast_7:
friendly_name_template: >
{%- set date = as_timestamp(now()) + (7 * 86400 ) -%}
{% set giorno = ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato"] %}
{% set mese = ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"] %}
{% set m_ok = date | timestamp_custom("%m") | int %}
{% set g_ok = date | timestamp_custom("%w") | int %}
{{giorno[g_ok] + ' ' + date | timestamp_custom("%d") + ' ' + mese[m_ok - 1]}}
value_template: >
{{states.sensor.dark_sky_daytime_high_temperature_7d.state|round(0)}}°|{{states.sensor.dark_sky_overnight_low_temperature_7d.state|round(0)}}°|{{states.sensor.dark_sky_precip_probability_7d.state|round(0)}}%
entity_picture_template: >-
{{ '/local/icons/dark_sky/' ~ states.sensor.dark_sky_icon_7d.state ~ '.png'}}
entity_id: sensor.dark_sky_daytime_high_temperature_7d, sensor.dark_sky_overnight_low_temperature_7d, sensor.dark_sky_precip_probability_7d, sensor.date
########################################################################
### Definizione Orario Alba e Tramonto
########################################################################
- platform: template
sensors:
sunset_time:
value_template: '{% set timestamp = as_timestamp(states.sun.sun.attributes.next_setting) | timestamp_custom("%H:%M") %} {{ timestamp.lstrip("0") }}'
friendly_name: "Tramonto"
- platform: template
sensors:
sunrise_time:
value_template: '{% set timestamp = as_timestamp(states.sun.sun.attributes.next_rising) | timestamp_custom("%H:%M") %} {{ timestamp.lstrip("0") }}'
friendly_name: "Alba"
- platform: time_date
display_options:
- time
- date
- date_time
- time_date
- time_utc
- beat
- platform: systemmonitor
resources:
- type: disk_use_percent
arg: /home
- type: disk_free
arg: /home
- type: memory_free
- type: memory_use
- type: memory_use_percent
- type: processor_use
- type: last_boot
#- type: since_last_boot
#- type: network_in
# arg: eth0
#- type: network_out
# arg: eth0
- platform: template
sensors:
uptime:
friendly_name: Up time
value_template: "{{ states.sensor.last_boot.state.split('.')[0] }}"
since_last_boot_templated:
friendly_name: Last boot
value_template: >-
{%- set slb = states.sensor.last_boot.state.split(' ') -%}
{%- set count = slb | length -%}
{%- set hms = slb[count - 1] -%}
{%- set hms_trimmed = hms.split('.')[0] -%}
{%- set hms_split = hms_trimmed.split(':') -%}
{%- set hours = hms_split[0] | int -%}
{%- set minutes = hms_split[1] | int -%}
{%- set seconds = hms_split[2] | int -%}
{%- if count == 3 -%}
{{ slb[0] ~ ' ' ~ slb[1] ~ ' ' }}
{%- endif -%}
{%- if hours > 0 -%}
{%- if hours == 1 -%}
1 hour
{%- else -%}
{{ hours }} hours
{%- endif -%}
{%- endif -%}
{%- if minutes > 0 -%}
{%- if hours > 0 -%}
{{ ', ' }}
{%- endif -%}
{%- if minutes == 1 -%}
1 minute
{%- else -%}
{{ minutes }} minutes
{%- endif -%}
{%- endif -%}
{%- if seconds > 0 -%}
{%- if hours > 0 or minutes > 0 -%}
{{ ', ' }}
{%- endif -%}
{%- if seconds == 1 -%}
1 second
{%- else -%}
{{ seconds }} seconds
{%- endif -%}
{%- endif -%}
- platform: command_line
name: CPU Temp
command: "cat /sys/class/thermal/thermal_zone0/temp"
unit_of_measurement: "°C"
value_template: '{{ value | multiply(0.001) | round(1) }}'
- platform: command_line
command: "cat /sys/class/thermal/thermal_zone0/temp"
unit_of_measurement: "°C"
value_template: '{{ value | multiply(0.001) | round(2) }}'
- platform: sql
db_url: !secret dburl
queries:
- name: MariaDB size
query: 'SELECT table_schema "homeassistant", Round(Sum(data_length + index_length) / 1024 / 1024, 1) "value" FROM information_schema.tables WHERE table_schema="homeassistant" GROUP BY table_schema;'
column: 'value'
unit_of_measurement: MB
- platform: authenticated