# Path: mysensors/const.py
# SYSTEM_CHILD_ID = 255
# 
# def get_const(protocol_version):
#     """Return the const module for the protocol_version."""
#     path = next(
#         (
#             CONST_VERSIONS[const_version]
#             for const_version in sorted(CONST_VERSIONS, reverse=True)
#             if parse_ver(protocol_version) >= parse_ver(const_version)
#         ),
#         "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


import logging
import voluptuous as vol
from .const import SYSTEM_CHILD_ID, get_const
            raise

    def encode(self, delimiter=";"):
        """Encode a command string from message."""
        try:
            return (
                delimiter.join(
                    [
                        str(f)
                        for f in [
                            int(self.node_id),
                            int(self.child_id),
                            int(self.type),
                            int(self.ack),
                            int(self.sub_type),
                            self.payload,
                        ]
                    ]
                )
                + "\n"
            )
        except ValueError:
            _LOGGER.error("Error encoding message to gateway")
            return None

    def validate(self, protocol_version):
        """Validate message."""
        if self.gateway is not None:
            _LOGGER.warning("Can not validate message if Message.gateway is set")
            return None

# Path: mysensors/const.py
# SYSTEM_CHILD_ID = 255
# 
# def get_const(protocol_version):
#     """Return the const module for the protocol_version."""
#     path = next(
#         (
#             CONST_VERSIONS[const_version]
#             for const_version in sorted(CONST_VERSIONS, reverse=True)
#             if parse_ver(protocol_version) >= parse_ver(const_version)
#         ),
#         "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


# Path: mysensors/message.py
import logging
import voluptuous as vol
from .const import SYSTEM_CHILD_ID, get_const

            raise

    def encode(self, delimiter=";"):
        """Encode a command string from message."""
        try:
            return (
                delimiter.join(
                    [
                        str(f)
                        for f in [
                            int(self.node_id),
                            int(self.child_id),
                            int(self.type),
                            int(self.ack),
                            int(self.sub_type),
                            self.payload,
                        ]
                    ]
                )
                + "\n"
            )
        except ValueError:
            _LOGGER.error("Error encoding message to gateway")
            return None

    def validate(self, protocol_version):
        """Validate message."""
        if self.gateway is not None:
            _LOGGER.warning("Can not validate message if Message.gateway is set")
            return None

        const = get_const(protocol_version)