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

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

[技术探讨] 米家无线开关,ha感应执行动作【已解决】

[复制链接]

41

主题

521

帖子

2499

积分

金牌会员

Rank: 6Rank: 6

积分
2499
金钱
1973
HASS币
30
发表于 2018-3-2 10:03:20 | 显示全部楼层 |阅读模式
本帖最后由 czweb 于 2018-3-2 23:35 编辑

两键无线开关只能识别:左键单击、右键单击、左右一起单击。不支持双击和长按;



TIM图片20180302100144.png
TIM图片20180302100157.png


#########################################################################################
## 无线开关(贴墙式双键版)
#########################################################################################
- alias: hys_mode_on
  trigger:
    platform: event
    event_type: click
    event_data:
      entity_id: binary_sensor.wall_switch_left_158d000214fd4a
      click_type: single
  action:
    # - service: light.turn_on
    #   entity_id: light.gateway_light_7811dcb1f02c
    - service: persistent_notification.create
      data_template: 
        title: '无线开关(贴墙式双键版)'
        message: "左键单击{{now().strftime('%Y-%m-%d %H:%M:%S')}}"

- alias: hys_mode_off
  trigger:
    platform: event
    event_type: click
    event_data:
      entity_id: binary_sensor.wall_switch_right_158d000214fd4a
      click_type: single
  action:
    # - service: light.turn_off
    #   entity_id: light.gateway_light_7811dcb1f02c
    - service: persistent_notification.create
      data_template: 
        title: '无线开关(贴墙式双键版)'
        message: "右键单击{{now().strftime('%Y-%m-%d %H:%M:%S')}}"

- alias: hys_mode_state
  trigger:
    platform: event
    event_type: click
    event_data:
      entity_id: binary_sensor.wall_switch_both_158d000214fd4a
      click_type: both
  action:
    # - service: light.turn_off
    #   entity_id: light.gateway_light_7811dcb1f02c
    - service: persistent_notification.create
      data_template: 
        title: '无线开关(贴墙式双键版)'
        message: "双键单击{{now().strftime('%Y-%m-%d %H:%M:%S')}}"









回复

使用道具 举报

74

主题

1948

帖子

7935

积分

元老级技术达人

积分
7935
金钱
5937
HASS币
430

活跃会员教程狂人

发表于 2018-3-2 10:28:50 | 显示全部楼层
小米开关不都这样么...
所有过往,皆为序章。
回复

使用道具 举报

220

主题

1284

帖子

7847

积分

超级版主

Rank: 8Rank: 8

积分
7847
金钱
6533
HASS币
86

教程狂人论坛风云人物突出贡献

发表于 2018-3-2 10:44:29 | 显示全部楼层
好像是事件,不是状态
回复

使用道具 举报

27

主题

387

帖子

3105

积分

元老级技术达人

积分
3105
金钱
2698
HASS币
40

教程狂人

发表于 2018-3-2 15:33:37 | 显示全部楼层
你搞錯了

正確的設定方式
https://home-assistant.io/components/binary_sensor.xiaomi_aqara/

Xiaomi Wireless Button
Available events are single, double, hold, long_click_press and long_click_release. For Square version (Aqara brand) only single and double events are supported. Furthermore the space between two clicks to generate a double click must be quite large now.

- alias: Toggle dining light on single press
  trigger:
    platform: event
    event_type: click
    event_data:
      entity_id: binary_sensor.switch_158d000xxxxxc2
      click_type: single
  action:
    service: switch.toggle
    entity_id: switch.wall_switch_left_158d000xxxxx01
- alias: Toggle couch light on double click
  trigger:
    platform: event
    event_type: click
    event_data:
      entity_id: binary_sensor.switch_158d000xxxxxc2
      click_type: double
  action:
    service: switch.toggle
    entity_id: switch.wall_switch_right_158d000xxxxx01
- alias: Let a dog bark on long press
  trigger:
    platform: event
    event_type: click
    event_data:
      entity_id: binary_sensor.switch_158d000xxxxxc2
      click_type: long_click_press
  action:
    service: xiaomi_aqara.play_ringtone
    data:
      gw_mac: xxxxxxxxxxxx
      ringtone_id: 8
      ringtone_vol: 8
回复

使用道具 举报

41

主题

521

帖子

2499

积分

金牌会员

Rank: 6Rank: 6

积分
2499
金钱
1973
HASS币
30
 楼主| 发表于 2018-3-2 18:24:11 | 显示全部楼层
windgo 发表于 2018-3-2 15:33
你搞錯了

正確的設定方式

谢谢,event的方式已经测试过了,我再试一次吧
回复

使用道具 举报

41

主题

521

帖子

2499

积分

金牌会员

Rank: 6Rank: 6

积分
2499
金钱
1973
HASS币
30
 楼主| 发表于 2018-3-2 23:36:34 | 显示全部楼层
咸味土豆 发表于 2018-3-2 10:28
小米开关不都这样么...

已解决,谢谢
回复

使用道具 举报

41

主题

521

帖子

2499

积分

金牌会员

Rank: 6Rank: 6

积分
2499
金钱
1973
HASS币
30
 楼主| 发表于 2018-3-2 23:39:36 | 显示全部楼层
lidicn 发表于 2018-3-2 10:44
好像是事件,不是状态

已解决,谢谢
回复

使用道具 举报

41

主题

521

帖子

2499

积分

金牌会员

Rank: 6Rank: 6

积分
2499
金钱
1973
HASS币
30
 楼主| 发表于 2018-3-2 23:48:43 | 显示全部楼层
windgo 发表于 2018-3-2 15:33
你搞錯了

正確的設定方式

解决了,我买的这款仅支持单击,没有双击和长按
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-5-9 11:06 , Processed in 0.445495 second(s), 33 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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