def parse_topic(topic, pretty=False):
 parts = topic.split('/')
 dev_id_format = ''
 if pretty:
  dev_id_format = '{} {}'
 else:
  dev_id_format = '{}_{}'
 dev_id = slugify(dev_id_format.format(parts[1], parts[2]))
 host_name = parts[1]
 return (host_name, dev_id)

def parse_topic ( topic , pretty = False ) : parts = topic . split ( '/' ) dev_id_format = '' if pretty : dev_id_format = '{} {}' else : dev_id_format = '{}_{}' dev_id = slugify ( dev_id_format . format ( parts [ 1 ] , parts [ 2 ] ) ) host_name = parts [ 1 ] return ( host_name , dev_id )
parse an mqtt topic owntracks/user/dev .