# Create function with multiple outputs send in a sequence

**URL:** <https://discourse.nodered.org/t/create-function-with-multiple-outputs-send-in-a-sequence/22587>\
**Category:** General\
**Created:** [3 March 2020 21:23 UTC](https://discourse.nodered.org/t/create-function-with-multiple-outputs-send-in-a-sequence/22587 "2020-03-03T21:23:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gschmidt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gschmidt/32/60349_2.png) [@gschmidt](https://discourse.nodered.org/u/gschmidt)\
**Post date:** [3 March 2020 21:23 UTC](https://discourse.nodered.org/t/create-function-with-multiple-outputs-send-in-a-sequence/22587/1 "2020-03-03T21:23:30Z")

</div>

Hi,

I am creating an Alarm Clock using the castv2 node.

A function node (advised by castv2 maker) is used to send a message in a special format to the Google Home device(s).  
Each message contains a command to control a cast [MEDIA, TTS, STOP, PLAY, VOLUME, CLOSE etc.]

Now for the Alarm Clock I have to send the following commands VOLUME, MEDIA:

- Set volume to 50  
(wait a few seconds to finish the VOLUME command)
- Cast a Media file (internet radio stream)

In my current flow this are 2 function nodes which have to be send in the listed order and with a certain delay, because the commands overrule eachother on the casting device(s). Now I use a QUEUE node for sequencing the commands to the castv2 Node.

Since I use domoticz as software I use a Switch to trigger the Alarm Clock.  
Switches in domoticz have timer options (which I use to set the Alarm at certain times)  
Also here a function node is used to filter the IDX of the domoticz switch:  
When IDX=243 && nvalue=1 (switch on), the 2 function nodes (castv2 commands) are activated.

This are 3 function nodes. Is there a more efficient way to combine the functions and queue node?  
Because I also want to STOP and CLOSE the MEDIA (again 3 sepparate commands) when the Domoticz switch is set to off (nvalue=0)

 ![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/0/9048731ebfad3a6d58e1d19417ad313916961636.png)

```auto
[{"id":"6790ef2e.5739e","type":"function","z":"cf6cdf2b.f9a03","name":"If IDX is Radio Wekker Switch ","func":"if (msg.payload.idx == '243' && msg.payload.nvalue == '1') {\n return msg;\n}\n","outputs":1,"noerr":0,"x":420,"y":200,"wires":[["37d57466.242c2c","a9e556fb.bda478"]]}]

```

---

<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:** [2 May 2020 21:23 UTC](https://discourse.nodered.org/t/create-function-with-multiple-outputs-send-in-a-sequence/22587/2 "2020-05-02T21:23:31Z")

</div>

Closed on 2 May 2020 21:23 UTC

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