def add_entity(self, entity, platform=None):
        if entity is None or entity in self.entities.values():
            return False

        entity.hass = self.hass

        if getattr(entity, 'entity_id', None) is None:
            object_id = entity.name or DEVICE_DEFAULT_NAME

            if platform is not None and platform.entity_namespace is not None:
                object_id = '{} {}'.format(platform.entity_namespace,
                                           object_id)

            entity.entity_id = generate_entity_id(
                self.entity_id_format, object_id,
                self.entities.keys())

        self.entities[entity.entity_id] = entity
        entity.update_ha_state()

        return True
Get the current token position in the input text.
dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/helpers/entity_component.py/EntityComponent.add_entity--crossover with--dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/words/xish/xpathparser.py/Scanner.get_token_pos