- 积分
- 552
- 金钱
- 456
- 威望
- 0
- 贡献
- 0
- HASS币
- 0
高级会员
- 积分
- 552
- 金钱
- 456
- HASS币
- 0
|
参考了论坛很多文章,得出了自己的代码如下:
cover:
- platform: template
covers:
garage_door:
friendly_name: '车库门'
value_template: "{% if not is_state('binary_sensor.door_window_sensor_XXX', 'off') %}open{% else %}closed{% endif %}"
open_cover:
service: remote.send_command
entity_id: 'remote.xiaomi_miio_192_168_1_XXX'
data:
command:
- 'garage_door_2_open'
stop_cover:
service: remote.send_command
entity_id: 'remote.xiaomi_miio_192_168_1_XXX'
data:
command:
- 'garage_door_2_stop'
close_cover:
service: remote.send_command
entity_id: 'remote.xiaomi_miio_192_168_1_XXX'
data:
command:
- 'garage_door_2_close'
icon_template: "{% if not is_state('binary_sensor.door_window_sensor_XXX', 'off') %}mdi:garage-open{% else %}mdi:garage{% endif %}"
这个代码,是会自动出现出home kit实现开关的,并且正常使用,但是在HA里,在车库实际为关门的状态下,HA里的开门图标为灰色,无法按,如图所示:
翻遍了论坛的代码都是大同小异,请问问题出在那里呢?也不明白为何代码是选择if not is_state('binary_sensor.door_window_sensor_XXX', 'off'),
而不是if is_state('binary_sensor.door_window_sensor_XXX', 'on')
|
|