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

 找回密码
 立即注册
查看: 1403|回复: 3

[插件集成] [Blueprint] 小米/绿米魔方玩具 (Z2M) 自动化蓝图

[复制链接]

19

主题

290

帖子

1510

积分

论坛技术达人

积分
1510
金钱
1205
HASS币
130
发表于 2022-6-1 13:39:08 | 显示全部楼层 |阅读模式

xiaomi_cube_controller_z2m.yaml

blueprint:
  name: Aqara Magic Cube (Z2M)
  description: Control anything using Aqara Magic Cube (Z2M) - V1.2
  domain: automation
  input:
    remote:
      name: Remote
      description: Magic Cube to use
      selector:
        entity:
          integration: mqtt
          domain: sensor
    slide_face_0:
      name: Slide the cube with face 0 up
      default: []
      selector:
        action: {}
    doubletap_face_0:
      name: Double tap the cube with face 0 up
      default: []
      selector:
        action: {}
    flipped90_face_0:
      name: Flip the cube 90 degrees to face 0
      default: []
      selector:
        action: {}
    flipped180_face_0:
      name: Flip the cube 180 degrees to face 0
      default: []
      selector:
        action: {}
    rotate_cw_face_0:
      name: Rotate cube clockwise with face 0 up
      default: []
      selector:
        action: {}
    rotate_ccw_face_0:
      name: Rotate cube counter clockwise with face 0 up
      default: []
      selector:
        action: {}
    slide_face_1:
      name: Slide the cube with face 1 up
      default: []
      selector:
        action: {}
    doubletap_face_1:
      name: Double tap the cube with face 1 up
      default: []
      selector:
        action: {}
    flipped90_face_1:
      name: Flip the cube 90 degrees to face 1
      default: []
      selector:
        action: {}
    flipped180_face_1:
      name: Flip the cube 180 degrees to face 1
      default: []
      selector:
        action: {}
    rotate_cw_face_1:
      name: Rotate cube clockwise with face 1 up
      default: []
      selector:
        action: {}
    rotate_ccw_face_1:
      name: Rotate cube counter clockwise with face 1 up
      default: []
      selector:
        action: {}
    slide_face_2:
      name: Slide the cube with face 2 up
      default: []
      selector:
        action: {}
    doubletap_face_2:
      name: Double tap the cube with face 2 up
      default: []
      selector:
        action: {}
    flipped90_face_2:
      name: Flip the cube 90 degrees to face 2
      default: []
      selector:
        action: {}
    flipped180_face_2:
      name: Flip the cube 180 degrees to face 2
      default: []
      selector:
        action: {}
    rotate_cw_face_2:
      name: Rotate cube clockwise with face 2 up
      default: []
      selector:
        action: {}
    rotate_ccw_face_2:
      name: Rotate cube counter clockwise with face 2 up
      default: []
      selector:
        action: {}
    slide_face_3:
      name: Slide the cube with face 3 up
      default: []
      selector:
        action: {}
    doubletap_face_3:
      name: Double tap the cube with face 3 up
      default: []
      selector:
        action: {}
    flipped90_face_3:
      name: Flip the cube 90 degrees to face 3
      default: []
      selector:
        action: {}
    flipped180_face_3:
      name: Flip the cube 180 degrees to face 3
      default: []
      selector:
        action: {}
    rotate_cw_face_3:
      name: Rotate cube clockwise with face 3 up
      default: []
      selector:
        action: {}
    rotate_ccw_face_3:
      name: Rotate cube counter clockwise with face 3 up
      default: []
      selector:
        action: {}
    slide_face_4:
      name: Slide the cube with face 4 up
      default: []
      selector:
        action: {}
    doubletap_face_4:
      name: Double tap the cube with face 4 up
      default: []
      selector:
        action: {}
    flipped90_face_4:
      name: Flip the cube 90 degrees to face 4
      default: []
      selector:
        action: {}
    flipped180_face_4:
      name: Flip the cube 180 degrees to face 4
      default: []
      selector:
        action: {}
    rotate_cw_face_4:
      name: Rotate cube clockwise with face 4 up
      default: []
      selector:
        action: {}
    rotate_ccw_face_4:
      name: Rotate cube counter clockwise with face 4 up
      default: []
      selector:
        action: {}
    slide_face_5:
      name: Slide the cube with face 5 up
      default: []
      selector:
        action: {}
    doubletap_face_5:
      name: Double tap the cube with face 5 up
      default: []
      selector:
        action: {}
    flipped90_face_5:
      name: Flip the cube 90 degrees to face 5
      default: []
      selector:
        action: {}
    flipped180_face_5:
      name: Flip the cube 180 degrees to face 5
      default: []
      selector:
        action: {}
    rotate_cw_face_5:
      name: Rotate cube clockwise with face 5 up
      default: []
      selector:
        action: {}
    rotate_ccw_face_5:
      name: Rotate cube counter clockwise with face 5 up
      default: []
      selector:
        action: {}
    shake:
      name: Shake the cube
      default: []
      selector:
        action: {}
    fall:
      name: Drop the cube
      default: []
      selector:
        action: {}
  source_url: https://community.home-assistant.io/t/z2m-xiaomi-cube-controller/263006
mode: queued
max: 5
max_exceeded: silent
trigger:
- platform: state
  entity_id: !input 'remote'
condition:
  - condition: and
    conditions:
      - condition: template
        value_template: >-
          {{ trigger.from_state.state in ('rotate_right', 'rotate_left', 'flip90', 'flip180', 'slide', 'tap', 'shake', 'fall') }}
