forked from matt8707/hass-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsensors.yaml
1045 lines (912 loc) · 43.4 KB
/
sensors.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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
####################################################
# #
# SENSORS #
# #
####################################################
- platform: version
name: hass_version_installed
- platform: version
name: hass_version_latest
source: docker
- platform: filesize
file_paths:
- /config/home-assistant_v2.db
- /config/home-assistant.log
- platform: file
name: oresundskraft
file_path: /config/python/data.kwh
- platform: systemmonitor
resources:
- type: disk_use_percent
arg: /
- type: memory_use_percent
- type: processor_use
- type: last_boot
- platform: time_date
display_options:
['time', 'date']
- platform: scrape
resource: https://elen.nu/timpriser-pa-el-for-elomrade-se4-malmo
name: Aktuellt spotpris
select: ".elspot-area-price"
value_template: '{{ ((value.split(" ")[0]) | replace (",", "."))}}'
unit_of_measurement: "öre/kWh"
- platform: dnsip
- platform: darksky
api_key: !secret darksky_api_key
language: sv
monitored_conditions:
['precip_probability', 'temperature', 'apparent_temperature', 'icon']
- platform: rest
name: fullykiosk
json_attributes:
['batteryLevel', 'screenBrightness', 'plugged', 'motionDetectorState',
'lastAppStart', 'internalStorageFreeSpace', 'internalStorageTotalSpace',
'ramFreeMemory', 'ramTotalMemory', 'currentFragment']
resource: !secret fullykiosk_rest_resource
value_template: '{{ value_json.isScreenOn }}'
scan_interval: 3
- platform: rest
name: docker_cpu
resource: !secret ha_dockermon_cpu
value_template: >
{% set cpuDelta = value_json.cpu_stats.cpu_usage.total_usage - value_json.precpu_stats.cpu_usage.total_usage %}
{% set systemDelta = value_json.cpu_stats.system_cpu_usage - value_json.precpu_stats.system_cpu_usage %}
{{ (cpuDelta / systemDelta * value_json.cpu_stats.cpu_usage.percpu_usage | length * 100) | round(1) }}
json_attributes:
- cpu_stats
- precpu_stats
- memory_stats
- platform: rest
name: docker_uptime
resource: !secret ha_dockermon_uptime
value_template: >
{{ value_json.status.split(' ')[1:] | join(' ') | replace ('About a minute', '1 minut')
| replace ('About an hour', '1 timme') | replace ('seconds', 'sekunder') | replace ('minutes', 'minuter')
| replace ('hours', 'timmar') | replace ('days', 'dagar') + ' sedan' }}
- platform: synologydsm_custom
# changed timedelta, updates every 30 seconds instead of 15min
host: !secret synologydsm_host
port: !secret synologydsm_port
ssl: false
username: !secret synologydsm_username
password: !secret synologydsm_password
monitored_conditions:
['cpu_total_load', 'memory_real_usage', 'volume_status',
'volume_percentage_used', 'network_up', 'network_down', 'disk_temp']
- platform: snmp
host: !secret synologydsm_host
community: public
name: Drifttid
baseoid: !secret synologydsm_baseoid
value_template: >
{% set uptime = value %}
{% set days = ((uptime | int) / 8640000) | int %}
{% set hours = ((uptime | int) / 360000) | int %}
{% set minutes = ((uptime | int) / 6000) | int %}
{% if days >= 2 %}{{ days }} dagar
{% elif days >= 1 %}{{ days }} dag
{% elif minutes < 1 %}Mindre än 1 minut
{% elif minutes <= 1 %}{{ minutes }} minut
{% elif minutes < 60 %}{{ minutes }} minuter
{% elif hours <= 1 %}{{ hours }} timme
{% elif hours < 24 %}{{ hours }} timmar
{% endif %}
- platform: plex_recently_added
token: !secret plex_token
host: !secret plex_host
port: !secret plex_port
max: 1
img_dir: '/plex/'
- platform: mqtt
state_topic: "valetudo/rockrobo/state"
json_attributes_topic: "valetudo/rockrobo/map_data"
name: xiaomi_map
value_template: 'OK'
scan_interval: 5
- platform: krisinformation
county: !secret krisinformation_county
latitude: !secret homeassistant_latitude
longitude: !secret homeassistant_longitude
radius: 50
- platform: krisinformation
country: 'Sverige'
####################################################
# #
# COMMAND LINE #
# #
####################################################
- platform: command_line
name: imac_get_ip
scan_interval: 300
command: !secret imac_get_ip
- platform: command_line
name: imac_system_ssd
scan_interval: 900
unit_of_measurement: '%'
command: !secret imac_system_ssd
- platform: command_line
name: imac_macintosh_hd
scan_interval: 900
unit_of_measurement: '%'
command: !secret imac_macintosh_hd
- platform: command_line
name: imac_time_machine
scan_interval: 900
unit_of_measurement: '%'
command: !secret imac_time_machine
- platform: command_line
name: imac_cpu_per
scan_interval: 900
unit_of_measurement: '%'
command: !secret imac_cpu_per
- platform: command_line
name: imac_mem_per
scan_interval: 900
unit_of_measurement: '%'
command: !secret imac_mem_per
- platform: command_line
name: getvolume
scan_interval: 900
command: !secret monitorer_update_volume
- platform: command_line
name: monitorer_mute_check
scan_interval: 900
command: !secret monitorer_mute_check
- platform: command_line
name: macos_uptime
scan_interval: 120
command: !secret macos_uptime
- platform: command_line
name: skanetrafiken
scan_interval: 120
command: !secret skanetrafiken
####################################################
# #
# TEMPLATE #
# #
####################################################
- platform: template
sensors:
sidebar_greeting:
entity_id: sensor.time
value_template: >-
{% set t = now().hour %}
{% if t <= 1 %} God natt {{'\U0001F611'}}
{% elif t <= 3 %} God natt {{'\U0001F62A'}}
{% elif t <= 5 %} God natt {{'\U0001F634'}}
{% elif t <= 7 %} God morgon {{'\U0001F4A9'}}
{% elif t <= 9 %} God morgon {{'\u2615\uFE0F'}}
{% elif t <= 10.5 %} God morgon {{'\U0001F642'}}
{% elif t <= 13 %} God dag {{'\U0001F60A'}}
{% elif t <= 15 %} God dag {{'\U0001F60E'}}
{% elif t <= 17 %} God dag {{'\U0001F44B\U0001F3FB'}}
{% elif t <= 19 %} God kväll {{'\U0001F44B\U0001F3FB'}}
{% elif t <= 22 %} God kväll {{'\U0001F60C'}}
{% elif t <= 23 %} God kväll {{'\U0001F974'}}
{% else %} God kväll {{'\U0001F974'}}
{% endif %}
sidebar_active:
value_template: >-
{% set lights = [states.light.tvlampa, states.light.golvlampa, states.light.fonsterlampa, states.light.datorlampa,
states.light.vask_hoger, states.light.vask_vanster, states.light.taklampa, states.light.kladkammare_2,
states.light.hallampa_1, states.light.hallampa_2, states.light.hallampa_3, states.light.mattias, states.light.sanja,
states.light.spot_1, states.light.spot_2] %}
{% set lights_on = lights | selectattr('state','eq','on') | list %}
{% set lights_name = lights | selectattr('state','eq','on') | map(attribute='name') | join(', ') %}
{% set switches = [states.switch.dator_template, states.switch.tv_template, states.switch.tv2_template,
states.switch.playstation_template, states.switch.wemo_monitorer, states.switch.wemo_flakt] %}
{% set switches_on = switches | selectattr('state','eq','on') | list %}
{% set switches_name = switches | selectattr('state','eq','on') | map(attribute='name') | join(', ') %}
{% if (lights_on | length ==0 ) and (switches_on | length > 0) %}
{{ switches_name | regex_replace(',([^,]*)$',' och\\1') }} är på
{% elif (lights_on | length ==1) and (switches_on | length == 1) %}
{{ lights_name }} och {{switches_name }} är på
{% elif (lights_on | length ==1) and (switches_on | length > 1) %}
{{ lights_name }}, {{ switches_name | regex_replace(',([^,]*)$',' och\\1') }} är på
{% elif (lights_on | length > 1) and (switches_on | length == 1) %}
{{ lights_on | length }} lampor och {{ switches_name }} är på
{% elif (lights_on | length > 1 ) and (switches_on | length > 1) %}
{{ lights_on | length }} lampor, {{ switches_name | regex_replace(',([^,]*)$',' och\\1') }} är på
{% elif (lights_on | length ==1) and (switches_on | length ==0) %}
{{ lights_name }} är på
{% elif (lights_on | length >1 ) and (switches_on | length ==0) %}
{{ lights_on | length}} lampor är på
{% else %}
<font color='#6a7377'>Allt är avstängt</font>
{% endif %}
sidebar_vacuum:
value_template: >-
{% if is_state('vacuum.xiaomi_vacuum_cleaner', 'cleaning') %}
Morty dammsuger
{% elif is_state('vacuum.xiaomi_vacuum_cleaner', 'returning') %}
Morty är färdig
{% endif %}
sidebar_weather:
value_template: >-
{% if states('sensor.dark_sky_temperature') == 'unknown' %}
Kan inte läsa in väderinformation...
{% else %}
{% if states('sensor.dark_sky_temperature') | float <= 0.0 %}
Känns som {{ states('sensor.dark_sky_apparent_temperature') | round }}° med
{{ states('sensor.dark_sky_precip_probability') | round }}% risk för snö {{'\u2744\uFE0F'}}
{% elif states('sensor.dark_sky_temperature') | float > 0.0 %}
Känns som {{ states('sensor.dark_sky_apparent_temperature') | round }}° med
{{ states('sensor.dark_sky_precip_probability') | round }}% risk för regn
{% if states('sensor.dark_sky_precip_probability') | float > 30.0 %} {{'\u2614\uFE0F' }}
{% endif %}
{% elif states('sensor.dark_sky_temperature') | float > 19.0 and
states('sensor.dark_sky_precip_probability') | float < 5.0 %}
Känns som {{ states('sensor.dark_sky_apparent_temperature') | round }}° {{'\U0001F60E' }} med
{{ states('sensor.dark_sky_precip_probability') | round }}% risk för regn
{% endif %}
{% endif %}
sidebar_skanetrafiken:
value_template: >-
{% if states('sensor.skanetrafiken') != 'från' %}
Nästa buss går {{ states('sensor.skanetrafiken') }}
{% endif %}
public_ip:
value_template: !secret public_ip
placeholder:
value_template: " "
docker_mem:
value_template: >-
{{ (state_attr('sensor.docker_cpu', 'memory_stats')['usage'] /
state_attr('sensor.docker_cpu', 'memory_stats')['limit'] * 100) | round(1) }}
vpn_imac:
friendly_name: VPN
value_template: >-
{% if states('sensor.imac_get_ip') == states('sensor.public_ip') %}
Ej Ansluten
{% else %}
Ansluten
{% endif %}
icon_template: >-
{% if states('sensor.imac_get_ip') == states('sensor.public_ip') %}
mdi:shield-alert
{% else %}
mdi:shield-check
{% endif %}
macos_uptime_template:
entity_id: sensor.time
friendly_name: Drifttid
icon_template: 'mdi:clock'
value_template: >
{% set uptime =
(as_timestamp(now()) - as_timestamp(states('sensor.macos_uptime') | int | timestamp_local | default(0))) %}
{% if uptime | timestamp_custom("%d") | int-1 == 1 %}{{ uptime | timestamp_custom("%d") | int-1}} dag
{% elif uptime | timestamp_custom("%d") | int-1 >= 2 %}{{ uptime | timestamp_custom("%d") | int-1}} dagar
{% elif uptime | timestamp_custom("%H") | int-1 == 1 %}{{ uptime | timestamp_custom("%H") | int-1}} timme
{% elif uptime | timestamp_custom("%H") | int-1 >= 2 %}{{ uptime | timestamp_custom("%H") | int-1}} timmar
{% elif uptime | timestamp_custom("%M") | int == 1 %}{{ uptime | timestamp_custom("%M") | int}} minut
{% elif uptime | timestamp_custom("%M") | int >= 2 %}{{ uptime | timestamp_custom("%M") | int}} minuter
{% else %}Minde än 1 minut
{% endif %}
hass_version_template:
icon_template: 'mdi:home-assistant'
friendly_name_template: >-
Installerad {{ states('sensor.hass_version_installed') }}
value_template: >-
{% if states('sensor.hass_version_installed') == states('sensor.hass_version_latest') %}
Senaste
{% else %}
{{ states('sensor.hass_version_latest') }}
{% endif %}
hass_release_template:
entity_id: sensor.time
icon_template: 'mdi:dev-to'
friendly_name_template: >-
{% set d = ((as_timestamp(state_attr('calendar.home_assistant_devs',
'start_time')) - as_timestamp(now())) / 86400) %}
{% if d > 20 %} Planerad beta
{% else %} {{ state_attr('calendar.home_assistant_devs','message') }}
{% endif %}
value_template: >-
{% set d = ((as_timestamp(state_attr('calendar.home_assistant_devs',
'start_time')) - as_timestamp(now())) / 86400) %}
{% if d < -1 %} Släppt
{% elif d < 0 %} Idag
{% elif d > 20 %} Ingen
{% else %} {{ d | int + 1 }} dagar
{% endif %}
printer_status_template:
friendly_name: Skrivare
icon_template: 'mdi:printer'
value_template: >-
{% if is_state('sensor.hp_printer_status', 'On') %}
På
{% elif is_state('sensor.hp_printer_status', 'Scanning') %}
Skannar
{% elif is_state('sensor.hp_printer_status', 'Copying') %}
Kopierar
{% elif is_state('sensor.hp_printer_status', 'Printing') %}
Skriver ut
{% elif is_state('sensor.hp_printer_status', 'Cancelling Job') %}
Avbryter
{% elif is_state('sensor.hp_printer_status', 'Idle') %}
Viloläge
{% elif is_state('sensor.hp_printer_status', 'trayEmptyOrOpen') %}
Inga papper
{% elif is_state('sensor.hp_printer_status', 'Off') %}
Av
{% else %}
{{ states('sensor.hp_printer_status') }}
{% endif %}
mattias_battery_level:
friendly_name: Batteri
unit_of_measurement: '%'
value_template: "{{ states('sensor.battery_level') }}"
icon_template: >-
{% set battery_level = states('sensor.battery_level')|int('unknown') %}
{% set battery_round = (battery_level|int / 10)|int * 10 %}
{% if battery_level == 'unknown' %}
mdi:battery-unknown
{% else %}
{% if battery_round >= 100 %}
mdi:battery
{% elif battery_round > 0 %}
mdi:battery-{{ battery_round }}
{% else %}
mdi:battery-alert
{% endif %}
{% endif %}
darksky_emoji:
value_template: >-
{% if is_state("sensor.dark_sky_icon","clear-day") %} {{ '\u2600\uFE0F' }}
{% elif is_state("sensor.dark_sky_icon","clear-night") %} {{ '\U0001F319' }}
{% elif is_state("sensor.dark_sky_icon","rain") %} {{ '\U0001F327' }}
{% elif is_state("sensor.dark_sky_icon","snow") %} {{ '\U0001F328' }}
{% elif is_state("sensor.dark_sky_icon","fog") %} {{ '\u2601\uFE0F' }}
{% elif is_state("sensor.dark_sky_icon","sleet") %} {{ '\U0001F328' }}
{% elif is_state("sensor.dark_sky_icon","wind") %} {{ '\U0001F32C' }}
{% elif is_state("sensor.dark_sky_icon","cloudy") %} {{ '\u2601\uFE0F' }}
{% elif is_state("sensor.dark_sky_icon","partly-cloudy-day") %} {{ '\u26C5\uFE0F' }}
{% elif is_state("sensor.dark_sky_icon","partly-cloudy-night") %} {{ '\u2601\uFE0F' }}
{% elif is_state("sensor.dark_sky_icon","hail") %} {{ '\U0001F328' }}
{% elif is_state("sensor.dark_sky_icon","lightning") %} {{ '\U0001F329' }}
{% elif is_state("sensor.dark_sky_icon","thunderstorm") %} {{ '\u26C8' }}
{% elif is_state("sensor.dark_sky_icon","tornado") %} {{ '\U0001F32A' }}
{% endif %}
last_motion_sensor_triggered:
value_template: >-
{% set sensors = [states.input_boolean.motion_hall, states.input_boolean.motion_badrum,
states.input_boolean.motion_garderob, states.binary_sensor.wemo_motion] %}
{% for sensor in sensors %}
{% if as_timestamp(sensor.last_changed) ==
as_timestamp(sensors | map(attribute='last_changed') | max) %}
{{ sensor.entity_id }}
{% endif %}
{% endfor %}
ps4_state:
value_template: >-
{% if is_state('media_player.playstation_4', 'off') or
is_state('media_player.playstation_4', 'standby') or
is_state('media_player.playstation_4', 'unknown') %}
off
{% else %}
on
{% endif %}
####################################################
# #
# LIGHT PERCENT #
# #
####################################################
belysning_percent:
value_template: >-
{% if is_state('light.belysning', 'on') %}
{{ (state_attr('light.belysning', 'brightness') / 2.54) | round }}{% endif %}
taklampor_percent:
value_template: >-
{% if is_state('light.taklampor', 'on') %}
{{ (state_attr('light.taklampor', 'brightness') / 2.54) | round }}{% endif %}
fonsterlampa_percent:
value_template: >-
{% if is_state('light.fonsterlampa', 'on') %}
{{ (state_attr('light.fonsterlampa', 'brightness') / 2.54) | round }}{% endif %}
datorlampa_percent:
value_template: >-
{% if is_state('light.datorlampa', 'on') %}
{{ (state_attr('light.datorlampa', 'brightness') / 2.54) | round }}{% endif %}
mattias_percent:
value_template: >-
{% if is_state('light.mattias', 'on') %}
{{ (state_attr('light.mattias', 'brightness') / 2.54) | round }}{% endif %}
sanja_percent:
value_template: >-
{% if is_state('light.sanja', 'on') %}
{{ (state_attr('light.sanja', 'brightness') / 2.54) | round }}{% endif %}
badrum_percent:
value_template: >-
{% if is_state('light.badrum', 'on') %}
{{ (state_attr('light.badrum', 'brightness') / 2.54) | round }}{% endif %}
kok_percent:
value_template: >-
{% if is_state('light.kok', 'on') %}
{{ (state_attr('light.kok', 'brightness') / 2.54) | round }}{% endif %}
garderob_percent:
value_template: >-
{% if is_state('light.kladkammare_2', 'on') %}
{{ (state_attr('light.kladkammare_2', 'brightness') / 2.54) | round }}{% endif %}
hall_percent:
value_template: >-
{% if is_state('light.hall', 'on') %}
{{ (state_attr('light.hall', 'brightness') / 2.54) | round }}{% endif %}
####################################################
# #
# VACUUM #
# #
####################################################
roborock_battery_level:
friendly_name: Batteri
unit_of_measurement: '%'
value_template: "{{ state_attr('vacuum.xiaomi_vacuum_cleaner', 'battery_level') }}"
icon_template: "{{ state_attr('vacuum.xiaomi_vacuum_cleaner', 'battery_icon') }}"
roborock_state:
friendly_name: Roborock S5
value_template: >-
{% if is_state('vacuum.xiaomi_vacuum_cleaner', 'docked') %}
Dockad
{% elif is_state('vacuum.xiaomi_vacuum_cleaner', 'cleaning') %}
Städar
{% elif is_state('vacuum.xiaomi_vacuum_cleaner', 'returning') %}
Återvänder
{% else %}
{{ states('vacuum.xiaomi_vacuum_cleaner') }}
{% endif %}
icon_template: 'bha:roborock'
roborock_fan_speed:
value_template: "{{ state_attr('vacuum.xiaomi_vacuum_cleaner', 'fan_speed') }}"
roborock_filter:
friendly_name: Filter
unit_of_measurement: '%'
value_template: "{{ (state_attr('vacuum.xiaomi_vacuum_cleaner', 'filter_left') / 1.5) | round }}"
icon_template: 'mdi:air-filter'
roborock_huvudborste:
friendly_name: Huvudborste
unit_of_measurement: '%'
value_template: "{{ (state_attr('vacuum.xiaomi_vacuum_cleaner', 'main_brush_left') / 3) | round }}"
icon_template: 'mdi:broom'
roborock_sensorer:
friendly_name: Sensorer
unit_of_measurement: '%'
value_template: "{{ (state_attr('vacuum.xiaomi_vacuum_cleaner', 'sensor_dirty_left') / 0.3) | round }}"
icon_template: 'mdi:leak'
roborock_sidoborste:
friendly_name: Sidoborste
unit_of_measurement: '%'
value_template: "{{ (state_attr('vacuum.xiaomi_vacuum_cleaner', 'side_brush_left') / 2) | round }}"
icon_template: 'mdi:brush'
roborock_last_clean:
entity_id: sensor.time
friendly_name: Senast städat
icon_template: 'mdi:clock'
value_template: >
{% set clean_stop =
(as_timestamp(now()) - as_timestamp(state_attr('vacuum.xiaomi_vacuum_cleaner', 'clean_stop') | default(0))) %}
{% if clean_stop | timestamp_custom("%d") | int-1 == 1 %}{{ clean_stop | timestamp_custom("%d") | int-1}} dag sedan
{% elif clean_stop | timestamp_custom("%d") | int-1 >= 2 %}{{ clean_stop | timestamp_custom("%d") | int-1}} dagar sedan
{% elif clean_stop | timestamp_custom("%H") | int-1 == 1 %}{{ clean_stop | timestamp_custom("%H") | int-1}} timme sedan
{% elif clean_stop | timestamp_custom("%H") | int-1 >= 2 %}{{ clean_stop | timestamp_custom("%H") | int-1}} timmar sedan
{% elif clean_stop | timestamp_custom("%M")|int == 1 %}{{ clean_stop | timestamp_custom("%M") | int}} minut sedan
{% elif clean_stop | timestamp_custom("%M")|int >= 2 %}{{ clean_stop | timestamp_custom("%M") | int}} minuter sedan
{% else %}Minde än 1 minut sedan
{% endif %}
####################################################
# #
# TABLET #
# #
####################################################
fullykiosk_plugged:
friendly_name: Strömsladd ansluten
value_template: >-
{% if is_state_attr('sensor.fullykiosk', 'plugged', true) %} Ja {% else %} Nej {% endif %}
icon_template: >-
{% if is_state_attr('sensor.fullykiosk', 'plugged', true) %} mdi:power-plug {% else %} mdi:power-plug-off {% endif %}
fullykiosk_storage_percentage:
friendly_name: Lagring
icon_template: 'mdi:sd'
unit_of_measurement: '%'
value_template: >
{{ 100 - ( state_attr('sensor.fullykiosk', 'internalStorageFreeSpace') /
state_attr('sensor.fullykiosk', 'internalStorageTotalSpace') * 100 ) | int }}
fullykiosk_memory_percentage:
friendly_name: Minne
icon_template: 'mdi:memory'
unit_of_measurement: '%'
value_template: >
{{ 100 - ( state_attr('sensor.fullykiosk', 'ramFreeMemory') /
state_attr('sensor.fullykiosk', 'ramTotalMemory') * 100 ) | int }}
fullykiosk_motion_detector_state:
friendly_name: Kamera
icon_template: 'mdi:camera'
value_template: >-
{% if is_state_attr('sensor.fullykiosk', 'motionDetectorState', 0) %}
Av
{% else %}
På
{% endif %}
fullykiosk_battery_level:
friendly_name: Batteri
unit_of_measurement: '%'
value_template: "{{ state_attr('sensor.fullykiosk', 'batteryLevel') }}"
icon_template: >-
{% set battery_level = state_attr('sensor.fullykiosk', 'batteryLevel')|int('unknown') %}
{% set battery_round = (battery_level|int / 10)|int * 10 %}
{% if battery_level == 'unknown' %}
mdi:battery-unknown
{% else %}
{% if battery_round >= 100 %}
mdi:battery
{% elif battery_round > 0 %}
mdi:battery-{{ battery_round }}
{% else %}
mdi:battery-alert
{% endif %}
{% endif %}
####################################################
# #
# DATE #
# #
####################################################
dag:
entity_id: sensor.date
value_template: >
{% set days = ["Måndag", "Tisdag", "Onsdag", "Torsdag", "Fredag", "Lördag", "Söndag"] %}
{{ days[now().weekday()] }}
datum:
value_template: >
{% set months = ["Januari", "Februari", "Mars", "April", "Maj", "Juni",
"Juli", "Augusti", "September", "Oktober", "November", "December"] %}
{{ strptime(states('sensor.date'), '%Y-%m-%d').day }}
{{ months[now().month-1] }}
tvatta_countdown:
entity_id: sensor.time
friendly_name: Tvätta
value_template: >-
{% if state_attr('calendar.tvatta', 'start_time') == null or
state_attr('calendar.tvatta', 'start_time') == None %}
{% else %}
{% set calendar_tvattid = state_attr('calendar.tvatta', 'start_time') %}
{% set nu_tid = now() %}
{% set dag = strptime(calendar_tvattid, "%Y-%m-%d %H:%M:%S").strftime("%A")
| replace('Monday', 'Måndag') | replace('Tuesday', 'Tisdag')
| replace('Wednesday', 'Onsdag') | replace('Thursday', 'Torsdag')
| replace('Friday', 'Fredag') | replace('Saturday', 'Lördag') | replace('Sunday', 'Söndag') %}
{% set tid = as_timestamp(calendar_tvattid) | timestamp_custom('%H:%M') %}
{% set sub_timmar = as_timestamp(calendar_tvattid) | timestamp_custom('%H') | int / 24 %}
{% set count = (as_timestamp(calendar_tvattid) - as_timestamp(nu_tid)) / 86400 - sub_timmar %}
{% if count <= 0.0 %}
{{'\U0001F4A6'}} Tvätt idag {{ tid }}
{% elif count <= 1.0 %}
Tvätt imorgon klockan {{ tid }}
{% elif count <= 2.0 %}
Tvätt i övermorgon klockan {{ tid }}
{% else %}
Tvätt om {{ (count + sub_timmar) | round }} dagar på {{ dag }} kl {{ tid }}
{% endif %}
{% endif %}
tvatta_countdown_timer_trigger:
entity_id: sensor.time
value_template: >-
{% if state_attr('calendar.tvatta', 'start_time') == null or
state_attr('calendar.tvatta', 'start_time') == None %}
false
{% else %}
{% set calendar_tvattid = state_attr('calendar.tvatta', 'start_time') %}
{% if ((as_timestamp(calendar_tvattid) - as_timestamp(now())) / 86400) <= 0.004 %}
true {% else %} false {% endif %}
{% endif %}
krisinformation_time_trigger:
entity_id: sensor.time
value_template: >-
{% set date = state_attr('sensor.krisinformation_sverige', 'messages')[0]["Published"] %}
{% if ((as_timestamp(date) - as_timestamp(now())) / 86400) <= -0.5 %}
false {% else %} true
{% endif %}
mattias_last_changed:
entity_id: sensor.time
value_template: >-
{%- set time = (as_timestamp(now()) -
as_timestamp(states.person.mattias.last_changed)) | int %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set days = (time // 86400) %}
{% if time <= 60 %} 0m
{% elif time <= 3600 %} {{ minutes }}m
{% elif time <= 86400 %} {{ hours }}h
{% elif time > 86400 %} {{ days }}d
{% endif %}
sanja_last_changed:
entity_id: sensor.time
value_template: >-
{%- set time = (as_timestamp(now()) -
as_timestamp(states.person.sanja.last_changed)) | int %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set days = (time // 86400) %}
{% if time <= 60 %} 0m
{% elif time <= 3600 %} {{ minutes }}m
{% elif time <= 86400 %} {{ hours }}h
{% elif time > 86400 %} {{ days }}d
{% endif %}
mattias_last_changed_h:
entity_id: sensor.time
value_template: >-
{%- set time = (as_timestamp(now()) -
as_timestamp(states.person.mattias.last_changed)) | int %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set days = (time // 86400) %}
{% if time <= 60 %} mindre än 1m
{% elif time <= 3600 %} {{ minutes }}m
{% elif time <= 86400 and minutes == 0 %} {{ hours }}h
{% elif time <= 86400 %} {{ hours }}h och {{ minutes }}m
{% elif time > 86400 %} {{ days }}d
{% endif %}
sanja_last_changed_h:
entity_id: sensor.time
value_template: >-
{%- set time = (as_timestamp(now()) -
as_timestamp(states.person.sanja.last_changed)) | int %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set days = (time // 86400) %}
{% if time <= 60 %} mindre än 1m
{% elif time <= 3600 %} {{ minutes }}m
{% elif time <= 86400 and minutes == 0 %} {{ hours }}h
{% elif time <= 86400 %} {{ hours }}h och {{ minutes }}m
{% elif time > 86400 %} {{ days }}d
{% endif %}
####################################################
# #
# NAS #
# #
####################################################
nas_disk_temp:
friendly_name: Disktemperatur
unit_of_measurement: '°C'
icon_template: 'mdi:thermometer'
value_template: >
{{ (states('sensor.synology_dsm_temperature_sda'), states('sensor.synology_dsm_temperature_sdb'),
states('sensor.synology_dsm_temperature_sdc'), states('sensor.synology_dsm_temperature_sdd')) | max }}
nas_net_down:
value_template: ' '
icon_template: 'mdi:arrow-down-bold'
friendly_name_template: >
{% set down = states('sensor.synology_dsm_network_down') | float %}
{% if down < 1000 %}
{{ down | round(0) }} kb/s
{% elif down >= 1000 %}
{{ ((down / 1000) | round(2)|string).rstrip('.0') }} Mb/s
{% endif %}
nas_net_up:
value_template: ' '
icon_template: 'mdi:arrow-up-bold'
friendly_name_template: >
{% set up = states('sensor.synology_dsm_network_up') | float %}
{% if up < 1000 %}
{{ up | round(0) }} kb/s
{% elif up >= 1000 %}
{{ ((up / 1000) | round(2)|string).rstrip('.0') }} Mb/s
{% endif %}
synology_dsm_status:
friendly_name: Systemhälsa
icon_template: 'mdi:nas'
value_template: >-
{% if is_state("sensor.synology_dsm_status_volume_1", "normal") %}
Bra
{% else %}
{{ states('sensor.synology_dsm_status_volume_1') }}
{% endif %}
vpn_nas:
friendly_name: VPN
value_template: >-
{% if states('sensor.myip') == states('sensor.public_ip') %}
Ej Ansluten
{% else %}
Ansluten
{% endif %}
icon_template: >-
{% if states('sensor.myip') == states('sensor.public_ip') %}
mdi:shield-alert
{% else %}
mdi:shield-check
{% endif %}
####################################################
# #
# MEDIA #
# #
####################################################
plex_title:
value_template: >
{% set data = state_attr('sensor.plex_recently_added', 'data') | from_json %}
{{ data[1].title }}
{% if data[1].number is none %} ({{ data[1].aired.split('-')[0] }})
{% else %} {{ data[1].number }} {% endif %}
plex_title_truncate:
value_template: >
{{ states('sensor.plex_title') | truncate(30, True, '...', 0) }}
apple_tv_vardagsrum_status:
value_template: >
{% if is_state('media_player.vardagsrum','playing') %} Spelar
{% elif is_state_attr('media_player.vardagsrum','media_title', 'No title') %} Av
{% elif is_state('media_player.vardagsrum','paused') %} Pausad
{% else %} Av {% endif %}
apple_tv_sovrum_status:
value_template: >
{% if is_state('media_player.sovrum','playing') %} Spelar
{% elif is_state_attr('media_player.sovrum','media_title', 'No title') %} Av
{% elif is_state('media_player.sovrum','paused') %} Pausad
{% else %} Av {% endif %}
playstation_status:
value_template: >
{% if is_state('media_player.playstation_4','playing') %} Spelar
{% elif is_state('media_player.playstation_4','paused') %} Pausad
{% else %} Av {% endif %}
google_nest_mini_status:
value_template: >
{% if is_state('media_player.google_nest_mini','playing') %} Spelar
{% elif is_state('media_player.google_nest_mini','paused') %} Pausad
{% else %} Av {% endif %}
apple_tv_vardagsrum_title_truncate:
value_template: >
{% if states('media_player.vardagsrum') == null %} {% else %}
{% if is_state_attr('media_player.vardagsrum', 'media_title', 'Nothing playing') %} Inget spelas
{% elif is_state_attr('media_player.vardagsrum', 'media_title', 'No title') %} Ingen titel
{% elif is_state('media_player.vardagsrum', 'idle') %} Viloläge
{% else %} {{ state_attr('media_player.vardagsrum', 'media_title')
| truncate(30, True, '...', 0) }} {% endif %}
{% endif %}
apple_tv_sovrum_title_truncate:
value_template: >
{% if states('media_player.sovrum') == null %} {% else %}
{% if is_state_attr('media_player.sovrum', 'media_title', 'Nothing playing') %} Inget spelas
{% elif is_state('media_player.sovrum', 'idle') %} Viloläge
{% else %} {{ state_attr('media_player.sovrum', 'media_title')
| truncate(30, True, '...', 0) }} {% endif %}
{% endif %}
playstation_title_truncate:
value_template: >
{% if is_state('media_player.playstation_4', 'standby') %} Viloläge
{% elif state_attr('media_player.playstation_4', 'media_title') == None %} Inget spelas
{% else %} {{ state_attr('media_player.playstation_4', 'media_title')
| truncate(30, True, '...', 0) }} {% endif %}
google_nest_mini_title_truncate:
value_template: >
{% if is_state('media_player.google_nest_mini', 'off') or
is_state('media_player.google_nest_mini', 'idle') %} Viloläge
{% elif state_attr('media_player.google_nest_mini', 'media_artist') == None or
state_attr('media_player.google_nest_mini', 'media_title') == None %} Ingen titel
{% else %} {% set artist_title = state_attr('media_player.google_nest_mini', 'media_artist')
+ ' - ' + state_attr('media_player.google_nest_mini', 'media_title') %}
{{ artist_title | truncate(30, True, '...', 0) }} {% endif %}
####################################################
# #
# Monthly kWh #
# #
####################################################
oresundskraft_1:
friendly_name_template: >
{{ as_timestamp(strptime(states('sensor.oresundskraft').split(',')[0].split(' ')[1],
'%Y-%m-%d')) | timestamp_custom('%b') }}
value_template: "{{ states('sensor.oresundskraft').split(',')[0].split(' ')[2] | int }}"
oresundskraft_2:
friendly_name_template: >
{{ as_timestamp(strptime(states('sensor.oresundskraft').split(',')[1].split(' ')[1],
'%Y-%m-%d')) | timestamp_custom('%b') }}
value_template: "{{ states('sensor.oresundskraft').split(',')[1].split(' ')[2] | int }}"
oresundskraft_3:
friendly_name_template: >
{{ as_timestamp(strptime(states('sensor.oresundskraft').split(',')[2].split(' ')[1],
'%Y-%m-%d')) | timestamp_custom('%b') }}
value_template: "{{ states('sensor.oresundskraft').split(',')[2].split(' ')[2] | int }}"
oresundskraft_4:
friendly_name_template: >
{{ as_timestamp(strptime(states('sensor.oresundskraft').split(',')[3].split(' ')[1],
'%Y-%m-%d')) | timestamp_custom('%b') }}
value_template: "{{ states('sensor.oresundskraft').split(',')[3].split(' ')[2] | int }}"
oresundskraft_5:
friendly_name_template: >
{{ as_timestamp(strptime(states('sensor.oresundskraft').split(',')[4].split(' ')[1],
'%Y-%m-%d')) | timestamp_custom('%b') | replace('y','j') }}
value_template: "{{ states('sensor.oresundskraft').split(',')[4].split(' ')[2] | int }}"
oresundskraft_6:
friendly_name_template: >
{{ as_timestamp(strptime(states('sensor.oresundskraft').split(',')[5].split(' ')[1],
'%Y-%m-%d')) | timestamp_custom('%b') }}
value_template: "{{ states('sensor.oresundskraft').split(',')[5].split(' ')[2] | int }}"
oresundskraft_7:
friendly_name_template: >
{{ as_timestamp(strptime(states('sensor.oresundskraft').split(',')[6].split(' ')[1],
'%Y-%m-%d')) | timestamp_custom('%b') }}
value_template: "{{ states('sensor.oresundskraft').split(',')[6].split(' ')[2] | int }}"
oresundskraft_8:
friendly_name_template: >
{{ as_timestamp(strptime(states('sensor.oresundskraft').split(',')[7].split(' ')[1],
'%Y-%m-%d')) | timestamp_custom('%b') }}
value_template: "{{ states('sensor.oresundskraft').split(',')[7].split(' ')[2] | int }}"
oresundskraft_9:
friendly_name_template: >
{{ as_timestamp(strptime(states('sensor.oresundskraft').split(',')[8].split(' ')[1],
'%Y-%m-%d')) | timestamp_custom('%b') }}
value_template: "{{ states('sensor.oresundskraft').split(',')[8].split(' ')[2] | int }}"
oresundskraft_10:
friendly_name_template: >
{{ as_timestamp(strptime(states('sensor.oresundskraft').split(',')[9].split(' ')[1],
'%Y-%m-%d')) | timestamp_custom('%b') | replace('c','k') }}
value_template: "{{ states('sensor.oresundskraft').split(',')[9].split(' ')[2] | int }}"
oresundskraft_11:
friendly_name_template: >
{{ as_timestamp(strptime(states('sensor.oresundskraft').split(',')[10].split(' ')[1],
'%Y-%m-%d')) | timestamp_custom('%b') }}
value_template: "{{ states('sensor.oresundskraft').split(',')[10].split(' ')[2] | int }}"
oresundskraft_12:
friendly_name_template: >
{{ as_timestamp(strptime(states('sensor.oresundskraft').split(',')[11].split(' ')[1],
'%Y-%m-%d')) | timestamp_custom('%b') }}
value_template: "{{ states('sensor.oresundskraft').split(',')[11].split(' ')[2] | int }}"
last_month_kwh:
unit_of_measurement: 'kWh'
value_template: >
{% for month in range(12) %}
{% if now().month-1 == (states('sensor.oresundskraft').split(',')
[month].split(' ')[0]|join|string).lstrip('0')|int %}
{{ states('sensor.oresundskraft').split(',')[month].split(' ')[2] }}
{% endif %}
{% endfor %}
last_month_price:
entity_id: sensor.oresundskraft
friendly_name_template: >
{% if now().month-1 == 0 %}
Beräknad {{ as_timestamp(strptime(states('sensor.oresundskraft').split(',')[11].split(' ')[1], '%Y-%m-%d')) |
timestamp_custom('%B') | replace('ay', 'aj') | replace('y', 'i') | replace('ch', 's')
| replace('ne', 'ni') | replace('ust', 'usti') | replace('ct', 'kt') }}
{% else %}
{% for month in range(12) %}
{% if now().month-1 == (states('sensor.oresundskraft').split(',')[month].split(' ')[0]|join|string).lstrip('0')|int %}
Beräknad {{ as_timestamp(strptime(states('sensor.oresundskraft').split(',')[month].split(' ')[1], '%Y-%m-%d')) |
timestamp_custom('%B') | replace('ay', 'aj') | replace('y', 'i') | replace('ch', 's')
| replace('ne', 'ni') | replace('ust', 'usti') | replace('ct', 'kt') }}