# Path: nilmtk/utils.py
# def flatten_2d_list(list2d):
#     list1d = []
#     for item in list2d:
#         if isinstance(item, str):
#             list1d.append(item)
#         else:
#             try:
#                 len(item)
#             except TypeError:
#                 list1d.append(item)
#             else:
#                 list1d.extend(item)
#     return list1d


from warnings import warn
from collections import namedtuple
from copy import deepcopy
from .hashable import Hashable
from .utils import flatten_2d_list
from nilm_metadata import get_appliance_types
        self.metadata = {} if metadata is None else metadata

        # Instantiate static appliance_types
        if not Appliance.appliance_types:
            Appliance.appliance_types = get_appliance_types()

        # Check appliance type
        if (self.identifier.type and
                self.identifier.type not in Appliance.appliance_types):
            warn("'{}' is not a recognised appliance type."
                 .format(self.identifier.type), RuntimeWarning)

    @property
    def identifier(self):
        """Return ApplianceID"""
        md = self.metadata
        return ApplianceID(md.get('type'), md.get('instance'))

    @property
    def type(self):
        """Return deepcopy of dict describing appliance type."""
        return deepcopy(Appliance.appliance_types[self.identifier.type])

    @property
    def n_meters(self):
        """Return number of meters (int) to which this
        appliance is connected"""
        return len(self.metadata['meters'])

    def on_power_threshold(self):

# Path: nilmtk/utils.py
# def flatten_2d_list(list2d):
#     list1d = []
#     for item in list2d:
#         if isinstance(item, str):
#             list1d.append(item)
#         else:
#             try:
#                 len(item)
#             except TypeError:
#                 list1d.append(item)
#             else:
#                 list1d.extend(item)
#     return list1d


# Path: nilmtk/appliance.py
from warnings import warn
from collections import namedtuple
from copy import deepcopy
from .hashable import Hashable
from .utils import flatten_2d_list
from nilm_metadata import get_appliance_types

        self.metadata = {} if metadata is None else metadata

        # Instantiate static appliance_types
        if not Appliance.appliance_types:
            Appliance.appliance_types = get_appliance_types()

        # Check appliance type
        if (self.identifier.type and
                self.identifier.type not in Appliance.appliance_types):
            warn("'{}' is not a recognised appliance type."
                 .format(self.identifier.type), RuntimeWarning)

    @property
    def identifier(self):
        """Return ApplianceID"""
        md = self.metadata
        return ApplianceID(md.get('type'), md.get('instance'))

    @property
    def type(self):
        """Return deepcopy of dict describing appliance type."""
        return deepcopy(Appliance.appliance_types[self.identifier.type])

    @property
    def n_meters(self):
        """Return number of meters (int) to which this
        appliance is connected"""
        return len(self.metadata['meters'])

    def on_power_threshold(self):

        try: