美文网首页
ha 条件判断 调试套路代码

ha 条件判断 调试套路代码

作者: 吉凶以情迁 | 来源:发表于2024-08-09 21:33 被阅读0次
         {{state_attr('media_player.xiaomi_l06a_3796_play_control','playing_state')==2}}
    

    不靠谱 ,无法判断是否暂停

    alias: 音乐列表
    sequence:
      - device_id: 93140cf3b25e84aad396604a8715f85b
        domain: button
        entity_id: 3b7bfa1c6b398597e2968975fd2dafbc
        type: press
      - delay:
          hours: 0
          minutes: 0
          seconds: 2
          milliseconds: 0
      - device_id: 93140cf3b25e84aad396604a8715f85b
        domain: text
        entity_id: 44c8b92ad2a226ad38e21796190053f9
        type: set_value
        value: 自动化触发,即将播放本地音乐列表
      - delay:
          hours: 0
          minutes: 0
          seconds: 3
          milliseconds: 0
      - wait_template: >-
          {{state_attr('media_player.xiaomi_l06a_3796_play_control','playing_state')==2}}
        continue_on_timeout: false
        timeout: "0"
      - service: media_player.play_media
        target:
          entity_id:
            - media_player.xiaomi_l06a_3796_play_control
          area_id: []
        data:
          media_content_id: http://192.168.2.58:8123/local/music/yygsx.mp3
          media_content_type: music
      - delay:
          hours: 0
          minutes: 0
          seconds: 20
          milliseconds: 0
      - wait_template: >-
          {{state_attr('media_player.xiaomi_l06a_3796_play_control','playing_state')==2}}
        continue_on_timeout: false
      - service: media_player.play_media
        metadata: {}
        data:
          media_content_id: http://192.168.2.58:8123/local/music/zmr.mp3
          media_content_type: music
        target:
          entity_id:
            - media_player.xiaomi_l06a_3796_play_control
      - delay:
          hours: 0
          minutes: 0
          seconds: 20
          milliseconds: 0
      - wait_template: >-
          {{state_attr('media_player.xiaomi_l06a_3796_play_control','playing_state')==2}}
        continue_on_timeout: false
      - service: media_player.play_media
        metadata: {}
        data:
          media_content_id: http://192.168.2.58:8123/local/music/zmr.mp3
          media_content_type: music
        target:
          entity_id:
            - media_player.xiaomi_l06a_3796_play_control
      - delay:
          hours: 0
          minutes: 0
          seconds: 20
          milliseconds: 0
      - wait_template: >-
          {{state_attr('media_player.xiaomi_l06a_3796_play_control','playing_state')==2}}
        continue_on_timeout: false
      - service: media_player.play_media
        metadata: {}
        data:
          media_content_id: http://192.168.2.58:8123/local/music/zmr.mp3
          media_content_type: music
        target:
          entity_id:
            - media_player.xiaomi_l06a_3796_play_control
      - delay:
          hours: 0
          minutes: 0
          seconds: 20
          milliseconds: 0
      - wait_template: >-
          {{state_attr('media_player.xiaomi_l06a_3796_play_control','playing_state')==2}}
        continue_on_timeout: false
      - service: media_player.play_media
        metadata: {}
        data:
          media_content_id: http://192.168.2.58:8123/local/music/zmr.mp3
          media_content_type: music
        target:
          entity_id:
            - media_player.xiaomi_l06a_3796_play_control
      - delay:
          hours: 0
          minutes: 0
          seconds: 20
          milliseconds: 0
      - wait_template: >-
          {{state_attr('media_player.xiaomi_l06a_3796_play_control','playing_state')==2}}
        continue_on_timeout: false
      - service: media_player.play_media
        metadata: {}
        data:
          media_content_id: http://192.168.2.58:8123/local/music/zmr.mp3
          media_content_type: music
        target:
          entity_id:
            - media_player.xiaomi_l06a_3796_play_control
      - delay:
          hours: 0
          minutes: 0
          seconds: 20
          milliseconds: 0
      - wait_template: >-
          {{state_attr('media_player.xiaomi_l06a_3796_play_control','playing_state')==2}}
        continue_on_timeout: false
      - service: media_player.play_media
        metadata: {}
        data:
          media_content_id: http://192.168.2.58:8123/local/music/zmr.mp3
          media_content_type: music
        target:
          entity_id:
            - media_player.xiaomi_l06a_3796_play_control
      - delay:
          hours: 0
          minutes: 0
          seconds: 20
          milliseconds: 0
      - wait_template: >-
          {{state_attr('media_player.xiaomi_l06a_3796_play_control','playing_state')==2}}
        continue_on_timeout: false
      - service: media_player.play_media
        metadata: {}
        data:
          media_content_id: http://192.168.2.58:8123/local/music/zmr.mp3
          media_content_type: music
        target:
          entity_id:
            - media_player.xiaomi_l06a_3796_play_control
      - delay:
          hours: 0
          minutes: 0
          seconds: 20
          milliseconds: 0
      - wait_template: >-
          {{state_attr('media_player.xiaomi_l06a_3796_play_control','playing_state')==2}}
        continue_on_timeout: false
      - service: media_player.play_media
        metadata: {}
        data:
          media_content_id: http://192.168.2.58:8123/local/music/zmr.mp3
          media_content_type: music
        target:
          entity_id:
            - media_player.xiaomi_l06a_3796_play_control
      - delay:
          hours: 0
          minutes: 0
          seconds: 20
          milliseconds: 0
      - wait_template: >-
          {{state_attr('media_player.xiaomi_l06a_3796_play_control','playing_state')==2}}
        continue_on_timeout: false
      - service: media_player.play_media
        metadata: {}
        data:
          media_content_id: http://192.168.2.58:8123/local/music/zmr.mp3
          media_content_type: music
        target:
          entity_id:
            - media_player.xiaomi_l06a_3796_play_control
      - device_id: 93140cf3b25e84aad396604a8715f85b
        domain: text
        entity_id: 44c8b92ad2a226ad38e21796190053f9
        type: set_value
      - if:
          - condition: device
            device_id: 93140cf3b25e84aad396604a8715f85b
            domain: media_player
            entity_id: 36070dc643545648b947d04ab181b34f
            type: is_paused
          - condition: or
            conditions:
              - condition: device
                device_id: 93140cf3b25e84aad396604a8715f85b
                domain: media_player
                entity_id: 36070dc643545648b947d04ab181b34f
                type: is_idle
        then:
          - service: media_player.play_media
            metadata: {}
            data:
              media_content_id: http://192.168.2.58:8123/local/music/zmr.mp3
              media_content_type: music
    mode: queued
    max: 20
    
    

    似乎靠谱的判断
    {{states.media_player.xiaomi_l06a_3796_play_control.state.find("playing")==0}}

    打印属性以及区别

    相关文章

      网友评论

          本文标题:ha 条件判断 调试套路代码

          本文链接:https://www.haomeiwen.com/subject/irufqjtx.html