action:
- variables:
    event: '{{ trigger.from_state.state }}'
    sub_event: '{{ trigger.from_state.attributes.side }}'
- service: system_log.write
  data:
    level: info
    message: 'Blueprint Script: {{ event }} {{ sub_event }}'
- choose:
  - conditions: '{{ event == "slide" }}'
    sequence:
    - choose:
      - conditions: '{{ sub_event == 0 }}'
        sequence: !input 'slide_face_0'
      - conditions: '{{ sub_event == 1 }}'
        sequence: !input 'slide_face_1'
      - conditions: '{{ sub_event == 2 }}'
        sequence: !input 'slide_face_2'
      - conditions: '{{ sub_event == 3 }}'
        sequence: !input 'slide_face_3'
      - conditions: '{{ sub_event == 4 }}'
        sequence: !input 'slide_face_4'
      - conditions: '{{ sub_event == 5 }}'
        sequence: !input 'slide_face_5'
  - conditions: '{{ event == "tap" }}'
    sequence:
    - choose:
      - conditions: '{{ sub_event == 0 }}'
        sequence: !input 'doubletap_face_0'
      - conditions: '{{ sub_event == 1 }}'
        sequence: !input 'doubletap_face_1'
      - conditions: '{{ sub_event == 2 }}'
        sequence: !input 'doubletap_face_2'
      - conditions: '{{ sub_event == 3 }}'
        sequence: !input 'doubletap_face_3'
      - conditions: '{{ sub_event == 4 }}'
        sequence: !input 'doubletap_face_4'
      - conditions: '{{ sub_event == 5 }}'
        sequence: !input 'doubletap_face_5'
  - conditions: '{{ event == "flip90" }}'
    sequence:
    - choose:
      - conditions: '{{ sub_event == 0 }}'
        sequence: !input 'flipped90_face_0'
      - conditions: '{{ sub_event == 1 }}'
        sequence: !input 'flipped90_face_1'
      - conditions: '{{ sub_event == 2 }}'
        sequence: !input 'flipped90_face_2'
      - conditions: '{{ sub_event == 3 }}'
        sequence: !input 'flipped90_face_3'
      - conditions: '{{ sub_event == 4 }}'
        sequence: !input 'flipped90_face_4'
      - conditions: '{{ sub_event == 5 }}'
        sequence: !input 'flipped90_face_5'
  - conditions: '{{ event == "flip180" }}'
    sequence:
    - choose:
      - conditions: '{{ sub_event == 0 }}'
        sequence: !input 'flipped180_face_0'
      - conditions: '{{ sub_event == 1 }}'
        sequence: !input 'flipped180_face_1'
      - conditions: '{{ sub_event == 2 }}'
        sequence: !input 'flipped180_face_2'
      - conditions: '{{ sub_event == 3 }}'
        sequence: !input 'flipped180_face_3'
      - conditions: '{{ sub_event == 4 }}'
        sequence: !input 'flipped180_face_4'
      - conditions: '{{ sub_event == 5 }}'
        sequence: !input 'flipped180_face_5'
  - conditions: '{{ event == "rotate_right" }}'
    sequence:
    - choose:
      - conditions: '{{ sub_event == 0 }}'
        sequence: !input 'rotate_cw_face_0'
      - conditions: '{{ sub_event == 1 }}'
        sequence: !input 'rotate_cw_face_1'
      - conditions: '{{ sub_event == 2 }}'
        sequence: !input 'rotate_cw_face_2'
      - conditions: '{{ sub_event == 3 }}'
        sequence: !input 'rotate_cw_face_3'
      - conditions: '{{ sub_event == 4 }}'
        sequence: !input 'rotate_cw_face_4'
      - conditions: '{{ sub_event == 5 }}'
        sequence: !input 'rotate_cw_face_5'
  - conditions: '{{ event == "rotate_left" }}'
    sequence:
    - choose:
      - conditions: '{{ sub_event == 0 }}'
        sequence: !input 'rotate_ccw_face_0'
      - conditions: '{{ sub_event == 1 }}'
        sequence: !input 'rotate_ccw_face_1'
      - conditions: '{{ sub_event == 2 }}'
        sequence: !input 'rotate_ccw_face_2'
      - conditions: '{{ sub_event == 3 }}'
        sequence: !input 'rotate_ccw_face_3'
      - conditions: '{{ sub_event == 4 }}'
        sequence: !input 'rotate_ccw_face_4'
      - conditions: '{{ sub_event == 5 }}'
        sequence: !input 'rotate_ccw_face_5'
  - conditions: '{{ event == "shake" }}'
    sequence: !input 'shake'
  - conditions: '{{ event == "fall" }}'
    sequence: !input 'fall'

回复

使用道具 举报

40

主题

3056

帖子

1万

积分

超级版主

Nero

Rank: 8Rank: 8

积分
11149
金钱
8042
HASS币
182
发表于 2022-6-1 15:53:40 | 显示全部楼层
好强!!!
Nero
回复

使用道具 举报

3

主题

48

帖子

601

积分

高级会员

Rank: 4

积分
601
金钱
553
HASS币
0
发表于 2022-6-1 19:02:43 | 显示全部楼层

好强!!!
回复

使用道具 举报

0

主题

152

帖子

1456

积分

金牌会员

Rank: 6Rank: 6

积分
1456
金钱
1304
HASS币
0
发表于 2022-7-13 09:17:57 | 显示全部楼层
这个是怎么用的
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-26 01:42 , Processed in 0.047781 second(s), 25 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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