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

 找回密码
 立即注册
查看: 3019|回复: 7

[技术探讨] 升级后两个自动化问题

[复制链接]

1

主题

143

帖子

3390

积分

论坛元老

Rank: 8Rank: 8

积分
3390
金钱
3247
HASS币
0
发表于 2019-3-25 14:17:11 | 显示全部楼层 |阅读模式
把系统从0.84升级到0.90后,原来的两个自动化出现问题,望大神帮忙解决一下,谢谢!
1、布谷鸟报时自动化

  - alias: Hourly Chime
    initial_state: true
    trigger:
      - platform: time_pattern
        hours: '/1'
        minutes: 0
        seconds: 0
    condition:
      - condition: time
        after: '06:50:00'
        before: '22:05:00'
    action:
      - service: xiaomi_aqara.play_ringtone
        data:
          gw_mac: ************
          ringtone_id: >
            {{now().strftime("%I") | int + 10000}}
          ringtone_vol: 40

升级后,系统报如下错误:
Error while executing automation automation.hourly_chime. Invalid data for call_service at pos 1: expected int for dictionary value @ data['ringtone_id']

2、小米网关灯根据空气质量显示不同的颜色

  - id: Air_sensor_light
    alias: Air_sensor_light
    initial_state: true
    trigger:
      - platform: state
        entity_id: input_boolean.sensor_light
        to: 'on'
      - platform: state
        entity_id: sensor.air_pollution
    action:
      - service: light.turn_on
        entity_id: light.gateway_light_***********
        data:
          brightness: 50
          color_name: >-
            {% if is_state("sensor.air_pollution", "优秀") %}
               green
            {% elif is_state("sensor.air_pollution", "良好") %}
               yellow
            {% elif is_state("sensor.air_pollution", "中等") %}
               orange
            {% elif is_state("sensor.air_pollution", "一般") %}
               red
            {% elif is_state("sensor.air_pollution", "较差") %}
               purple
            {% else %}
               brown
            {% endif %}


系统报如下错误:
Got unknown color {% if is_state("sensor.air_pollution", "优秀") %}
   green
{% elif is_state("sensor.air_pollution", "良好") %}
   yellow
{% elif is_state("sensor.air_pollution", "中等") %}
   orange
{% elif is_state("sensor.air_pollution", "一般") %}
   red
{% elif is_state("sensor.air_pollution", "较差") %}
   purple
{% else %}
   brown
{% endif %}, falling back to white

回复

使用道具 举报

40

主题

3057

帖子

1万

积分

超级版主

Nero

Rank: 8Rank: 8

积分
11135
金钱
8028
HASS币
182
发表于 2019-3-25 16:35:20 | 显示全部楼层
两个自动化感觉都是 template 模块解析出现问题,升级到最新版试试?
Nero
回复

使用道具 举报

1

主题

143

帖子

3390

积分

论坛元老

Rank: 8Rank: 8

积分
3390
金钱
3247
HASS币
0
 楼主| 发表于 2019-3-25 17:18:58 | 显示全部楼层
升级到了最新的0.90.1,还是同样的问题
回复

使用道具 举报

1

主题

92

帖子

285

积分

中级会员

Rank: 3Rank: 3

积分
285
金钱
193
HASS币
0
发表于 2019-3-25 18:29:28 | 显示全部楼层
请问楼主是如何使用{%%}的?为什么我的总是报错found character '%' that cannot start any token
回复

使用道具 举报

1

主题

143

帖子

3390

积分

论坛元老

Rank: 8Rank: 8

积分
3390
金钱
3247
HASS币
0
 楼主| 发表于 2019-3-26 08:57:36 | 显示全部楼层
alannana 发表于 2019-3-25 18:29
请问楼主是如何使用{%%}的?为什么我的总是报错found character '%' that cannot start any token ...

把你的代码贴出来看看
回复

使用道具 举报

1

主题

92

帖子

285

积分

中级会员

Rank: 3Rank: 3

积分
285
金钱
193
HASS币
0
发表于 2019-3-26 10:31:21 | 显示全部楼层
crazybobby 发表于 2019-3-26 08:57
把你的代码贴出来看看

已经解决了,谢楼主
回复

使用道具 举报

1

主题

92

帖子

285

积分

中级会员

Rank: 3Rank: 3

积分
285
金钱
193
HASS币
0
发表于 2019-3-26 10:33:52 | 显示全部楼层
ringtone_id: >
            {{now().strftime("%I") | int + 10000}}
这里大括号内不加%吗?“ | int” 是类型string转int吗?本人小白,求大神指教
回复

使用道具 举报

1

主题

143

帖子

3390

积分

论坛元老

Rank: 8Rank: 8

积分
3390
金钱
3247
HASS币
0
 楼主| 发表于 2019-3-27 19:51:22 | 显示全部楼层
大佬都在闭关吗?
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-4-26 19:47 , Processed in 0.051279 second(s), 29 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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