Sending json to esp by clicking on a button

Hello,
I’m trying to control entire home automation using painlessmesh, i have tried to implement similar thing with Blynk (not much of a success)
The idea is to use one esp32 to connect to the gateway and another esp32 to recieve instructions via UART from the first one and send the data in the esp channel
Is there a way to configure buttons to send json data that specifies the board in the mesh network and the values to be sent to that

Like if i can send
{
“Board” = “1”
“Pin” = " 12"
"Value=“1”
}
And recieve updates similary to update the gateway then it would help a lot …

I send my X10 CM15 controller commands from the GW using the “RUN PROGRAM” addon. This addon executes a program. In my case, it executes something like this to communicate to the mochad process which controls the X10 CM15.

/bin/echo “A10 RF ON” | /bin/nc -w 3 127.0.0.1 1099

A kludge, but it works. In this simple implementation, I must define a sepeate device for ON and OFF actions since the program is hard-coded.

I also wrote a shell tool that uses a persistent nohup’ed nc process to monitor the output of the CM15 by mochad. It then sends commands to the GW using curl to turn off/on ZWave devices. Got a bunch of old X10 buttons put to good re-use. Another kludge that seems to work well although it requires hard-coded X10 to ZWave ID mapping.

Can provide more info should this be an option…

Please can you post the code … Thank you

The buttons appear to be preconfigured when you set up a device itself … So when writing the config file on how device works, … Is there a way to make the gateway understand that it only accepts custom json doc coded buttons ?