# How do I create an object to pass to alexa.remote2

**URL:** https://discourse.nodered.org/t/how-do-i-create-an-object-to-pass-to-alexa-remote2/31757
**Category:** General
**Created:** [20 August 2020 06:40 UTC](https://discourse.nodered.org/t/how-do-i-create-an-object-to-pass-to-alexa-remote2/31757 "2020-08-20T06:40:24Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![v8dave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/v8dave/32/4420_2.png) [@v8dave](https://discourse.nodered.org/u/v8dave)
#### Post date: [20 August 2020 06:40 UTC](https://discourse.nodered.org/t/how-do-i-create-an-object-to-pass-to-alexa-remote2/31757/1 "2020-08-20T06:40:24Z")

</div>

I am trying to control a device and create a generic function that can take a topic with the device name and a payload with ON or OFF but I can't seem to figure out the code for this. I am trying to pass this to an alex.remote2 custom routine node set to custom and msg.payload as the data input.

I have the following in the function:

```auto
var state = msg.payload.toUpperCase();
var device = msg.topic;
msg = {};

if(state==="ON")
{
    msg.payload={type: "smarthome", payload: {entity: [device], action: "turnOn"}};
    node.status({fill:"green",shape:"ring",text:"ON"});
}
else
{
    msg.payload={type: "smarthome", payload: {entity: [device], action: "turnOff"}};
    node.status({fill:"red",shape:"ring",text:"OFF"});
}
return msg;

```

I get the following in the debug output:

`invalid sequence node: "{"type":"smarthome","payload":{"entity":["Front room fan"],"action":"turnOff"}}" expected layout: "{"entity":"","action":""}"`

This is what I output from the function:

`{"payload":{"type":"smarthome","payload":{"entity":["Front room fan"],"action":"turnOn"}},"_msgid":"c028a4cd.8e16d8"}`

Any ideas where I am going wrong?

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [20 August 2020 06:54 UTC](https://discourse.nodered.org/t/how-do-i-create-an-object-to-pass-to-alexa-remote2/31757/2 "2020-08-20T06:54:24Z")

</div>

You are sending `["Front room fan"]` should this be `"Front room fan"` ?

---

<div class="post-metadata">

### Author: ![v8dave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/v8dave/32/4420_2.png) [@v8dave](https://discourse.nodered.org/u/v8dave)
#### Post date: [20 August 2020 07:08 UTC](https://discourse.nodered.org/t/how-do-i-create-an-object-to-pass-to-alexa-remote2/31757/3 "2020-08-20T07:08:09Z")

</div>

That was it. I had surrounded the variable name with but it was not needed. The node now recognises the commands. Thanks for pointing it out.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [3 September 2020 07:08 UTC](https://discourse.nodered.org/t/how-do-i-create-an-object-to-pass-to-alexa-remote2/31757/4 "2020-09-03T07:08:11Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
