2024年11月25日星期一 上午8:05:29

小爱对话记录实体使用场景及示例 #537

7 个月 前
#33026 引用
小爱对话记录实体使用场景及示例 #537

http://192.168.2.50:8123/config/automation/edit/1669815952897

http://192.168.2.50:8123/config/automation/edit/1669815952897
0
7 个月 前
#33027 引用
监听小爱同学对话




run ok

执行 自己的语音指令



alias: "小爱对话记录实体使用场景及示例 #537"
description: https://github.com/al-one/hass-xiaomi-miot/issues/537   http://localhost:4999/boards/topic/24027/%E5%B0%8F%E7%88%B1%E5%AF%B9%E8%AF%9D%E8%AE%B0%E5%BD%95%E5%AE%9E%E4%BD%93%E4%BD%BF%E7%94%A8%E5%9C%BA%E6%99%AF%E5%8F%8A%E7%A4%BA%E4%BE%8B-537
trigger:
  - platform: state
    entity_id:
      - sensor.xiaomi_lx06_026c_conversation
condition:
  - condition: template
    value_template: |-
      {{ (trigger.to_state|default(0)) and as_timestamp(now()) -
            as_timestamp(trigger.to_state.attributes.timestamp) < 60 }}
            {# 限制60秒内的对话 #}
action:
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ '测试打开' in trigger.to_state.state }}"
        sequence:
          - service: switch.turn_on
            target:
              entity_id: switch.cuco_cp2_7782_switch
            data: {}
      - conditions:
          - condition: template
            value_template: "{{ '测试关闭' in trigger.to_state.state }}"
        sequence:
          - service: switch.turn_on
            target:
              entity_id: switch.cuco_cp2_7782_switch
            data: {}
      - conditions:
          - condition: template
            value_template: " {{ '打开博联插座' in trigger.to_state.state }}"
        sequence:
          - service: switch.turn_on
            target:
              entity_id: >-
                switch.broadlink_smart_plug_sp4l_cn_30056_by_broadlink_integration
            data: {}
      - conditions:
          - condition: template
            value_template: "{{ '睡觉模式' in trigger.to_state.state }}"
        sequence:
          - service: input_select.select_option
            metadata: {}
            data:
              option: Sleep mode
            target:
              entity_id: input_select.input_select_husband_book_room_status_dropdown
    default: []
  - service: system_log.write
    data:
      level: info
      logger: custom_components.xiaomi_miot.xiaoai
      message: >
        "trigger.entity_id={{ trigger.entity_id }}: trigger.to_state.state ={{
        trigger.to_state.state }} by automation  小爱对话记录实体使用场景及示例
        #537"            
              
mode: single


0