请选择 进入手机版 | 继续访问电脑版

『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 2663|回复: 1

[已解决] 关于service_template的使用问题

[复制链接]

106

主题

548

帖子

2728

积分

金牌会员

Rank: 6Rank: 6

积分
2728
金钱
2180
HASS币
20
发表于 2020-3-29 20:41:50 | 显示全部楼层 |阅读模式
本帖最后由 comeon_000 于 2020-3-29 23:37 编辑

写了一个脚本,调用的时候总是提示域和名称不匹配

Error executing script script.fan_oscillating. Invalid data for call_service at pos 1: Service  does not match format <domain>.<name>
代码如下:
  fan_oscillating:
    alias: shufang fan osc
    sequence:
      - service_template: >
          {% if oscillating == True %}
            script.turn_on_study_fan_osc
          {% elif oscillating == False %}
            script.shufang_fan_speed
            data_template:
              speed: "{{ speed }}"
          {% endif %}
      - service: input_select.select_option
        data_template:
          entity_id: input_select.shufang_fan_osc
          option: "{{ oscillating }}"

怀疑还是service_template的使用方法不太对,另外一个类似脚本就没这个问题,对比了很长时间,也没法先什么区别,看不出是哪里的问题,向大神求教
  shufang_fan_speed:
    alias: shufang fan speed
    sequence:
      - service_template: >
          {% if speed == '1' %}
            script.turn_on_study_fan1
          {% elif speed == '2' %}
            script.turn_on_study_fan2
          {% elif speed == '3' %}
            script.turn_on_study_fan3
          {% elif speed == '4' %}
            script.turn_on_study_fan4
          {% elif speed == '5' %}
            script.turn_on_study_fan5
          {% elif speed == '6' %}
            script.turn_on_study_fan6
          {% else %}
            script.turn_off_study_fan
          {% endif %}
      - service: input_select.select_option
        data_template:
          entity_id: input_select.shufang_fan_speed
          option: "{{ speed }}"





回复

使用道具 举报

106

主题

548

帖子

2728

积分

金牌会员

Rank: 6Rank: 6

积分
2728
金钱
2180
HASS币
20
 楼主| 发表于 2020-3-29 23:36:46 | 显示全部楼层
解决了,是少了一个else分支,没想到yaml对判断分支语句控制的这么严格
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-3-28 17:29 , Processed in 0.045902 second(s), 23 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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