# Path: insteonplm/constants.py
# MESSAGE_FLAG_EXTENDED_0X10 = 0x10
# 
# MESSAGE_TYPE_ALL_LINK_BROADCAST = 6
# 
# MESSAGE_TYPE_ALL_LINK_CLEANUP = 2
# 
# MESSAGE_TYPE_ALL_LINK_CLEANUP_ACK = 3
# 
# MESSAGE_TYPE_ALL_LINK_CLEANUP_NAK = 7
# 
# MESSAGE_TYPE_BROADCAST_MESSAGE = 4
# 
# MESSAGE_TYPE_DIRECT_MESSAGE_ACK = 1
# 
# MESSAGE_TYPE_DIRECT_MESSAGE_NAK = 5


import logging
import binascii
from insteonplm.constants import (
    MESSAGE_FLAG_EXTENDED_0X10,
    MESSAGE_TYPE_ALL_LINK_BROADCAST,
    MESSAGE_TYPE_ALL_LINK_CLEANUP,
    MESSAGE_TYPE_ALL_LINK_CLEANUP_ACK,
    MESSAGE_TYPE_ALL_LINK_CLEANUP_NAK,
    MESSAGE_TYPE_BROADCAST_MESSAGE,
    MESSAGE_TYPE_DIRECT_MESSAGE_ACK,
    MESSAGE_TYPE_DIRECT_MESSAGE_NAK,
)
        """Return a hexadecimal representation of the message flags."""
        return binascii.hexlify(self.bytes).decode()

    # pylint: disable=no-self-use
    def _normalize(self, flags):
        """Take any format of flags and turn it into a hex string."""
        norm = None
        if isinstance(flags, MessageFlags):
            norm = flags.bytes
        elif isinstance(flags, bytearray):
            norm = binascii.hexlify(flags)
        elif isinstance(flags, int):
            norm = bytes([flags])
        elif isinstance(flags, bytes):
            norm = binascii.hexlify(flags)
        elif isinstance(flags, str):
            flags = flags[0:2]
            norm = binascii.hexlify(binascii.unhexlify(flags.lower()))
        elif flags is None:
            norm = None
        else:
            _LOGGER.warning("MessageFlags with unknown type %s: %r", type(flags), flags)
        return norm

    def _set_properties(self, flags):
        """Set the properties of the message flags based on a byte input."""
        flagByte = self._normalize(flags)

        if flagByte is not None:
            self._messageType = (flagByte[0] & 0xE0) >> 5

# Path: insteonplm/constants.py
# MESSAGE_FLAG_EXTENDED_0X10 = 0x10
# 
# MESSAGE_TYPE_ALL_LINK_BROADCAST = 6
# 
# MESSAGE_TYPE_ALL_LINK_CLEANUP = 2
# 
# MESSAGE_TYPE_ALL_LINK_CLEANUP_ACK = 3
# 
# MESSAGE_TYPE_ALL_LINK_CLEANUP_NAK = 7
# 
# MESSAGE_TYPE_BROADCAST_MESSAGE = 4
# 
# MESSAGE_TYPE_DIRECT_MESSAGE_ACK = 1
# 
# MESSAGE_TYPE_DIRECT_MESSAGE_NAK = 5


# Path: insteonplm/messages/messageFlags.py
import logging
import binascii
from insteonplm.constants import (
    MESSAGE_FLAG_EXTENDED_0X10,
    MESSAGE_TYPE_ALL_LINK_BROADCAST,
    MESSAGE_TYPE_ALL_LINK_CLEANUP,
    MESSAGE_TYPE_ALL_LINK_CLEANUP_ACK,
    MESSAGE_TYPE_ALL_LINK_CLEANUP_NAK,
    MESSAGE_TYPE_BROADCAST_MESSAGE,
    MESSAGE_TYPE_DIRECT_MESSAGE_ACK,
    MESSAGE_TYPE_DIRECT_MESSAGE_NAK,
)

        """Return a hexadecimal representation of the message flags."""
        return binascii.hexlify(self.bytes).decode()

    # pylint: disable=no-self-use
    def _normalize(self, flags):
        """Take any format of flags and turn it into a hex string."""
        norm = None
        if isinstance(flags, MessageFlags):
            norm = flags.bytes
        elif isinstance(flags, bytearray):
            norm = binascii.hexlify(flags)
        elif isinstance(flags, int):
            norm = bytes([flags])
        elif isinstance(flags, bytes):
            norm = binascii.hexlify(flags)
        elif isinstance(flags, str):
            flags = flags[0:2]
            norm = binascii.hexlify(binascii.unhexlify(flags.lower()))
        elif flags is None:
            norm = None
        else:
            _LOGGER.warning("MessageFlags with unknown type %s: %r", type(flags), flags)
        return norm

    def _set_properties(self, flags):
        """Set the properties of the message flags based on a byte input."""
        flagByte = self._normalize(flags)

        if flagByte is not None:
            self._messageType = (flagByte[0] & 0xE0) >> 5

            self._extended = (flagByte[0] & MESSAGE_FLAG_EXTENDED_0X10) >> 4