def station_id(mqtt_topic: str) -> str:
    """
    Returns the id of the weather station based on mqtt topic.
    The id is for the database location tag.

    Parameters:
        mqtt_topic (str): weather station mqtt topic

    Returns:
        weather station id
    """

    # Topic is a string like "ws/esp0", the number after "esp" is the id
    if mqtt_topic[-1].isdigit():
        # If number == 0 (zero) is a test weather station
        if mqtt_topic[6:] == '0':
            id = 'ws_test'
        else:
            # ws/espX when X > 1, stations in production
            id = 'ws0' + mqtt_topic[6:]
    else:
        id = 'ws_not_identified'

    return id