Developer Tools
0
{## Imitate available variables: ##}
{% set my_test_json = {
"temperature": 25,
"unit": "°C"
} %}
The temperature is {{ my_test_json.temperature }} {{ my_test_json.unit }}.
{% if is_state("sun.sun", "above_horizon") -%}
The sun rose {{ relative_time(states.sun.sun.last_changed) }} ago.
{%- else -%}
The sun will rise at {{ as_timestamp(state_attr("sun.sun", "next_rising")) | timestamp_local }}.
{%- endif %}
For loop example getting entity values in the weather domain:
{% for state in states.weather -%}
{%- if loop.first %}The {% elif loop.last %} and the {% else %}, the {% endif -%}
{{ state.name | lower }} is {{state.state_with_unit}}
{%- endfor %}.
{{now()}}
现在时间{{ now().strftime('%Y-%m-%d %H:%M:%S') }}
现在时间{{ now().strftime('%H时%M分') }}
{{ states.binary_sensor.aqara_motion_sensor_rtcgq11lm_1_cn_version_by_homekit_contreller_in_hallway_3.last_changed }}
{{ as_timestamp(states.binary_sensor.aqara_motion_sensor_rtcgq11lm_1_cn_version_by_homekit_contreller_in_hallway_3.last_changed) | timestamp_local }}
{{ (as_timestamp(now()) - as_timestamp(states.binary_sensor.aqara_motion_sensor_rtcgq11lm_1_cn_version_by_homekit_contreller_in_hallway_3.last_changed)) }}
{{ (as_timestamp(now()) - as_timestamp(states.binary_sensor.aqara_motion_sensor_rtcgq11lm_1_cn_version_by_homekit_contreller_in_hallway_3.last_changed)) < 60 }}
{{ ['light.aqara_hub_m1s_edb6_lightbulb', 'light.dining_room'] | select('is_state', 'on') | list }}
{{ as_timestamp(now()) - as_timestamp(states.input_boolean.input_boolean_husband.last_changed) }}
The temperature is 25 °C.
The sun rose 11 hours ago.
For loop example getting entity values in the weather domain:
The forecast home is partlycloudy.
2023-09-10 16:43:14.691440+08:00
现在时间2023-09-10 16:43:14
现在时间16时43分
2023-09-10 07:26:22.679086+00:00
2023-09-10T15:26:22.679086+08:00
4612.014055967331
False
[]
{% for device in states.light %}
{{ device.name }} is {{ device.state }}
{%- endfor %}
{% for device in states.light %}
{{ device.name }} is {{ device.state }}, entity_id: {{ device.entity_id}}
{%- endfor %}
Yeelight Ceil26 0x1c5c4959 by Yeelight Integration by yeelink is on
yeelink.light.ceiling21 by alone's Miio for Yeelink is off
MiSmartLEDLivingRoomCeilingLight-5F74 mi home app by Homekit controller Mi Smart LED Ceiling Light SW is off
Aqara-Hub-M1S-EDB6 Lightbulb is off
Aqara Lightbulb T1 by aqara home mode Homekit Controller is off
米家多功能智能网关(新加坡版) Light is on
Yeelight吸顶灯c2001 by xiaomi miot auto integration Light is on
米家客厅吸顶灯 by xiaomi miot auto integration Light is off
Philips灯泡 by xiaomi miot auto integration Light is unavailable
yeeligt 1s color灯泡 by xiaomi miot auto integration Light is unavailable
米家蓝牙mesh led灯泡 light is on
Aqara 网关M1S Light is on
Yeelight m2筒灯 light is off
Aqara LED灯泡 T1 (可调色温) Light is off
Yeelight Color8 0x1c598a45 by yeelink integration is unavailable
米家智能插座2 蓝牙网关版2 Indicator Light is unavailable
插座cp2 indicator_light is unavailable
yeelink.light.ceil26 by ha0y's xiaomi_miot_raw is unavailable
米家蓝牙mesh led灯泡 is unavailable
Xiaomi 中枢网关 is unavailable
Yeelight m2筒灯 by xiaomi-miot-raw is unavailable
Aqara 网关M1S is unavailable
chuangmi.plug.212a01 by local Xiaomi Miot auto Indicator Light is unavailable
Aqara-Hub-M1S-3967 Lightbulb is unavailable
Lightbulb-3467 is unavailable
领普人体存在传感器ES1ZB(MI) Indicator Light is on
米家多功能智能网关(新加坡版) Light is unavailable
{{ area_entities("living room")}}
['light.yeelink_ceiling21_5f74_light', 'number.yeelink_ceiling21_5f74_off_delay_time', 'light.yeelink_light_ceiling21_by_alone_s_miio_for_yeelink', 'light.mismartledlivingroomceilinglight_5f74_mi_smart_led_ceiling_light_sw', 'button.mismartledlivingroomceilinglight_5f74_identify', 'light.aqara_hub_m1s_3967_lightbulb', 'alarm_control_panel.aqara_hub_m1s_3967_security_system', 'button.aqara_hub_m1s_3967_identify', 'switch.aqara_hub_m1s_3967_pairing_mode', 'sensor.motion_sensor_d3ee_battery_sensor', 'button.motion_sensor_d3ee_identify', 'sensor.motion_sensor_battery_sensor_2', 'button.motion_sensor_identify_2', 'binary_sensor.motion_sensor_2', 'button.lightbulb_identify', 'media_player.wifipuffer1c', 'sensor.linp_hb01_c930_occupancy_sensor', 'light.linp_hb01_c930_indicator_light', 'binary_sensor.aqara_motion_sensor_t1_china_version_no1_5', 'sensor.aqara_motion_sensor_t1_china_version_no1_battery_sensor_5', 'button.aqara_motion_sensor_t1_china_version_no1_identify_5', 'sensor.wireless_router_wta301_external_ip', 'sensor.wireless_router_wta301_kib_s_received', 'sensor.wireless_router_wta301_kib_s_sent', 'sensor.mi_jia_duo_gong_neng_zhi_neng_wang_guan_xin_jia_po_ban_illuminance', 'alarm_control_panel.mi_jia_duo_gong_neng_zhi_neng_wang_guan_xin_jia_po_ban_alarm', 'light.mi_jia_duo_gong_neng_zhi_neng_wang_guan_xin_jia_po_ban_light']
{% set devices = states | map(attribute='entity_id') | map('device_id') | unique | reject('eq',None) | list %}
{%- set ns = namespace(integrations = []) %}
{%- for device in devices %}
{%- set ids = device_attr(device, 'identifiers') | list | first %}
{%- if ids and ids | length == 2 %}
{%- set integration, something_unique = ids %}
{%- if integration not in ns.integrations %}
{%- set ns.integrations = ns.integrations + [ integration ] %}
{%- endif %}
{%- endif %}
{%- endfor %}
{{ ns.integrations }}
['xiaomi_miot', 'xiaomi_miio', 'mobile_app', 'upnp', 'yeelight', 'broadlink', 'miio_yeelink', 'vlc_telnet', 'dlna_dmr']
{{devices}}
['00a88c8e6d25a006fdf1562307fd7388', '37ab23ca3178def57515f3becace3470', 'af5e4e17ec89c6d706998dcc7008704c', '3f34b3f4da9da1a89ad6fbc23aec6b01', 'e7c1f81f76433c7057305822f3a06838', 'c7c7a7bf4cc344e9b64cb852a48f8f49', '0ab42053111739d489fad031679558ff', '7cf635d3b03403a910d40f7173d9c134', '4379c994e1c43beb86bd97e98de5df2a', 'eba52a095ebc4c8c5737c409f77bda13', '2f26042c6da881154393d1582543f819', '013097d27df13c2ede8662381d726e2b', 'afbb62049caa030ca9381b326452e44c', '6862c624872d41e387de92a2e134c564', '79d9044e7b69cb3118c74e427b137ef7', '36616a3dba21fc3900be2f5cd88d5b3f', '6f5e003de372c0f7e2a5bf372c274851', 'd02902c42987dce38658a0ba1db66c81', '51a42c63f0d646d18cd4aac261a85901', '0e4841e72f88ef59fbe9bc5fa83eff6d', '161c2c71624568f23bc244c2b2a3ab9e', '980365bd2034c38ef331000215c8b2aa', 'cc15e483c69eed452ec76fe10ae4e41c', 'cfb77ff8d31bb14119e8d6ac69cd3ebe', '8e2aabeb5df6f5b6644bf714b41324c1', 'a1062da9f630cb4891eaa8d4107aa134', '20d180d0e52e5d009b9c53bf6a844577', '2a6e4f2b0c67d00d56b0f8b45c46cf48', '1a109adf4ae12c3ff10e8eb89d3e84c0', '0ce2264347c3366d65623d1f5dad858f', '1cb4ea91ab8b8002bd7c0beb7b35468c', 'c63c73cd8b1ca527b1b59a1665c22ce2', '0e769df40421eb544e674c67791bef56', '1d3f75234f1f1765f622503ef7c6acc4', '2fe3391d308fb1a124505c691286c7db', '109fb7267c479bf934377cb8cd3dd79b', '76670b30df9f76307dc340f2f817292a', '989b2d7a561ea77c2f7716619513d7c9', '294f1aaca45aa25492d7d6b305de401c', 'a62a7d7c57c5ca57073313a4dc4404b0', '83a15d106b5c8566b78ad5fbf282b17e', 'c571e0973dde7b840d424f99491dd3ac', '8e6f94be7c4c8086a7c9feafffc3ec43', '01415f461232c0ba527db6bdceb2aef2']
{% for device in devices %}
{{device_attr(device, 'manufacturer')}}
{{device_entities(device)}}
{% endfor %}
lumi
['light.lumi_acn01_edb6_light', 'alarm_control_panel.lumi_acn01_edb6_arming', 'sensor.lumi_acn01_edb6_illumination']
Yeelight
['binary_sensor.yeelight_ceil26_0x1c5c4959_nightlight', 'light.yeelight_ceil26_0x1c5c4959']