mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Added command line toggle to open UI on start
This commit is contained in:
parent
1f32ce2ca4
commit
50eecd11c1
@ -42,7 +42,7 @@ git clone --recursive https://github.com/balloob/home-assistant.git
|
|||||||
cd home-assistant
|
cd home-assistant
|
||||||
pip3 install -r requirements.txt
|
pip3 install -r requirements.txt
|
||||||
|
|
||||||
python3 -m homeassistant
|
python3 -m homeassistant --open-ui
|
||||||
```
|
```
|
||||||
|
|
||||||
This will start the Home Assistant server and create an initial configuration file in `config/home-assistant.conf` that is setup for demo mode. It will launch its web interface on [http://127.0.0.1:8123](http://127.0.0.1:8123). The default password is 'password'.
|
This will start the Home Assistant server and create an initial configuration file in `config/home-assistant.conf` that is setup for demo mode. It will launch its web interface on [http://127.0.0.1:8123](http://127.0.0.1:8123). The default password is 'password'.
|
||||||
|
@ -51,8 +51,14 @@ class HomeAssistant(object):
|
|||||||
self.bus = EventBus(pool)
|
self.bus = EventBus(pool)
|
||||||
self.services = ServiceRegistry(self.bus, pool)
|
self.services = ServiceRegistry(self.bus, pool)
|
||||||
self.states = StateMachine(self.bus)
|
self.states = StateMachine(self.bus)
|
||||||
|
|
||||||
|
# List of loaded components
|
||||||
self.components = []
|
self.components = []
|
||||||
|
|
||||||
|
# Remote.API object pointing at local API
|
||||||
|
self.local_api = None
|
||||||
|
|
||||||
|
# Directory that holds the configuration
|
||||||
self.config_dir = os.path.join(os.getcwd(), 'config')
|
self.config_dir = os.path.join(os.getcwd(), 'config')
|
||||||
|
|
||||||
def get_config_path(self, path):
|
def get_config_path(self, path):
|
||||||
|
@ -17,6 +17,8 @@ except ImportError:
|
|||||||
|
|
||||||
from homeassistant import bootstrap
|
from homeassistant import bootstrap
|
||||||
|
|
||||||
|
from homeassistant.const import EVENT_HOMEASSISTANT_START
|
||||||
|
|
||||||
|
|
||||||
def validate_dependencies():
|
def validate_dependencies():
|
||||||
""" Validate all dependencies that HA uses. """
|
""" Validate all dependencies that HA uses. """
|
||||||
@ -72,6 +74,10 @@ def main():
|
|||||||
metavar='path_to_config_dir',
|
metavar='path_to_config_dir',
|
||||||
default="config",
|
default="config",
|
||||||
help="Directory that contains the Home Assistant configuration")
|
help="Directory that contains the Home Assistant configuration")
|
||||||
|
parser.add_argument(
|
||||||
|
'--open-ui',
|
||||||
|
action='store_true',
|
||||||
|
help='Open the webinterface in a browser')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
@ -82,6 +88,17 @@ def main():
|
|||||||
config_path = ensure_config_path(config_dir)
|
config_path = ensure_config_path(config_dir)
|
||||||
|
|
||||||
hass = bootstrap.from_config_file(config_path)
|
hass = bootstrap.from_config_file(config_path)
|
||||||
|
|
||||||
|
if args.open_ui:
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
def open_browser(event):
|
||||||
|
""" Open the webinterface in a browser. """
|
||||||
|
if hass.local_api is not None:
|
||||||
|
import webbrowser
|
||||||
|
webbrowser.open(hass.local_api.base_url)
|
||||||
|
|
||||||
|
hass.bus.listen_once(EVENT_HOMEASSISTANT_START, open_browser)
|
||||||
|
|
||||||
hass.start()
|
hass.start()
|
||||||
hass.block_till_stopped()
|
hass.block_till_stopped()
|
||||||
|
|
||||||
|
@ -141,10 +141,7 @@ def setup(hass, config):
|
|||||||
lambda event:
|
lambda event:
|
||||||
threading.Thread(target=server.start, daemon=True).start())
|
threading.Thread(target=server.start, daemon=True).start())
|
||||||
|
|
||||||
# If no local api set, set one with known information
|
hass.local_api = rem.API(util.get_local_ip(), api_password, server_port)
|
||||||
if isinstance(hass, rem.HomeAssistant) and hass.local_api is None:
|
|
||||||
hass.local_api = \
|
|
||||||
rem.API(util.get_local_ip(), api_password, server_port)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user