# Pressing PATCH REQUEST button generates three messages

**URL:** <https://forum.electra.one/t/pressing-patch-request-button-generates-three-messages/1488>\
**Category:** Bug reports\
**Created:** [May 15, 2022, 7:49pm UTC](https://forum.electra.one/t/pressing-patch-request-button-generates-three-messages/1488 "2022-05-15T19:49:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.electra.one/jhh/32/951_2.png) [@jhh](https://forum.electra.one/u/jhh)\
**Post date:** [May 15, 2022, 7:49pm UTC](https://forum.electra.one/t/pressing-patch-request-button-generates-three-messages/1488/1 "2022-05-15T19:49:39Z")

</div>

When defining patch.onRequest() to send a MIDI message when the PATCH REQUEST button is pressed, this message is sent three times in succesion. See attached screenshot.

With:

```auto
function patch.onRequest (device) 
  print ("Patch Request pressed"); 
  midi.sendSysex(PORT_1, {0x00, 0x21, 0x45, 0x7E, 0x02, 5, 10}) 
end

```

 ![Screenshot 2022-05-15 at 21.48.13](https://europe1.discourse-cdn.com/flex017/uploads/electraone/original/2X/a/a90d743901cc8cd150c81a68663f6007b4c32e38.png)

---

<div class="post-metadata">

**Author:** ![martin](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.electra.one/martin/32/145_2.png) [@martin](https://forum.electra.one/u/martin)\
**Post date:** [May 16, 2022, 3:53pm UTC](https://forum.electra.one/t/pressing-patch-request-button-generates-three-messages/1488/2 "2022-05-16T15:53:16Z")

</div>

ok, I was able to replicate that.

I assume your preset has three devices used. That means that the function will be called three times, each time having different device reference passed as a parameter. It is actually correct behaviour. You can either use the device parameter to identify the request. Or, if you just want to sent a fixed SysEx message (like in your example), you can define that message on the Device :: Edit Patch :: Request:

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/electraone/original/2X/3/3c76cbe2fd4c0b4891babc9ebc048f529b633986.jpeg)

or JSON:

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/electraone/original/2X/1/1800627a26b41d38930527bf633202ad07a5718b.jpeg)

---

<div class="post-metadata">

**Author:** ![jhh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.electra.one/jhh/32/951_2.png) [@jhh](https://forum.electra.one/u/jhh)\
**Post date:** [May 16, 2022, 4:47pm UTC](https://forum.electra.one/t/pressing-patch-request-button-generates-three-messages/1488/3 "2022-05-16T16:47:22Z")

</div>

A yes, the mixer preset uses three different MIDI channels and hence three different devices. That explains it and also explains that this is indeed intended behaviour. I already fixed it another way, but your suggestion is cleaner. Thanks.
