{
  "name": "Intercom \u64ad\u653e",
  "description": "Flask\u56de\u8c03\uff1a\u63a5\u6536{entity,url,duration} \u2192 HA\u64ad\u653e \u2192 Wait\u64ad\u5b8c",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "intercom/play",
        "options": {
          "noResponseBody": false
        }
      },
      "id": "f7c07106-4055-4558-8225-c4af99234873",
      "name": "Intercom Play",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        48
      ]
    },
    {
      "parameters": {
        "resource": "service",
        "operation": "call",
        "domain": "media_player",
        "service": "play_media",
        "serviceAttributes": {
          "attributes": [
            {
              "name": "entity_id",
              "value": "={{ $json.body.entity }}"
            },
            {
              "name": "media_content_id",
              "value": "={{ $json.body.url }}"
            },
            {
              "name": "media_content_type",
              "value": "music"
            }
          ]
        }
      },
      "id": "a3845526-8319-4457-a8c8-24352443d1eb",
      "name": "\u64ad\u653e\u5230\u97f3\u7bb1",
      "type": "n8n-nodes-base.homeAssistant",
      "typeVersion": 1,
      "position": [
        224,
        48
      ],
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "amount": "={{ $('Intercom Play').item.json.body.duration }} "
      },
      "id": "e6e4d918-5de4-4aca-bb97-173333983d21",
      "name": "\u7b49\u5f85\u64ad\u5b8c",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        672,
        144
      ]
    },
    {
      "parameters": {
        "resource": "service",
        "operation": "call",
        "domain": "media_player",
        "service": "media_pause",
        "serviceAttributes": {
          "attributes": [
            {
              "name": "entity_id",
              "value": "={{ $('Intercom Play').item.json.body.entity }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.homeAssistant",
      "typeVersion": 1,
      "position": [
        896,
        144
      ],
      "id": "6d8e492a-d024-4c84-b8cb-2f24732a44aa",
      "name": "Pause",
      "retryOnFail": false,
      "alwaysOutputData": true,
      "executeOnce": false
    },
    {
      "parameters": {
        "resource": "state",
        "entityId": "={{ $('Intercom Play').item.json.body.entity }}"
      },
      "type": "n8n-nodes-base.homeAssistant",
      "typeVersion": 1,
      "position": [
        1120,
        144
      ],
      "id": "318099b9-94a0-4d3d-8a0b-51254b16631b",
      "name": "Get a state",
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "b9d3234e-e99f-452d-a980-54c303c78126",
              "leftValue": "={{ $json.state }}",
              "rightValue": "playing",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        1344,
        144
      ],
      "id": "e4b9359e-fb94-4d6f-8b27-fc85684d59b1",
      "name": "If"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "b9d3234e-e99f-452d-a980-54c303c78126",
              "leftValue": "={{ $json.state }}",
              "rightValue": "playing",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            },
            {
              "id": "d3a748f1-46f6-48ba-afff-681d826ca10c",
              "leftValue": "={{ $runIndex }}",
              "rightValue": 5,
              "operator": {
                "type": "number",
                "operation": "gte"
              }
            }
          ],
          "combinator": "or"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        448,
        48
      ],
      "id": "2ec6a2e8-974c-4d7d-9d25-5c6fcabf6fb9",
      "name": "If1"
    },
    {
      "parameters": {
        "resource": "state",
        "entityId": "={{ $('Intercom Play').item.json.body.entity }}"
      },
      "type": "n8n-nodes-base.homeAssistant",
      "typeVersion": 1,
      "position": [
        896,
        -48
      ],
      "id": "0e02b48a-4086-4533-93af-600b878537ad",
      "name": "Get a state1",
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "amount": "=0.5"
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        672,
        -48
      ],
      "id": "2d34a800-e3db-493d-b206-22d1d25db937",
      "name": "Wait"
    }
  ],
  "connections": {
    "Intercom Play": {
      "main": [
        [
          {
            "node": "\u64ad\u653e\u5230\u97f3\u7bb1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u64ad\u653e\u5230\u97f3\u7bb1": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u7b49\u5f85\u64ad\u5b8c": {
      "main": [
        [
          {
            "node": "Pause",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pause": {
      "main": [
        [
          {
            "node": "Get a state",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get a state": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Pause",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "\u7b49\u5f85\u64ad\u5b8c",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get a state1": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Get a state1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "availableInMCP": true,
    "binaryMode": "separate"
  }
}