# String formatting in a function

**URL:** <https://discourse.nodered.org/t/string-formatting-in-a-function/65170>\
**Category:** General\
**Created:** [15 July 2022 21:36 UTC](https://discourse.nodered.org/t/string-formatting-in-a-function/65170 "2022-07-15T21:36:03Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [15 July 2022 21:36 UTC](https://discourse.nodered.org/t/string-formatting-in-a-function/65170/1 "2022-07-15T21:36:03Z")

</div>

I am trying to log everything that Alexa hears using the "On Device Activity" node.

I am pretty sure that everything is a string. This is how I am saving name, for example:

```auto
var a={payload:msg.payload.name};
flow.set("name",a);
return [a];

```

In the failing function I am trying to build a single line: "timestamp, name, command"

```auto
var devicetime = flow.get('timestamp');
var devicename = flow.get('name');
var devicecommand = flow.get('command');

var str = devicetime + ',' + devicename + ',' + devicecommand;
msg.payload = str;
return msg;

```

But this is what I get: "Friday, July 15th 2022, 5:10:26 pm",[object Object],[object Object]

So, what did I do wrong?  
Thanks

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [15 July 2022 21:40 UTC](https://discourse.nodered.org/t/string-formatting-in-a-function/65170/2 "2022-07-15T21:40:11Z")

</div>

What does the Alexa output look like?, can you provide the output you get from the node? (using the debug node)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [15 July 2022 21:43 UTC](https://discourse.nodered.org/t/string-formatting-in-a-function/65170/3 "2022-07-15T21:43:24Z")

</div>

> [@SteveMann](#):
>
> `var a={payload:msg.payload.name};`

Var `a` is an object, so flow name is an object  
`flow.set("name",a.payload)`

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [15 July 2022 21:46 UTC](https://discourse.nodered.org/t/string-formatting-in-a-function/65170/4 "2022-07-15T21:46:43Z")

</div>

> [@SteveMann](#):
>
> I am trying to log everything that Alexa hears using the "On Device Activity" node.

@SteveMann What is the actual name of that node (node-red-contrib-?????). Your idea looks interesting.

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [15 July 2022 21:50 UTC](https://discourse.nodered.org/t/string-formatting-in-a-function/65170/5 "2022-07-15T21:50:51Z")

</div>

As per @E1cid comment, the name is an object, but..

`Friday, July 15th 2022, 5:10:26 pm",[object Object],[object Object]`

doesn't explain the `command` property.  
it will help if you could paste here, what the output is, before you process it.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [15 July 2022 21:52 UTC](https://discourse.nodered.org/t/string-formatting-in-a-function/65170/6 "2022-07-15T21:52:53Z")

</div>

It's [node-res-contrib-alexaremote2-appelstrudel](https://flows.nodered.org/node/node-red-contrib-alexa-remote2-applestrudel) i believe.

@marcus-j-davies , the OP is probably setting the command context the same way.

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [15 July 2022 21:59 UTC](https://discourse.nodered.org/t/string-formatting-in-a-function/65170/7 "2022-07-15T21:59:23Z")

</div>

@E1cid That's what I'm betting also.

@SteveMann  
Not knowing your flow, something like below should achieve your goal.

```auto
flow.set("timestamp",msg.payload.timestamp);
flow.set("name",msg.payload.name);
flow.set("command",msg.payload.command);

return msg

```

later....

```auto
const devicetime = flow.get('timestamp');
const devicename = flow.get('name');
const devicecommand = flow.get('command');

const str = `${devicetime},${devicename},${devicecommand}`;
msg.payload = str;
return msg;

```

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [15 July 2022 23:25 UTC](https://discourse.nodered.org/t/string-formatting-in-a-function/65170/8 "2022-07-15T23:25:48Z")

</div>

All terrific input and much appreciated.  
It was a doh' moment when @e1cid pointed out that I was saving objects. But I am still having a problem with extracting the command.

@zenofmud - The node is "Alexa Event" from "node-red-contrib-alexa-remote2", V3.10.4

The flow:

```auto
[{"id":"3bcee00cd20bb90b","type":"function","z":"cc2b243f.efbf58","name":"Build the log file line","func":"const devicetime = flow.get('timestamp');\nconst devicename = flow.get('name');\nconst devicecommand = flow.get('command');\n\nconst str = `${devicetime},${devicename},${devicecommand}`;\nmsg.payload = str;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":740,"wires":[["4eefd537527fd7b6"]]},{"id":"1dcdac75e08018e9","type":"alexa-remote-event","z":"cc2b243f.efbf58","name":"","account":"4627f780.84a6a8","event":"ws-device-activity","x":150,"y":600,"wires":[["f211df871972ea36","b75fa357259ba43c","ac8ec3cc9bf0e97e","97e94defad52ded1"]]},{"id":"f211df871972ea36","type":"function","z":"cc2b243f.efbf58","name":"Get name","func":"flow.set(\"name\",msg.payload.name);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":600,"wires":[["102b0745cea8db28"]]},{"id":"b75fa357259ba43c","type":"function","z":"cc2b243f.efbf58","name":"Get Command","func":"var a={payload:msg.payload.description.summary};\nflow.set(\"command\",a);\nreturn [a];","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":640,"wires":[["c8426b41292c2a67"]]},{"id":"c8426b41292c2a67","type":"ui_text","z":"cc2b243f.efbf58","group":"30106f26816982fe","order":2,"width":0,"height":0,"name":"Command","label":"Command","format":"{{msg.payload}}","layout":"row-spread","className":"","x":790,"y":640,"wires":[]},{"id":"102b0745cea8db28","type":"ui_text","z":"cc2b243f.efbf58","group":"30106f26816982fe","order":1,"width":0,"height":0,"name":"","label":"Originating Device","format":"{{msg.payload}}","layout":"row-spread","className":"","x":810,"y":600,"wires":[]},{"id":"ac8ec3cc9bf0e97e","type":"function","z":"cc2b243f.efbf58","name":"Get Timestamp","func":"var a={payload:msg.payload.creationTimestamp.mydate};\nreturn [a];","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":200,"y":680,"wires":[["bedfa4ed716e3f76"]]},{"id":"d71e4d59e2e1b75e","type":"ui_text","z":"cc2b243f.efbf58","group":"30106f26816982fe","order":3,"width":0,"height":0,"name":"Timestamp","label":"Tmestamp","format":"{{msg.payload}}","layout":"row-spread","className":"","x":810,"y":680,"wires":[]},{"id":"bedfa4ed716e3f76","type":"moment","z":"cc2b243f.efbf58","name":"","topic":"","input":"","inputType":"msg","inTz":"America/New_York","adjAmount":0,"adjType":"days","adjDir":"add","format":"\"dddd, MMMM Do YYYY, h:mm:ss a\"","locale":"C","output":"","outputType":"msg","outTz":"America/New_York","x":400,"y":680,"wires":[["f6dc1de10ed24cc1"]]},{"id":"4eefd537527fd7b6","type":"file","z":"cc2b243f.efbf58","name":"","filename":"/share/logs/alexa.log","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":740,"y":740,"wires":[[]]},{"id":"f6dc1de10ed24cc1","type":"function","z":"cc2b243f.efbf58","name":"Save timestamp","func":"flow.set(\"timestamp\",msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":680,"wires":[["d71e4d59e2e1b75e"]]},{"id":"97e94defad52ded1","type":"delay","z":"cc2b243f.efbf58","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":290,"y":740,"wires":[["3bcee00cd20bb90b"]],"info":"Allows all data to be flow.saved."},{"id":"4627f780.84a6a8","type":"alexa-remote-account","name":"","authMethod":"proxy","proxyOwnIp":"192.168.1.57","proxyPort":"3456","cookieFile":"alexa.txt","refreshInterval":"1","alexaServiceHost":"pitangui.amazon.com","amazonPage":"amazon.com","acceptLanguage":"en-US","userAgent":"","useWsMqtt":"on","autoInit":"off"},{"id":"30106f26816982fe","type":"ui_group","name":"Last Command Summary","tab":"cc8daca91241397e","order":2,"disp":true,"width":"6","collapse":false,"className":""},{"id":"cc8daca91241397e","type":"ui_tab","name":"Alexa","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

However, I am still having a problem extracting the command. In my flow the output of the Get Command function node is the command: "turn on the office light", for example. But in my log file it is: "Friday, July 15th 2022, 7:20:57 pm",Stephen,[object Object]

Here is the output from the Alexa Event node when I say "Alexa turn off the office light"

```auto
{"payload":{"data":{"_disambiguationId":null,"activityStatus":"SUCCESS","creationTimestamp":1657927436872,"description":"{\"summary\":\"alexa turn off office light\",\"firstUtteranceId\":\"A4ZP7ZC4PI6TO:1.0/2022/07/15/23/DEVICE_UNSPECIFIED/23:55::TNIH_2V.35e9ccc3-a187-48f0-906b-b44fbe308a6eZXV/0\",\"firstStreamId\":\"A4ZP7ZC4PI6TO:1.0/2022/07/15/23/DEVICE_UNSPECIFIED/23:55::TNIH_2V.35e9ccc3-a187-48f0-906b-b44fbe308a6eZXV\"}","domainAttributes":null,"domainType":null,"feedbackAttributes":null,"id":"A3FOLKQ9ENDI49#1657927436872#A4ZP7ZC4PI6TO#G0911B0592850CN1","intentType":null,"providerInfoDescription":null,"registeredCustomerId":"A3FOLKQ9ENDI49","sourceActiveUsers":null,"sourceDeviceIds":[{"deviceAccountId":null,"deviceType":"A4ZP7ZC4PI6TO","serialNumber":"G0911B0592850CN1"}],"utteranceId":"A4ZP7ZC4PI6TO:1.0/2022/07/15/23/DEVICE_UNSPECIFIED/23:55::TNIH_2V.35e9ccc3-a187-48f0-906b-b44fbe308a6eZXV","version":1},"description":{"summary":"alexa turn off office light","firstUtteranceId":"A4ZP7ZC4PI6TO:1.0/2022/07/15/23/DEVICE_UNSPECIFIED/23:55::TNIH_2V.35e9ccc3-a187-48f0-906b-b44fbe308a6eZXV/0","firstStreamId":"A4ZP7ZC4PI6TO:1.0/2022/07/15/23/DEVICE_UNSPECIFIED/23:55::TNIH_2V.35e9ccc3-a187-48f0-906b-b44fbe308a6eZXV"},"deviceSerialNumber":"G0911B0592850CN1","name":"Stephen","deviceType":"A4ZP7ZC4PI6TO","deviceAccountId":null,"creationTimestamp":1657927436872,"activityStatus":"SUCCESS","domainAttributes":null,"destinationUserId":"A3FOLKQ9ENDI49"},"_msgid":"049d1cff8aa6a4ab"}

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [16 July 2022 01:58 UTC](https://discourse.nodered.org/t/string-formatting-in-a-function/65170/9 "2022-07-16T01:58:39Z")

</div>

Ok, lets take each section on it's own.  
**Originating Device leg**  
In the 'Get name' `function` node you have:

```auto
flow.set("name",msg.payload.name);
return msg;

```

so that stores msg.payload.name in a flow variable  
(why is it called 'Get name'? Wouldn't 'Store name' be better?)  
then the `ui-text` node displays 'msg.payload' which is a big blob of data. One of the items in the payload (`payload.data.sourceDeviceIds[0].serialNumber`) is the serial number. I would build a object of all your device serial numbers and and the room or what you call the device like this:

```auto
{ "G0911B0592850CN1": "bedroom",
  "G0911B0592850CN1": "den",
  "G0911B0592850CN1": "pool"
}

```

Then in the function node use the serial number to lookup in the object to get the location and move that to msg.payload so the `ui-text` node can display just that.

**Command leg**  
It looks like you just want to display the command summary which (in the sample data) is `payload.description.summary` and that is working fine.

**Timestame leg**  
In the 'Get Timestamp' `function` you have:

```auto
var a={payload:msg.payload.creationTimestamp.mydate};
return [a];

```

You have specify the path as `payload.creationTimestamp.mydate` and the result is that the out going payload is _undefined_. The actual path is `payload.creationTimestamp` as part of the path but it should not be there. You need to corect that path (you could have used a `change` node for this.

You have an error in `Date/Time Format` node. The `Output Format` should not have the double quotes!

Also, many of your `function` nodes could be replaced with `change` nodes. For example, the 'Get Command' function node:  
 ![Screen Shot 2022-07-15 at 9.55.36 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/4/d40d272d8fdb4c169f7475edb949af8674d7d282.png)  
could be a `change` node like this  
 ![Screen Shot 2022-07-15 at 9.56.19 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/4/a4f9d11c1f6d7bcdb602fb9c05793130b5d28bed.png)

I hope this helps you out.

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [16 July 2022 03:19 UTC](https://discourse.nodered.org/t/string-formatting-in-a-function/65170/10 "2022-07-16T03:19:52Z")

</div>

> [@zenofmud](#):
>
> I hope this helps you out.

Actually, it did. Everything is working now. Thanks again.

BTW, not a big deal, but can I format the log string with tabs instead of commas? (The double quotes surround the timestamp because I can import the log file into Excel as a CSV file).

`const str = `${devicetime},${devicename},${devicecommand}`;`

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [16 July 2022 07:04 UTC](https://discourse.nodered.org/t/string-formatting-in-a-function/65170/11 "2022-07-16T07:04:40Z")

</div>

Why are you using context? as the values are in the msg flowing through your flow. Also i would probably use the template node here to. Also the ui-dashboard nodes can accept a different property other than payload.  
Maybe some thing like this, hope it helps.

```auto
[{"id":"b7d14e2a.7bccc8","type":"inject","z":"30af2d3e.d94ea2","name":"test","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":60,"wires":[["73c9435a.bb2bec"]]},{"id":"73c9435a.bb2bec","type":"function","z":"30af2d3e.d94ea2","name":"simulate payload","func":"msg= {\"payload\":{\"data\":{\"_disambiguationId\":null,\"activityStatus\":\"SUCCESS\",\"creationTimestamp\":1657927436872,\"description\":\"{\\\"summary\\\":\\\"alexa turn off office light\\\",\\\"firstUtteranceId\\\":\\\"A4ZP7ZC4PI6TO:1.0/2022/07/15/23/DEVICE_UNSPECIFIED/23:55::TNIH_2V.35e9ccc3-a187-48f0-906b-b44fbe308a6eZXV/0\\\",\\\"firstStreamId\\\":\\\"A4ZP7ZC4PI6TO:1.0/2022/07/15/23/DEVICE_UNSPECIFIED/23:55::TNIH_2V.35e9ccc3-a187-48f0-906b-b44fbe308a6eZXV\\\"}\",\"domainAttributes\":null,\"domainType\":null,\"feedbackAttributes\":null,\"id\":\"A3FOLKQ9ENDI49#1657927436872#A4ZP7ZC4PI6TO#G0911B0592850CN1\",\"intentType\":null,\"providerInfoDescription\":null,\"registeredCustomerId\":\"A3FOLKQ9ENDI49\",\"sourceActiveUsers\":null,\"sourceDeviceIds\":[{\"deviceAccountId\":null,\"deviceType\":\"A4ZP7ZC4PI6TO\",\"serialNumber\":\"G0911B0592850CN1\"}],\"utteranceId\":\"A4ZP7ZC4PI6TO:1.0/2022/07/15/23/DEVICE_UNSPECIFIED/23:55::TNIH_2V.35e9ccc3-a187-48f0-906b-b44fbe308a6eZXV\",\"version\":1},\"description\":{\"summary\":\"alexa turn off office light\",\"firstUtteranceId\":\"A4ZP7ZC4PI6TO:1.0/2022/07/15/23/DEVICE_UNSPECIFIED/23:55::TNIH_2V.35e9ccc3-a187-48f0-906b-b44fbe308a6eZXV/0\",\"firstStreamId\":\"A4ZP7ZC4PI6TO:1.0/2022/07/15/23/DEVICE_UNSPECIFIED/23:55::TNIH_2V.35e9ccc3-a187-48f0-906b-b44fbe308a6eZXV\"},\"deviceSerialNumber\":\"G0911B0592850CN1\",\"name\":\"Stephen\",\"deviceType\":\"A4ZP7ZC4PI6TO\",\"deviceAccountId\":null,\"creationTimestamp\":1657927436872,\"activityStatus\":\"SUCCESS\",\"domainAttributes\":null,\"destinationUserId\":\"A3FOLKQ9ENDI49\"},\"_msgid\":\"049d1cff8aa6a4ab\"}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":60,"wires":[["1717e631.c3fbca"]]},{"id":"1717e631.c3fbca","type":"change","z":"30af2d3e.d94ea2","name":"","rules":[{"t":"set","p":"payload.timestamp","pt":"msg","to":"$moment($$.payload.data.creationTimestamp).format(\"dddd, MMMM Do YYYY, h:mm:ss a\")","tot":"jsonata"},{"t":"set","p":"payload.device","pt":"msg","to":"($devices := {\t\"G0911B0592850CN1\": \"alexa_device_name1\",\t\"G0911B0592850BN2\": \"alexa_device_name2\",\t\"G0911B0592850GM3\": \"alexa_device_name3\"\t};\t$lookup($devices, $$.payload.deviceSerialNumber))","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":120,"wires":[["97e94defad52ded1","d71e4d59e2e1b75e","102b0745cea8db28","c8426b41292c2a67"]]},{"id":"1dcdac75e08018e9","type":"alexa-remote-event","z":"30af2d3e.d94ea2","name":"","account":"4627f780.84a6a8","event":"ws-device-activity","x":100,"y":120,"wires":[["1717e631.c3fbca"]]},{"id":"97e94defad52ded1","type":"delay","z":"30af2d3e.d94ea2","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":240,"y":260,"wires":[["a838a11a.f28058"]],"info":"Allows all data to be flow.saved."},{"id":"d71e4d59e2e1b75e","type":"ui_text","z":"30af2d3e.d94ea2","group":"30106f26816982fe","order":3,"width":0,"height":0,"name":"Timestamp","label":"Tmestamp","format":"{{msg.payload.timestamp}}","layout":"row-spread","className":"","x":760,"y":200,"wires":[]},{"id":"102b0745cea8db28","type":"ui_text","z":"30af2d3e.d94ea2","group":"30106f26816982fe","order":1,"width":0,"height":0,"name":"","label":"Originating Device","format":"{{msg.payload.device}}","layout":"row-spread","className":"","x":710,"y":120,"wires":[]},{"id":"c8426b41292c2a67","type":"ui_text","z":"30af2d3e.d94ea2","group":"30106f26816982fe","order":2,"width":0,"height":0,"name":"Command","label":"Command","format":"{{msg.payload.description.summary}}","layout":"row-spread","className":"","x":740,"y":160,"wires":[]},{"id":"a838a11a.f28058","type":"template","z":"30af2d3e.d94ea2","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.timestamp}} {{payload.name}} {{payload.device}} {{payload.description.summary}} {{payload.activityStatus}}","output":"str","x":450,"y":260,"wires":[["ca575484.486028","4eefd537527fd7b6"]]},{"id":"ca575484.486028","type":"debug","z":"30af2d3e.d94ea2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":300,"wires":[]},{"id":"4eefd537527fd7b6","type":"file","z":"30af2d3e.d94ea2","name":"","filename":"/share/logs/alexa.log","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":690,"y":260,"wires":[[]]},{"id":"4627f780.84a6a8","type":"alexa-remote-account","name":"","authMethod":"proxy","proxyOwnIp":"192.168.1.57","proxyPort":"3456","cookieFile":"alexa.txt","refreshInterval":"1","alexaServiceHost":"pitangui.amazon.com","amazonPage":"amazon.com","acceptLanguage":"en-US","userAgent":"","useWsMqtt":"on","autoInit":"off"},{"id":"30106f26816982fe","type":"ui_group","name":"Last Command Summary","tab":"cc8daca91241397e","order":2,"disp":true,"width":"6","collapse":false,"className":""},{"id":"cc8daca91241397e","type":"ui_tab","name":"Alexa","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

output

```auto
Saturday, July 16th 2022, 12:23:56 am Stephen alexa_device_name1 alexa turn off office light SUCCESS

```

[node-red-contrib-alexa-remote2](https://flows.nodered.org/node/node-red-contrib-alexa-remote2) is unmaintained you would do better changing to  
[node-red-contrib-alexa-remote2-applestrudel](https://flows.nodered.org/node/node-red-contrib-alexa-remote2-applestrudel) which is maintained and updated 12 hr ago. This node also output device friendly name so you would not need a lookup table.

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [16 July 2022 19:42 UTC](https://discourse.nodered.org/t/string-formatting-in-a-function/65170/12 "2022-07-16T19:42:49Z")

</div>

Thanks. I probably will upgrade to applestruedel. The main reason I haven't is that I have dozens of flows and use remote2 on most of them. It could take me a couple of hours to make the change.

---

<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:** [14 September 2022 19:42 UTC](https://discourse.nodered.org/t/string-formatting-in-a-function/65170/13 "2022-09-14T19:42:50Z")

</div>

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