Using flowcard with fixed list in Homey script

Want to use the AndroidTV Press Key card in HomeyScript, but can’t find the exact Syntac for the press_key card.

const AndroidTV = "homey:device:fee85441-654a-461d-8a36-bf544b8e350d:";
//await Homey.flow.runFlowCardAction({"id": AndroidTV + "pause"});
await Homey.flow.runFlowCardAction({"id": AndroidTV + "press_key",
"args": {"option" : "key_pause"}});

The second line (if I remove //) works fine. But the third line doesn’t. I want to select TV channels using HomeyScript, but can’t figure out what I need to fill in. Tried select channel 2 the number 2 or key_digit_2, but nothing works (no error as well).

It’s maybe caused by the fact that it’s a fixed list of items:

Does anyone know the answer to this riddle?

Are you sure this is the name of the arg?

Because if I would have created the flowcard, I would have called that argument key I suppose :thinking:

Yes Arie, I’m quite sure (but thanks for the hint). Used other flow cards in Homey Script, and they all use the ‘name’ arch name.

Press key [[option]]
{
  "id": "homey:device:fee85441-654a-461d-8a36-bf544b8e350d:press_key",
  "args": [
    {
      "name": "option",
      "type": "autocomplete",
      "title": "Key",
      "placeholder": null
    }
  ],
  "droptoken": null,
  "duration": false
}

And of course in my desperate search I’ve tested Key as well.

I’ve sent an email to the developer of this app, hoping to get the right hint to make it work.

This wil work for what you want to do:

await Homey.flow.runFlowCardAction({
  id: 'homey:device:fee85441-654a-461d-8a36-bf544b8e350d:press_key',
  args: {
    option: {
      key: 'key_confirm'
    }
  }  
});

Technically the card also has an id tag, and a name tag, but both seem optional and the id is always the same as key.

Available key IDs:

'key_stop'
'key_play'
'key_pause'
'key_rewind'
'key_fast_forward'
'key_watch_tv'
'key_confirm'
'key_previous'
'key_next'
'key_cursor_left'
'key_cursor_up'
'key_cursor_right'
'key_cursor_down'
'key_channel_up'
'key_channel_down'
'key_digit_1'
'key_digit_2'
'key_digit_3'
'key_digit_4'
'key_digit_5'
'key_digit_6'
'key_digit_7'
'key_digit_8'
'key_digit_9'
'key_digit_0'
'key_options'
'key_back'
'key_home'

Thanks Caseda! It works! Had found the key commands in Homey Developer, but just added a few qotes to much. And the word key itself :flushed_face:

Channel switching is verrrry fast (hardly visible)

//Gettting a 3 digit channel code and send this to the Android TV
const AndroidTV = "homey:device:fee85441-654a-461d-8a36-bf544b8e350d:"
let text = (args[0]);
var length = text.length;
if (length == 3) {
var num1 = text.substring(0,1);
var num2 = text.substring(1,2);
var num3 = text.substring(2,3);
await Homey.flow.runFlowCardAction({"id": AndroidTV + "press_key",
args:{option : {key:"key_digit_" + num1}}}); await wait(5);
await Homey.flow.runFlowCardAction({"id": AndroidTV + "press_key",
args:{option : {key:"key_digit_" + num2}}}); await wait(5);
await Homey.flow.runFlowCardAction({"id": AndroidTV + "press_key",
args:{option : {key:"key_digit_" + num3}}}); await wait(5);
await Homey.flow.runFlowCardAction({"id": AndroidTV + "press_key",
args:{option : {key:"key_confirm"}}});
}