Ejemplo n.º 1
0
    def start(self):
        # If there is no local API setup but we do want to connect with remote
        # We create a random password and set up a local api
        if self.local_api is None:
            import homeassistant.components.http as http
            import random

            # pylint: disable=too-many-format-args
            random_password = '******'.format(random.randrange(16**30))

            http.setup(
                self, {http.DOMAIN: {
                    http.CONF_API_PASSWORD: random_password
                }})

        ha.Timer(self)

        self.bus.fire(ha.EVENT_HOMEASSISTANT_START,
                      origin=ha.EventOrigin.remote)

        # Setup that events from remote_api get forwarded to local_api
        # Do this after we fire START, otherwise HTTP is not started
        if not connect_remote_events(self.remote_api, self.local_api):
            raise ha.HomeAssistantError(
                ('Could not setup event forwarding from api {} to '
                 'local api {}').format(self.remote_api, self.local_api))
Ejemplo n.º 2
0
    def start(self):
        # Ensure a local API exists to connect with remote
        if self.config.api is None:
            bootstrap.setup_component(self, 'http')
            bootstrap.setup_component(self, 'api')

        ha.Timer(self)

        self.bus.fire(ha.EVENT_HOMEASSISTANT_START,
                      origin=ha.EventOrigin.remote)

        # Setup that events from remote_api get forwarded to local_api
        # Do this after we fire START, otherwise HTTP is not started
        if not connect_remote_events(self.remote_api, self.config.api):
            raise ha.HomeAssistantError(
                ('Could not setup event forwarding from api {} to '
                 'local api {}').format(self.remote_api, self.config.api))
Ejemplo n.º 3
0
    def start(self):
        # If there is no local API setup but we do want to connect with remote
        # We create a random password and set up a local api
        if self.local_api is None:
            import homeassistant.components.http as http
            import random

            # pylint: disable=too-many-format-args
            random_password = '******'.format(random.randrange(16**30))

            http.setup(self, random_password)

        ha.Timer(self)

        # Setup that events from remote_api get forwarded to local_api
        connect_remote_events(self.remote_api, self.local_api)

        self.bus.fire(ha.EVENT_HOMEASSISTANT_START,
                      origin=ha.EventOrigin.remote)