# HomeyScript runFlowCardAction for Home Assitant

**URL:** <https://community.homey.app/t/homeyscript-runflowcardaction-for-home-assitant/138051>\
**Category:** Questions & Help\
**Tags:** app, flow, homey-pro\
**Created:** [June 12, 2025, 2:47pm UTC](https://community.homey.app/t/homeyscript-runflowcardaction-for-home-assitant/138051 "2025-06-12T14:47:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kurt1](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/kurt1/32/79399_2.png) [@Kurt1](https://community.homey.app/u/Kurt1)\
**Post date:** [June 12, 2025, 2:47pm UTC](https://community.homey.app/t/homeyscript-runflowcardaction-for-home-assitant/138051/1 "2025-06-12T14:47:44Z")

</div>

I am trying to use a Home Assistant flowcard in a HomeyScript using the runFlowCardAction to call the ‘chime\_tts.say’ service on HA from HomeyScript, but so far I have not gotten it to function.  
I tried several things so far, but always get an error.

```auto
//Attempt 1

const MediaPlayer = "media_player.woonkamer"

action ={
    "id": "homey:app:io.home-assistant.community:callServiceEntity",
    "args": [
        {"service":"chime_tts.say"},
        {"entity":MediaPlayer},
        {"data":"{\"volume_level\": 0.56,\"fade_audio\": true,\"message\": \"Dit is een testje vanuit Homey\"}"}
    ]
}

test = await Homey.flow.runFlowCardAction(action)
console.log(test)

//Attempt 2

action ={
    "id": "homey:app:io.home-assistant.community:callServiceEntity",
    "args": {
        "service":"chime_tts.say",
        "entity":MediaPlayer,
        "data":"{\"volume_level\": 0.56,\"fade_audio\": true,\"message\": \"Dit is een testje vanuit Homey\"}"
    }
}

test = await Homey.flow.runFlowCardAction(action)
console.log(test)

//Attempt 2

action ={
    "id": "homey:app:io.home-assistant.community:callServiceEntity",
    "args": [
        {"variable":{"name":"service"},"value":"chime_tts.say"},
        {"variable":{"name":"entity"},"value":MediaPlayer},
        {"variable":{"name:":"data"},"value":"{\"volume_level\": 0.56,\"fade_audio\": true,\"message\": \"Dit is een testje vanuit Homey\"}"}
    ]
}

test = await Homey.flow.runFlowCardAction(action)
console.log(test)

```

---

<div class="post-metadata">

**Author:** ![Arnt\_Soloy](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arnt_soloy/32/58318_2.png) [@Arnt\_Soloy](https://community.homey.app/u/Arnt_Soloy)\
**Post date:** [June 12, 2025, 4:41pm UTC](https://community.homey.app/t/homeyscript-runflowcardaction-for-home-assitant/138051/2 "2025-06-12T16:41:37Z")

</div>

From Homey web api:  
 → runFlowCardAction  
(async) runFlowCardAction(opts): Promise. then  
POST /api/manager/flow/flowcardaction/:uri/:id/run

It expects 2 keys, so in your case i would assume it should be:

uri: ‘homey:app:io.home-assistant.community’,  
id: ‘callServiceEntity’,

and not both in id:..

---

<div class="post-metadata">

**Author:** ![Kurt1](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/kurt1/32/79399_2.png) [@Kurt1](https://community.homey.app/u/Kurt1)\
**Post date:** [June 12, 2025, 7:36pm UTC](https://community.homey.app/t/homeyscript-runflowcardaction-for-home-assitant/138051/3 "2025-06-12T19:36:57Z")

</div>

Hi, thanks, but that didn’t work.

When I run

```auto
log('===========');
log('Then-cards:');
log('===========');
const actionCards = await Homey.flow.getFlowCardActions();
for( const card of Object.values(actionCards) ) {
  log(card.titleFormatted || card.title)
  log(JSON.stringify({
    uri: card.uri,
    id: card.id,
    args: card.args,
    droptoken: card.droptoken,
    duration: card.duration,
  }, false, 2));
  log('-----------')
}

```

it returns the following:

```auto
Roep service [[service]] aan voor entiteit [[entity]] met data [[data]]
{
  "uri": "homey:flowcardaction:homey:app:io.home-assistant.community:callServiceEntity",
  "id": "homey:app:io.home-assistant.community:callServiceEntity",
  "args": [
    {
      "type": "autocomplete",
      "name": "service",
      "title": "Service",
      "placeholder": "Selecteer de dienst"
    },
    {
      "type": "autocomplete",
      "name": "entity",
      "required": false,
      "title": "Entiteit",
      "placeholder": "selecteer de entiteit"
    },
    {
      "type": "text",
      "name": "data",
      "required": false,
      "title": "Gegevens",
      "placeholder": "{\"parameter\": \"waarde\"}"
    }
  ],
  "droptoken": null,
  "duration": false
}

```

So I ran:

```auto
const MediaPlayer = "media_player.woonkamer"

action ={
    "uri": "homey:flowcardaction:homey:app:io.home-assistant.community:callServiceEntity",
    "id": "homey:app:io.home-assistant.community:callServiceEntity",
    "args": [
        {"service":"chime_tts.say"},
        {"entity":MediaPlayer},
        {"data":"{\"volume_level\": 0.56,\"fade_audio\": true,\"message\": \"Dit is een testje vanuit Homey\"}"}
    ]
}

test = await Homey.flow.runFlowCardAction(action)
console.log(test)

```

This returns the following:

```auto
{
  returnTokens: null,
  usedTokens: {},
  error: { message: "Cannot read properties of undefined (reading 'id')" },
  elapsedTime: 4.5726789981126785
}

```

---

<div class="post-metadata">

**Author:** ![Arnt\_Soloy](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arnt_soloy/32/58318_2.png) [@Arnt\_Soloy](https://community.homey.app/u/Arnt_Soloy)\
**Post date:** [June 12, 2025, 8:45pm UTC](https://community.homey.app/t/homeyscript-runflowcardaction-for-home-assitant/138051/4 "2025-06-12T20:45:00Z")

</div>

I have been playing around with Homeyscript lately, but have done things different than you,  
so having a bit hard time following the code.

Dont have HA so no chance testing myself, but regarding the Homey web api and the runFlowcardsAction the id and uri should be something like this:

```auto
const MEDIA_PLAYER = 'media_player.woonkamer';

(async () => {
  try {
    const result = await Homey.flow.runFlowCardAction({
      uri: 'homey:app:io.home-assistant.community',
      id: 'callServiceEntity',
      args: {
        service : 'chime_tts.say',
        entity : MEDIA_PLAYER,
        data : JSON.stringify({
          volume_level : 0.56,
          fade_audio : true,
          message : 'Dit is een testje vanuit Homey'
        })
      }
    });
    console.log('Service call OK ->', result);
  } catch (err) {
    console.error('Service call FAILED ->', err.message);
  }
})();

```

Play around with this, if still error, it is off my knowledge

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [June 12, 2025, 10:58pm UTC](https://community.homey.app/t/homeyscript-runflowcardaction-for-home-assitant/138051/5 "2025-06-12T22:58:51Z")

</div>

> [@Kurt1](#):
>
> When I run
> 
> ```auto
> log('===========');
> log('Then-cards:');
> log('===========');
> const actionCards = await ......
> 
> ```

Unfortunately this only works in ‘classic’ homeyscript.  
Things have changed since HS uses homey-api instead of athom-api for new scripts [(source)](https://community.homey.app/t/homeyscript-looking-for-testers/109249)

`uri` and `id `are now combined as `id`:

 ![Screenshot_20250613_003201_Chrome](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/c/bc3ed650230eac236230c6577705596457b5e32c.jpeg)  
([source of screenshot](https://athombv.github.io/com.athom.homeyscript/tutorial-migrate))

Second, I always first create the service (called ‘action’ nowadays) in the ‘Actions’ tab of HA Developer tools, to make sure it works:

 ![Screenshot_20250612_221659_Chrome](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/6/862082a537d07c948a7fc83c4c3dd5f4bfdae6ce.jpeg)

Next, I check if this works with a real flow card:

 ![Screenshot_20250612_222734_Firefox](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/d/bd4696fdaf0c5bea4d1d0850a5e961b4b3be6279.jpeg)

So far, so good.  
However, I can’t get the script to run successfully

This one errrors:

```auto
const test = await Homey.flow.runFlowCardAction({
    id: 'homey:app:io.home-assistant.community:callServiceEntity',
    args: {
      service: 'tts.google_translate_say',
      entity: 'media_player.yamaha_kamer',
      data: {
        'message':'hallo dit is homey',
        'language':'nl'
        }
    },
});

console.log(test);

```

Error:

```auto
{
  returnTokens: null,
  usedTokens: {},
  error: { message: 'Unexpected token o in JSON at position 1' },
 }

```

The issue seems to be the data part. The [JSON should be converted to a string](https://stackoverflow.com/questions/38380462/syntaxerror-unexpected-token-o-in-json-at-position-1#38380728)

So I tried `toString`, and the `JSON.stringify` Arnt used, but it’s not working yet;  
This one errors as well:

```auto
const test = await Homey.flow.runFlowCardAction({
    id: 'homey:app:io.home-assistant.community:callServiceEntity',
    args: {
      service: 'tts.google_translate_say',
      entity: 'media_player.yamaha_kamer',
      data: JSON.stringify({
        'message': 'hallo dit is homey',
        'language': 'nl'})
    },
});

console.log(test);

```

Error:

```auto
{
  returnTokens: null,
  usedTokens: {},
  error: { message: "Cannot read properties of undefined (reading 'split')" },
}

```

I’m no coder or expert in this, I think I’m close but no cigar apparently 🤣.  
I’m out of ideas here.

This works fine however:

```auto
const test = Homey.flow.runFlowCardAction({
  id: 'homey:manager:mobile:push_text',
    args: {
        user: {
        id: 'xxxxxxxx-xxxx-xxxx-xxxxx-xxxxxxxx',
	    athomId: 'xxxxxxxxxxxxxxx',
	    },
	    text: 'Test push notification from HomeyScript'
        },
     });
console.log(test);

```

 ![Screenshot_20250613_011920_One UI Home](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/3/a/3a728aa9871b7e62e999a9cf385512e07a60d0d6.jpeg)
