hass-core/start.py

25 lines
643 B
Python
Raw Normal View History

2014-09-24 22:36:52 -05:00
""" Starts home assistant. """
import sys
import os
2013-10-07 20:23:05 -07:00
import homeassistant
import homeassistant.bootstrap
2013-09-17 00:32:51 -07:00
2014-09-24 22:36:52 -05:00
# 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")
2014-11-02 09:41:41 -08:00
conf.write("api_password=password\n\n")
conf.write("[demo]\n")
2014-09-24 22:36:52 -05:00
hass = homeassistant.bootstrap.from_config_file(config_path)
hass.start()
hass.block_till_stopped()