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

 找回密码
 立即注册
查看: 990|回复: 4

[求助] 二进制传感器的模块如何写? 事件如下

[复制链接]

204

主题

552

帖子

3903

积分

论坛元老

Rank: 8Rank: 8

积分
3903
金钱
3351
HASS币
0
发表于 2023-1-17 12:03:55 | 显示全部楼层 |阅读模式
请教大家我想写一个二进制模板,就是当下面的绿米fp1传感器binary_sensor.fp1_new_presence的presence_event属性变为approach状态后,二进制模板里,定义新的二进制传感器属性为on.
这个如何写呀?
下面是侦测到的fp1传感器有人接近的事件
newspaper(108109588)  11:58:57
event_type: state_changed
data:
  entity_id: binary_sensor.fp1_new_presence
  old_state:
    entity_id: binary_sensor.fp1_new_presence
    state: "off"
    attributes:
      approach_distance: near
      device_temperature: 23
      linkquality: 211
      monitoring_mode: left_right
      motion_sensitivity: medium
      power_outage_count: 0
      presence: false
      presence_event: approach

因为利用fp1本身的二进制传感器侦测人存在时,太延迟了。所以想用这个办法。




回复

使用道具 举报

204

主题

552

帖子

3903

积分

论坛元老

Rank: 8Rank: 8

积分
3903
金钱
3351
HASS币
0
 楼主| 发表于 2023-1-17 12:07:45 | 显示全部楼层
template:
- binary_sensor:
      - name: 移动感应fp1_new
        device_class: motion
        auto_off: 10
        state: "{{ is_device_attr('binary_sensor.fp1_new_presence', 'presence_event', 'approach') }} "

上面是我看了官网的介绍写的。但不成功。大家看看错在哪里?
回复

使用道具 举报

204

主题

552

帖子

3903

积分

论坛元老

Rank: 8Rank: 8

积分
3903
金钱
3351
HASS币
0
 楼主| 发表于 2023-1-17 12:31:12 | 显示全部楼层
或者在z2m或zha里如何修改配置文件,就是绿米的fp1一但侦测到人,马上显示为在家。而不是等到三秒后。
回复

使用道具 举报

76

主题

1365

帖子

1万

积分

元老级技术达人

积分
19508
金钱
18103
HASS币
290
发表于 2023-1-17 14:31:12 | 显示全部楼层
newspaper 发表于 2023-1-17 12:07
template:
- binary_sensor:
      - name: 移动感应fp1_new

auto_off time (optional)
Requires a trigger. After how much time the entity should turn off after it rendered ‘on’.

看文档说需要增加一项触发条件。

template:
  - trigger:
      - platform: state
        entity_id: binary_sensor.fp1_new_presence
        attribute: presence_event

    binary_sensor:
      - name: 移动感应fp1_new
            device_class: motion
            auto_off: 10
            state: "{{ is_device_attr('binary_sensor.fp1_new_presence', 'presence_event', 'approach') }} "



不知道这个 presence_event 状态变化来触发行不行
回复

使用道具 举报

204

主题

552

帖子

3903

积分

论坛元老

Rank: 8Rank: 8

积分
3903
金钱
3351
HASS币
0
 楼主| 发表于 2023-1-17 15:43:58 | 显示全部楼层
dscao 发表于 2023-1-17 14:31
auto_off time (optional)
Requires a trigger. After how much time the entity should turn off after  ...

非常感谢! 可以了!
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-5-29 20:06 , Processed in 0.053687 second(s), 27 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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