代码拉取完成,页面将自动刷新
- 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 %}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。