-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix starting of remote slaves. #3681
Conversation
Ok this was a naive try, but i cannot understand that i'm only one who using remote instances.. |
@@ -131,13 +131,13 @@ def start_wsgi_server(event): | |||
"""Start the WSGI server.""" | |||
server.start() | |||
|
|||
hass.bus.listen_once(EVENT_HOMEASSISTANT_START, start_wsgi_server) | |||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, start_wsgi_server) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setup
is not called from within the event loop and thus should not call async_*
methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I use sync version, get freeze in this method
(hass) Michaels-MacBook:hass michaelkuty$ ./hass-slave.py
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): localhost
DEBUG:requests.packages.urllib3.connectionpool:"GET /api/ HTTP/1.1" 200 27
DEBUG:asyncio:Using selector: KqueueSelector
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): localhost
DEBUG:requests.packages.urllib3.connectionpool:"GET /api/states HTTP/1.1" 200 2
INFO:homeassistant.loader:Loaded api from homeassistant.components.api
INFO:homeassistant.loader:Loaded http from homeassistant.components.http
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the slave work when you add the async listener? When I setup a remote connection I get a lock in remote.py:StateMachine:__init__
the line bus.listen(ha.EVENT_STATE_CHANGED, self._state_changed_listener)
.
Changing it to an async_listen
makes the slave start, but it does not connect the master, which I guess is due to the fact that the EVENT_STATE_CHANGED
is not fired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
State was changed but is not set to remote API as you can see fix in last commit
|
||
def stop_wsgi_server(event): | ||
"""Stop the WSGI server.""" | ||
server.stop() | ||
|
||
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop_wsgi_server) | ||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, stop_wsgi_server) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
#! /Users/michaelkuty/projects/hass/bin/python3 import logging import homeassistant.bootstrap as bootstrap import homeassistant.config as config import homeassistant.remote as remote from homeassistant.const import EVENT_HOMEASSISTANT_START # setup logging logging.basicConfig(level=logging.DEBUG) # Location of the Master API: host, password, port. # Password and port are optional. remote_api = remote.API("localhost", port=8124) # Initialize slave hass = remote.HomeAssistant(remote_api) hass.config.config_dir = "/Users/michaelkuty/projects/hass/.config" myconfig = config.load_yaml_config_file( "/Users/michaelkuty/projects/hass/conf.yaml") # To add an interface to the slave on localhost:8123 #bootstrap.setup_component(hass, 'frontend', myconfig) def setup_platforms(event): """Stop the WSGI server.""" bootstrap.setup_component(hass, 'api', myconfig) bootstrap.setup_component(hass, 'http', myconfig) bootstrap.setup_component(hass, 'switch', myconfig) bootstrap.setup_component(hass, 'sensor', myconfig) hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, setup_platforms) hass.start()
6222e19
to
543ef27
Compare
|
The remote pieces of Home Assistant have not gotten the same amount of attention as the rest of the codebase. Some are thinking about a revamp based on websockets once we have switched our HTTP stack over to aiohttp (#3914) |
I agree this, but I think that for you is only some minutes, but for me is about hours of debugging. @balloob Please can you fix this just for basic functions now ? My implementation works but tests failing.. |
How that aiohttp has been implemented, is it possible we could see some progress from this? What is now required to get slaves working again? |
This PR seems to have gone stale. Closing it. You can reopen it when you're ready to finish it. |
Description:
Related to my issue #3669
I cannot start my slave with state sharing
Related issue (if applicable): fixes #
Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#
Example entry for
configuration.yaml
(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If code communicates with devices, web services, or a:
tox
run successfully. Your PR cannot be merged unless tests passREQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.If the code does not interact with devices:
tox
run successfully. Your PR cannot be merged unless tests pass