找回密码
 立即注册
查看: 652|回复: 3

[信息发布] configuration配置文件判断语句如何写?

[复制链接]

1

主题

42

回帖

257

积分

中级会员

积分
257
金钱
214
HASS币
0
发表于 2024-10-4 01:46:09 | 显示全部楼层 |阅读模式
template:
    sensors:
      dn_dqms:
        friendly_name: '地暖_当前模式'
        value_template: "{{   state_attr('climate.fawad_40011_a039_thermostat', 'preset_mode') }}"
        unique_id: "32b33778a2614be0a3290f8200000003"
value_template我想写成
           {% if is_state('climate.fawad_40011_a039_thermostat.preset_mode', 'Mannu') %}
             手动
           {% else if is_state('climate.fawad_40011_a039_thermostat.preset_mode', 'Energy Saving') %}
             节能
           {% else if is_state('climate.fawad_40011_a039_thermostat.preset_mode', 'Sleep') %}
             睡眠
           {% else if is_state('climate.fawad_40011_a039_thermostat.preset_mode', 'Inhome') %}
             在家
           {% else if is_state('climate.fawad_40011_a039_thermostat.preset_mode', 'Outhome') %}
             离家
           {% else %}
             关闭
           {% endif %}
但是总是导致无法使用,请问各路大神这个判断语句要如何写?

回复

使用道具 举报

25

主题

260

回帖

2047

积分

金牌会员

积分
2047
金钱
1762
HASS币
0
发表于 2024-10-4 09:56:48 | 显示全部楼层
也可以直接创建辅助元素传感器如
{% if is_state('binary_sensor.*****', 'off') %}
            on
          {% elif is_state('binary_sensor.*****', 'on') %}
            off
          {% endif %}
回复

使用道具 举报

1

主题

42

回帖

257

积分

中级会员

积分
257
金钱
214
HASS币
0
 楼主| 发表于 2024-10-4 11:28:35 | 显示全部楼层
最后的解决方案就是没有使用is_state,改为使用state_attr取值去做判断了
回复

使用道具 举报

1

主题

42

回帖

257

积分

中级会员

积分
257
金钱
214
HASS币
0
 楼主| 发表于 2024-10-4 11:29:36 | 显示全部楼层
wpw72 发表于 2024-10-4 09:56
也可以直接创建辅助元素传感器如
{% if is_state('binary_sensor.*****', 'off') %}
            on

谢谢大神的建议
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian ( 晋ICP备17001384号-1 )

GMT+8, 2025-5-7 01:25 , Processed in 0.061116 second(s), 23 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表