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

 找回密码
 立即注册
查看: 2484|回复: 2

[求助] 关于自动化的疑问

[复制链接]

106

主题

549

帖子

2745

积分

金牌会员

Rank: 6Rank: 6

积分
2745
金钱
2196
HASS币
20
发表于 2020-10-18 17:39:08 | 显示全部楼层 |阅读模式
想写一个状态持续不更新超过5分钟就重启设备的自动化,看到官方有下面这种方式和我的需求刚好契合
In this example, the trigger fires if the state value of the entity remains the same for for the time specified, regardless of the current state value.
automation:
  trigger:
    platform: state
    entity_id: media_player.kitchen
    # The media player remained in its current state for 1 hour
    for: "01:00:00"


照葫芦画瓢写了如下代码:
- alias: bluetooth_gateway_notwork
  trigger:
    - platform: state
      entity_id: group.groupwet
      for: "00:05:00"
  action:
    - service: notify.mobile_app_du_s_iphone
      data: 
        title: '通知' 
        message: '蓝牙网关已重启' 
可是编译检查的时候,缺有错误提示:
Invalid config for [automation]: expected str for dictionary value @ data['trigger'][0]['from']. Got None. (See /config/configuration.yaml, line 63).


是我的代码写的有问题,还是这种方式已经失效了?
另外请教有其他方法实现这种状态持续不更新的监测吗


回复

使用道具 举报

98

主题

2866

帖子

1万

积分

超级版主

智能家居&单板滑雪痴迷爱好者

Rank: 8Rank: 8

积分
11435
金钱
8504
HASS币
460

教程狂人突出贡献

发表于 2020-10-19 08:25:34 | 显示全部楼层
看错误提示,‘from’是必须得有才行。可能是版本变化带来的新问题?
回复

使用道具 举报

106

主题

549

帖子

2745

积分

金牌会员

Rank: 6Rank: 6

积分
2745
金钱
2196
HASS币
20
 楼主| 发表于 2020-10-19 19:40:09 | 显示全部楼层
XCray 发表于 2020-10-19 08:25
看错误提示,‘from’是必须得有才行。可能是版本变化带来的新问题?

感觉像是新版本的问题,这种逻辑按道理是有应用场景的
state有一个last_updatetime的属性,不知道能不能用这个做一个自动化完成上述功能,还没想好怎么写程序
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-4-20 13:14 , Processed in 0.923112 second(s), 25 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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