This 2 scripts can be used for communicating through MQTT protocol, asynchronized.
In my case, my apartment door button wasn't working properly so I connected a raspberry with this script as listener. Then I use this method to open my apartment door by publishing to the same channel.