-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplate.yaml
142 lines (127 loc) · 5.1 KB
/
template.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
# This is the "newer" way of making sensor or binary_sensor entities
- sensor:
- name: Greeting
state: >
Good {{
'morning' if now().hour < 12
else 'afternoon' if now().hour < 17
else 'evening'
}}
- name: Indoor dewpoint
device_class: temperature
unit_of_measurement: "°C"
state: >
{% set b = 17.67 %}
{% set c = 243.5 %}
{% set T = states('sensor.average_temperature') | float %}
{% set RH = states('sensor.average_humidity') | float %}
{% set gamma = log(RH / 100) + ((b * T) / (c + T)) %}
{{ ((c * gamma) / (b - gamma)) | round(1) }}
- name: Balcony dewpoint
device_class: temperature
unit_of_measurement: "°C"
state: >
{% set b = 17.67 %}
{% set c = 243.5 %}
{% set T = states('sensor.balcony_air_temperature') | float %}
{% set RH = states('sensor.balcony_air_humidity') | float %}
{% set gamma = log(RH / 100) + ((b * T) / (c + T)) %}
{{ ((c * gamma) / (b - gamma)) | round(1) }}
- name: "Adaptive Lighting Brightness: Home"
icon: "mdi:brightness-percent"
unit_of_measurement: "%"
state: "{{ state_attr('switch.adaptive_lighting_home', 'brightness_pct') | round(0) }}"
- name: "Adaptive Lighting Color Temp: Home"
icon: "mdi:palette"
unit_of_measurement: "mired"
state: "{{ state_attr('switch.adaptive_lighting_home', 'color_temp_mired') }}"
- name: Daily playlist
icon: mdi:spotify
# ISO weekday is 1 (Mon) .. 7 (Sun)
# Mon Discover weekly
# Tue Daily mix 1
# Wed Daily mix 2
# Thr Daily mix 3
# Fri Release radar
# Sat Daily mix 5
# Sun Daily mix 6
state: >
{% set playlists = {
1: "https://open.spotify.com/playlist/37i9dQZEVXcBLCgPN4zUED",
2: "https://open.spotify.com/playlist/37i9dQZF1E3500CBHfZVid",
3: "https://open.spotify.com/playlist/37i9dQZF1E36xhkhhnd6OW",
4: "https://open.spotify.com/playlist/37i9dQZF1E36PUMXDr0n6B",
5: "https://open.spotify.com/playlist/37i9dQZEVXbc0jST94T3I3",
6: "https://open.spotify.com/playlist/37i9dQZF1E36QhxXBTH2RE",
7: "https://open.spotify.com/playlist/37i9dQZF1E35TbkiCN416a"
} %}
{{ playlists[now().isoweekday()] }}
- name: Apple Watch rain sparkline
state: >
{%- set raindata = state_attr("sensor.precipitation_next_hour", "precipitation_rate") %}
{%- for fifteenminutes in raindata | batch(3) -%}
{%- set rainintensity = fifteenminutes | max -%}
{{ "▁" if rainintensity == 0 else
"▂" if rainintensity < 0.5 else
"▃" if rainintensity < 2.0 else
"▄" if rainintensity < 3.5 else
"▅" if rainintensity < 5.0 else
"▆" if rainintensity < 7.5 else
"▇" if rainintensity < 10 else
"█" if rainintensity < 15 else
"▓" }}
{%- endfor %}
- name: Apple Watch rain sparkline icon
state: >
{% set icon = state_attr("sensor.precipitation_next_hour", "icon") %}
{% set icons = {
"mdi:weather-sunny": "☀" if is_state("sun.sun", "above_horizon") else "🌙",
"mdi:weather-partly-cloudy": "⛅",
"mdi:weather-cloudy": "☁",
"mdi:weather-fog": "≡",
"mdi:weather-rainy": "💧",
"mdi:weather-lightning-rainy": "⚡",
"mdi:weather-pouring": "☔",
"mdi:weather-snowy": "❄️",
"mdi:weather-snowy-rainy": "❄️",
"mdi:weather-snowy-heavy": "❄️"
} %}
{{ icons.get(icon, "?") }}
- binary_sensor:
- name: Air quality
device_class: smoke
state: "{{ states('sensor.purifier_3h_pm2_5') | float > 100 }}"
- name: Vacation
state: "{{ distance(closest(states.person)) > 25 }}"
icon: "{{ 'mdi:island' if this.state == 'on' else 'mdi:home' }}"
attributes:
distance: "{{ distance(closest(states.person)) }}"
person: "{{ closest(states.person).name }}"
- name: Diningroom chair occupancy
# Change the door sensor to occupancy sensor and invert the state (door open = unoccupied)
device_class: occupancy
icon: mdi:table-chair
state: "{{ is_state('binary_sensor.diningroom_chair_contact', 'off') }}"
- name: Bathroom shower occupancy
device_class: moisture
state: "{{ states('sensor.bathroom_air_humidity') | int >= states('sensor.average_humidity') | int + 10 }}"
- name: Illuminance bright
icon: "mdi:theme-light-dark"
state: >
{% set lux = states('sensor.kitchen_illuminance_average') | int %}
{% set upper = states('input_number.illuminance_upper') | int %}
{% set lower = states('input_number.illuminance_lower') | int %}
{{
'on' if lux >= upper
else 'off' if lux < lower
else this.state
}}
- name: Study show sleep button
state: >
{{ (now().hour >= 0 and now().hour < 6) or
(is_state('light.study_lights', 'on') and (state_attr('light.study_lights', 'brightness') | int(0) < 20)) }}
- name: Entrance hall occupancy
device_class: motion
state: >
{{ is_state('binary_sensor.entrance_pir_occupancy', 'on') and
is_state('binary_sensor.hall_pir_occupancy', 'on') }}