EVENT_SCARLETT_START = "scarlett_start" EVENT_SCARLETT_STOP = "scarlett_stop" EVENT_STATE_CHANGED = "state_changed" EVENT_TIME_CHANGED = "time_changed" EVENT_CALL_SERVICE = "call_service" EVENT_SERVICE_EXECUTED = "service_executed" EVENT_SERVICE_REGISTER = "service_register" EVENT_PLATFORM_DISCOVERED = "platform_discovered" EVENT_SCARLETT_SAY = "scarlett_speak" EVENT_LOCAL  = "LOCAL" EVENT_REMOTE = "REMOTE" def singleton(myClass):
    def getInstance(*args, **kwargs):
    def __init__(self, time_remaining):
    def get_time_remaining(self):
    def has_time_remaining(self, time_comparison=None):
def disambiguate_server_parameter(hostport_tuple):
def select(rlist, wlist, xlist, timeout=None):
def unlist(given_list):
def get_local_ip():
    def __init__(self, job_handler, worker_count=0, busy_callback=None):
    def add_worker(self):
    def remove_worker(self):
    def add_job(self, priority, job):
    def block_till_done(self):
    def stop(self):
    def _worker(self):
    def __init__(self, priority, item):
    def __cmp__(self, other):
class Stopwatch(object):
class ThreadPool(object):
class PriorityQueueItem(object):
from datetime import datetime
from scarlett.constants import ( EVENT_SCARLETT_START,
                                 EVENT_SCARLETT_STOP,
                                 EVENT_STATE_CHANGED,
                                 EVENT_TIME_CHANGED,
                                 EVENT_CALL_SERVICE,
                                 EVENT_SERVICE_EXECUTED,
                                 EVENT_SERVICE_REGISTER,
                                 EVENT_PLATFORM_DISCOVERED,
                                 EVENT_SCARLETT_SAY,
                                 EVENT_LOCAL,
                                 EVENT_REMOTE
                               )
from scarlett.util import ensure_unique_string, slugify
"""
Helper methods for features within Scarlett.
NOTE: Lots of help from home-assistant
NOTE: Lots of help from Trevor Payne's lesson on Finite State Machines
SOURCE: https://www.youtube.com/watch?v=E45v2dD3IQU&index=8&list=PL82YdDfxhWsC-3kdTKK2_mwbNdBfVvb_M
"""


#from scarlett.commands import Commander, get_component




def generate_entity_id(entity_id_format, name, current_ids=None, hass=None):
    """ Generate a unique entity ID based on given entity IDs or used ids. """
    if current_ids is None:
        if hass is None:
            raise RuntimeError("Missing required parameter currentids or hass")

        current_ids = hass.states.entity_ids()

    return ensure_unique_string(

        entity_id_format.format(slugify(name.lower())), current_ids)