forked from matt8707/hass-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sidebar.yaml
executable file
·96 lines (85 loc) · 4.45 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
- 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 = ['Monday', 'Tuesday', 'Wednesdey', 'Thursday', 'Friday', 'Saturday', 'Sunday'] %}
{% set months = ['January', 'February', 'March', 'April', 'Mau', 'June',
'July', 'August', 'September', 'October', '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 %} Good night {{'\U0001F611'}}
{% elif time <= 3 %} Good night {{'\U0001F62A'}}
{% elif time <= 5 %} Good night {{'\U0001F634'}}
{% elif time <= 7 %} Good morning {{'\U0001F4A9'}}
{% elif time <= 9 %} Good morning {{'\u2615\uFE0F'}}
{% elif time <= 10 %} Good morning {{'\U0001F642'}}
{% elif time <= 13 %} Good afternoon {{'\U0001F60A'}}
{% elif time <= 15 %} Good afternoon {{'\U0001F60E'}}
{% elif time <= 17 %} Good afternoon {{'\U0001F44B\U0001F3FB'}}
{% elif time <= 19 %} Good evening {{'\U0001F44B\U0001F3FB'}}
{% elif time <= 22 %} Good evening {{'\U0001F60C'}}
{% elif time <= 23 %} Good evening {{'\U0001F974'}}
{% else %} Good evening {{'\U0001F974'}}
{% endif %}
</b>
active: >
<b>
{% set lights = [] %}
{% set devices = [
states.media_player.sony_bravia_tv,
] %}
{% 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(',([^,]*)$',' and\\1') }} is on
{% elif (lights_on | length == 1) and (devices_on | length == 1) %}
{{ lights_name }} and {{devices_name }} is on
{% elif (lights_on | length == 1) and (devices_on | length > 1) %}
{{ lights_name }}, {{ devices_name | regex_replace(',([^,]*)$',' and\\1') }} is on
{% elif (lights_on | length > 1) and (devices_on | length == 1) %}
{{ lights_on | length }} lamps and {{ devices_name }} is on
{% elif (lights_on | length > 1) and (devices_on | length > 1) %}
{{ lights_on | length }} lamps, {{ devices_name | regex_replace(',([^,]*)$',' and\\1') }} is on
{% elif (lights_on | length == 1) and (devices_on | length == 0) %}
{{ lights_name }} is on
{% elif (lights_on | length > 1) and (devices_on | length == 0) %}
{{ lights_on | length }} lamps is on
{% else %}
<font color='#6a7377'>Everything is turned off</font>
{% endif %}
</b>
weather: >
{% set entity = 'weather.forecast_home' %}
{% if not is_state(entity, 'unknown') %}
{% set temp = state_attr(entity, 'temperature') | round %}
{% set precip = state_attr(entity, 'forecast')[0]['precipitation'] | round %}
Feels like {{ temp }}° with {{ 'no risk of rain' if precip == 0
else precip | string + 'mm rain \u2614\uFE0F' }}
{% else %}
Can't read weather...
{% endif %}
battery: >
{% set entities = states.sensor
| selectattr('entity_id', 'search', '_battery_level')
| 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) <= 30 %}
{% if loop.first %} {{'\u26A0\uFE0F'}} Battery {% else %}, {% endif %}
{{ state_attr(sensor, 'friendly_name') }} {{ states(sensor) }}%
{% endfor %}