def publish_public_ip_address(srv=None):
    """
    Custom function used as a periodic task for publishing your public ip address to the MQTT bus.
    Obtains service object.
    Returns None.
    """
    import socket
    import requests
    hostname = socket.gethostname()
    ip_address = requests.get('https://httpbin.org/ip').json().get('origin')
    if srv is not None:
        srv.logging.debug(
            'Publishing public ip address "{ip_address}" of host "{hostname}"'
            .format(**locals()))
        srv.mqttc.publish('test/ip/{hostname}'.format(**locals()), ip_address)
