I just posted a new version of the code that also provides a server so that you can check the current status while it is running remotely:
$ telnet 192.168.2.8 Trying 192.168.2.8... Connected to 192.168.2.8. Escape character is '^]'. mqtt_connected = 1 distance_cm = 102 door_open = 1 Connection closed by foreign host.