"""Helpers for const."""
# pylint: disable=no-name-in-module, import-error
from distutils.version import LooseVersion as parse_ver
from importlib import import_module

LOADED_CONST = {}


def get_const(protocol_version):
    """Return the const module for the protocol_version."""
    version = protocol_version
    if parse_ver('1.5') <= parse_ver(version) < parse_ver('2.0'):
        path = 'mysensors.const_15'
    elif parse_ver(version) >= parse_ver('2.2'):
        path = 'mysensors.const_22'
    elif parse_ver(version) >= parse_ver('2.1'):
        path = 'mysensors.const_21'
    elif parse_ver(version) >= parse_ver('2.0'):
        path = 'mysensors.const_20'
    else:
        path = 'mysensors.const_14'
    if path in LOADED_CONST:
        return LOADED_CONST[path]
    const = import_module(path)
    LOADED_CONST[path] = const  # Cache the module
    return const

@@ -184,411 +184,419 @@
 %7B%7D%0A%0A
-%0Adef get_const(protocol_version):%0A    %22%22%22Return the const module for the protocol_version.%22%22%22%0A    version = protocol_version%0A    if parse_ver('1.5') %3C= parse_ver(version) %3C parse_ver('2.0'):%0A        path = 'mysensors.const_15'%0A    elif parse_ver(version) %3E= parse_ver('2.2'):%0A        path = 'mysensors.const_22'%0A    elif parse_ver(version) %3E= parse_ver('2.1'):%0A        path = 'mysensors.const_21'%0A    el
+CONST_VERSIONS = %7B%0A    '1.4': 'mysensors.const_14',%0A    '1.5': 'mysensors.const_15',%0A    '2.0': 'mysensors.const_20',%0A    '2.1': 'mysensors.const_21',%0A    '2.2': 'mysensors.const_22',%0A%7D%0A%0A%0Adef get_const(protocol_version):%0A    %22%22%22Return the const module for the protocol_version.%22%22%22%0A    path = next((%0A        CONST_VERSIONS%5Bconst_version%5D%0A        for const_version in sorted(CONST_VERSIONS, reverse=True)%0A        
 if p
@@ -604,16 +604,25 @@
 rse_ver(
+protocol_
 version)
@@ -639,76 +639,29 @@
 ver(
-'2.0'):%0A        path = 'mysensors.const_20'%0A    else:%0A        path =
+const_version)%0A    ),
  'my
@@ -677,16 +677,17 @@
 onst_14'
+)
 %0A    if 

Clean up get_const (#151)