Skip to content

Instantly share code, notes, and snippets.

@kai-zer-ru
Created February 19, 2024 05:46
Show Gist options
  • Save kai-zer-ru/073dbca535a47aaa9a228601180f792d to your computer and use it in GitHub Desktop.
Save kai-zer-ru/073dbca535a47aaa9a228601180f792d to your computer and use it in GitHub Desktop.
HomeAssistant integration with NextCloud
{#
Base url - указываем ссылку на ваш HomeAssistant
Long-lived access token - вводим токен, который можно получить в HomeAsssistant в настройках пользователя (левый нижний угол, аватарка)
Template widget refresh interval (in seconds) - интервал обновления в секундах, у меня стоит 5
Template widget - тут сам код виджета
#}
{% if (states('sensor.water_leak_detect')|int) > 0 %}
<h2>Протечки: </h2>
<ul>{% for entity_name, entity_state in state_attr('sensor.water_leak_detect', 'list_entities')-%}
<li> {{ entity_name }} </li>
{% endfor %}
</ul>
<br>
{% endif %}
{% if states('sensor.otkritie_okna_i_dveri')|int > 0 %}
<br>
<h2>Открытые окна и двери: </h2>
<ul>
{% for entity_name, entity_state in state_attr('sensor.otkritie_okna_i_dveri', 'list_entities')-%}
<li> {{ entity_name }} </li>
{% endfor %}
</ul>
{%else %}
Нет открытых окон дверей
{% endif %}
{% set stations = ['media_player.yandex_tv_cea24f3ba56911d921f7','media_player.yandex_station_lp0000000000003275280000d3cec0a7', 'media_player.yandex_station_lb00000000000023316500005c0f041e', 'media_player.yandex_station_u00320300axc5b'] %}
{% set variable = namespace(value = {}) %}
{% for entity in states.media_player if is_state(entity.entity_id, 'playing') and entity.entity_id in stations %}
{% set variable.value = dict(variable.value, **{entity.name: entity.state }) %}
{% endfor %}
{% if (variable.value | length) | int > 0 %}
<br><br><h2>Играют станции:</h2>
{% for station in stations %}
{% if states(station) == 'playing' %}
<b>{{ state_attr(station, 'friendly_name') }}:</b> {{ state_attr(station, 'media_artist') }} - {{ state_attr(station, 'media_title') }}<br>
{% endif %}
{% endfor %}
{% endif %}
<br><br><h2>Чайник</h2>
<b>Температура</b> {{ state_attr('water_heater.skykettle_rk_m216s', 'current_temperature') }}°C<br>
<b>Режим: </b>
{% if state_attr('water_heater.skykettle_rk_m216s', 'operation_mode') == 'off' %} Отключен
{%elif state_attr('water_heater.skykettle_rk_m216s', 'operation_mode') == 'Heat' %} Поддержание температуры {{ state_attr('water_heater.skykettle_rk_m216s', 'temperature') }}°C
{%elif state_attr('water_heater.skykettle_rk_m216s', 'operation_mode') == 'Boil' %} Кипячение
{%elif state_attr('water_heater.skykettle_rk_m216s', 'operation_mode') == 'Boil+Heat' %} Кипячение + Поддержание температуры {{ state_attr('water_heater.skykettle_rk_m216s', 'temperature') }}°C
{%elif state_attr('water_heater.skykettle_rk_m216s', 'operation_mode') == 'Lamp' %} Лампа
{%elif state_attr('water_heater.skykettle_rk_m216s', 'operation_mode') == 'Light' %} Светильник {%else%} Недоступен
{%endif%}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment