mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Starting home assistant is now done via __main__.py
This commit is contained in:
parent
d56edd46bb
commit
94d9cbf76e
@ -5,4 +5,4 @@ VOLUME /config
|
||||
|
||||
EXPOSE 8123
|
||||
|
||||
CMD [ "python", "./start.py", "--docker" ]
|
||||
CMD [ "python", "-m", "homeassistant", "--docker" ]
|
||||
|
@ -37,7 +37,7 @@ git clone --recursive https://github.com/balloob/home-assistant.git
|
||||
cd home-assistant
|
||||
pip3 install -r requirements.txt
|
||||
|
||||
python3 start.py
|
||||
python3 -m homeassistant
|
||||
```
|
||||
|
||||
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'.
|
||||
|
52
homeassistant/__main__.py
Normal file
52
homeassistant/__main__.py
Normal file
@ -0,0 +1,52 @@
|
||||
""" Starts home assistant. """
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
try:
|
||||
from homeassistant import bootstrap
|
||||
|
||||
except ImportError:
|
||||
# This is to add support to load Home Assistant using
|
||||
# `python3 homeassistant` instead of `python3 -m homeassistant`
|
||||
|
||||
# Insert the parent directory of this file into the module search path
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
|
||||
|
||||
from homeassistant import bootstrap
|
||||
|
||||
|
||||
ARG_RUN_TESTS = "--run-tests"
|
||||
ARG_DOCKER = '--docker'
|
||||
|
||||
|
||||
def main():
|
||||
""" Starts Home Assistant. Will create demo config if no config found. """
|
||||
|
||||
# Do we want to run the tests?
|
||||
if ARG_RUN_TESTS in sys.argv:
|
||||
sys.argv.remove(ARG_RUN_TESTS)
|
||||
|
||||
import unittest
|
||||
|
||||
unittest.main(module='homeassistant.test')
|
||||
|
||||
# Within Docker we load the config from a different path
|
||||
if ARG_DOCKER in sys.argv:
|
||||
config_path = '/config/home-assistant.conf'
|
||||
else:
|
||||
config_path = 'config/home-assistant.conf'
|
||||
|
||||
# Ensure a config file exists to make first time usage easier
|
||||
if not os.path.isfile(config_path):
|
||||
with open(config_path, 'w') as conf:
|
||||
conf.write("[http]\n")
|
||||
conf.write("api_password=password\n\n")
|
||||
conf.write("[demo]\n")
|
||||
|
||||
hass = bootstrap.from_config_file(config_path)
|
||||
hass.start()
|
||||
hass.block_till_stopped()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
24
start.py
24
start.py
@ -1,24 +0,0 @@
|
||||
""" Starts home assistant. """
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
import homeassistant
|
||||
import homeassistant.bootstrap
|
||||
|
||||
# Within Docker we load the config from a different path
|
||||
if '--docker' in sys.argv:
|
||||
config_path = '/config/home-assistant.conf'
|
||||
else:
|
||||
config_path = 'config/home-assistant.conf'
|
||||
|
||||
# Ensure a config file exists to make first time usage easier
|
||||
if not os.path.isfile(config_path):
|
||||
with open(config_path, 'w') as conf:
|
||||
conf.write("[http]\n")
|
||||
conf.write("api_password=password\n\n")
|
||||
conf.write("[demo]\n")
|
||||
|
||||
hass = homeassistant.bootstrap.from_config_file(config_path)
|
||||
hass.start()
|
||||
hass.block_till_stopped()
|
Loading…
x
Reference in New Issue
Block a user