I looked over the motion sketch linked and still not any clearer. Yes I see the basics of reading the pin but it is setup to publish to a gateway not directly to the broker as a client via my wifi. :(
Yes it will publish to the gateway. As per your sketch above you have configured the gateway to publish to mqtt. That's it. No more work to be done :)