-
Notifications
You must be signed in to change notification settings - Fork 676
/
sidebar.yaml
159 lines (148 loc) · 7.29 KB
/
sidebar.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
- sensor:
- unique_id: sidebar
state: template
attributes:
time: >
{% set hours = now().strftime('%H') %}
{% set minutes = now().strftime('%M') %}
<span class="time">
{{ hours }}<span class="time-colon">:</span>{{ minutes }}
</span>
date: >
<font color='#6a7377'><b>
{% if strptime(states('sensor.date'), '%Y-%m-%d').day != None %}
{% set days = ['Måndag', 'Tisdag', 'Onsdag', 'Torsdag', 'Fredag', 'Lördag', 'Söndag'] %}
{% set months = ['Januari', 'Februari', 'Mars', 'April', 'Maj', 'Juni',
'Juli', 'Augusti', 'September', 'Oktober', 'November', 'December'] %}
{{ days[now().weekday()] }}<br>
{{ strptime(states('sensor.date'), '%Y-%m-%d').day }} {{ months[now().month-1] }}
{% endif %}
</b></font>
greet: >
<b>
{% set time = now().hour %}
{% if time <= 1 %} God natt {{'\U0001F611'}}
{% elif time <= 3 %} God natt {{'\U0001F62A'}}
{% elif time <= 5 %} God natt {{'\U0001F634'}}
{% elif time <= 7 %} God morgon {{'\U0001F4A9'}}
{% elif time <= 9 %} God morgon {{'\u2615\uFE0F'}}
{% elif time <= 10 %} God morgon {{'\U0001F642'}}
{% elif time <= 13 %} God dag {{'\U0001F60A'}}
{% elif time <= 15 %} God dag {{'\U0001F60E'}}
{% elif time <= 17 %} God dag {{'\U0001F44B\U0001F3FB'}}
{% elif time <= 19 %} God kväll {{'\U0001F44B\U0001F3FB'}}
{% elif time <= 22 %} God kväll {{'\U0001F60C'}}
{% elif time <= 23 %} God kväll {{'\U0001F974'}}
{% else %} God kväll {{'\U0001F974'}}
{% endif %}
</b>
active: >
<b>
{% set lights = [
states.light.vardagsrum_tv,
states.light.vardagsrum_golv,
states.light.vardagsrum_horna,
states.light.studio_dator,
states.light.badrum_vask_2,
states.light.badrum_vask_1,
states.light.sovrum_tv,
states.light.garderob_lampa,
states.light.hall_spot_1,
states.light.hall_spot_2,
states.light.hall_spot_3,
states.light.sovrum_mattias,
states.light.sovrum_sanja,
states.light.studio_spot_1,
states.light.studio_spot_2,
states.switch.deltaco_sh_p01_socket
] %}
{% set devices = [
states.switch.imac,
states.switch.ps5_635_power,
states.switch.gosund_monitors_switch,
states.switch.gosund_fan_switch,
states.media_player.samsung,
states.media_player.sony_bravia_tv,
states.climate.ac
] %}
{% set lights_on = lights | selectattr('state','eq','on') | list %}
{% set lights_name = lights | selectattr('state','eq','on') | map(attribute='name') | join(', ') %}
{% set devices_on = devices | selectattr('state','search','(on|cool|fan_only|playing)') | list %}
{% set devices_name = devices_on | map(attribute='name') | join(', ') %}
{% if (lights_on | length == 0) and (devices_on | length > 0) %}
{{ devices_name | regex_replace(',([^,]*)$',' och\\1') }} är på
{% elif (lights_on | length == 1) and (devices_on | length == 1) %}
{{ lights_name }} och {{devices_name }} är på
{% elif (lights_on | length == 1) and (devices_on | length > 1) %}
{{ lights_name }}, {{ devices_name | regex_replace(',([^,]*)$',' och\\1') }} är på
{% elif (lights_on | length > 1) and (devices_on | length == 1) %}
{{ lights_on | length }} lampor och {{ devices_name }} är på
{% elif (lights_on | length > 1) and (devices_on | length > 1) %}
{{ lights_on | length }} lampor, {{ devices_name | regex_replace(',([^,]*)$',' och\\1') }} är på
{% elif (lights_on | length == 1) and (devices_on | length == 0) %}
{{ lights_name }} är på
{% elif (lights_on | length > 1) and (devices_on | length == 0) %}
{{ lights_on | length }} lampor är på
{% else %}
<font color='#6a7377'>Allt är avstängt</font>
{% endif %}
</b>
mailbox: >
{% set mailbox = states('sensor.mailbox') %}
{% if mailbox | int(default=0) > 0 %}
{{ '\U0001F4EC' }} <font color='#6a7377'><b>Brevlåda ({{ mailbox }})</b></font>
{% endif %}
vacuum: >
{% set entity_id = 'vacuum.morty' %}
{% if is_state(entity_id, 'cleaning') %}
<b>Morty dammsuger</b>
{% elif is_state(entity_id, 'returning') %}
<b>Morty är färdig</b>
{% endif %}
weather: >
{% set entity = 'weather.smhi_home' %}
{% if not is_state(entity, 'unknown') %}
{% set temp = state_attr(entity, 'temperature') | round %}
{% set precip = state_attr(entity, 'forecast')[0]['precipitation'] | round %}
Känns som {{ temp }}° med {{ 'ingen risk för regn' if precip == 0
else precip | string + 'mm regn \u2614\uFE0F' }}
{% else %}
Kan inte läsa in väder...
{% endif %}
laundry: >
{% set date_data = state_attr('sensor.laundry_data', 'date') | as_datetime %}
{% set time_data = state_attr('sensor.laundry_data', 'time') %}
{% set number_data = state_attr('sensor.laundry_data', 'number') %}
{% set start_time = date_data.strftime('%Y-%m-%d %H:%M:%S') %}
{% if start_time != None %}
{% set time = as_timestamp(start_time) | timestamp_custom('%H:%M') %}
{% set hours = as_timestamp(start_time) | timestamp_custom('%H') | int(default=0) / 24 %}
{% set count = (as_timestamp(start_time) - as_timestamp(now())) / 86400 - hours %}
{% set day = strptime(start_time, '%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') %}
{% if count <= 0.0 %}
{{'\U0001F4A6'}} Tvätt idag {{ time_data }}, Tvättstuga {{ number_data }}
{% elif count <= 1.0 %}
Tvätt imorgon klockan {{ time }}
{% elif count <= 2.0 %}
Tvätt i övermorgon klockan {{ time }}
{% else %}
Tvätt om {{ (count + hours) | round }} dagar på {{ day }} kl {{ time }}
{% endif %}
{% endif %}
battery: >
{% set entities = states.sensor
| selectattr('entity_id', 'search', 'battery')
| rejectattr('entity_id', 'search', 'iphone')
| map(attribute = 'entity_id') | list %}
{% for sensor in entities if states(sensor) != 'unknown' and states(sensor) !=
'unavailable' and states(sensor) != 'None' and states(sensor) | int(default=0) <= 5 %}
{% if loop.first %} {{'\u26A0\uFE0F'}} Batteri {% else %}, {% endif %}
{{ state_attr(sensor, 'friendly_name') }} {{ states(sensor) }}%
{% endfor %}