Skip to content

Commit

Permalink
Home Assistant contains pre-compiled version of polymer components
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob committed Oct 25, 2014
1 parent 5596ac7 commit e7c648a
Show file tree
Hide file tree
Showing 6 changed files with 10,008 additions and 18 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
config/*
!config/home-assistant.conf.default
homeassistant/components/http/www_static/polymer/bower_components/*
homeassistant/components/http/www_static/polymer/build.htm

# There is not a better solution afaik..
!config/custom_components
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,14 @@ The system is built modular so support for other devices or actions can be imple

## Installation instructions / Quick-start guide

Running Home Assistant requires that node.js and python3 are installed. (Node.js is required for installing dependencies and concatenating the frontend)
Running Home Assistant requires that python3 is installed.

Run the following code to get up and running with the minimum setup:

```python
git clone --recursive https://github.com/balloob/home-assistant.git
cd home-assistant
pip3 install -r requirements.txt
npm install bower vulcanize
./build_polymer

python3 start.py
```
Expand Down
4 changes: 3 additions & 1 deletion build_polymer
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# To build the frontend, you need node, bower and vulcanize
# npm install -g bower vulcanize
cd homeassistant/components/http/www_static/polymer
bower install
vulcanize -o build.htm home-assistant-main.html
vulcanize -o ../frontend.html home-assistant-main.html
23 changes: 17 additions & 6 deletions homeassistant/components/http/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
CONF_API_PASSWORD = "api_password"
CONF_SERVER_HOST = "server_host"
CONF_SERVER_PORT = "server_port"
CONF_DEVELOPMENT = "development"


def _get_domain_icon(domain):
Expand All @@ -141,8 +142,11 @@ def setup(hass, config):

server_port = config[DOMAIN].get(CONF_SERVER_PORT, rem.SERVER_PORT)

development = config[DOMAIN].get(CONF_DEVELOPMENT, "") == "1"

server = HomeAssistantHTTPServer((server_host, server_port),
RequestHandler, hass, api_password)
RequestHandler, hass, api_password,
development)

hass.listen_once_event(
ha.EVENT_HOMEASSISTANT_START,
Expand All @@ -161,12 +165,13 @@ class HomeAssistantHTTPServer(ThreadingMixIn, HTTPServer):
""" Handle HTTP requests in a threaded fashion. """

def __init__(self, server_address, RequestHandlerClass,
hass, api_password):
hass, api_password, development=False):
super().__init__(server_address, RequestHandlerClass)

self.server_address = server_address
self.hass = hass
self.api_password = api_password
self.server_address = server_address
self.development = development
self.logger = logging.getLogger(__name__)

# To store flash messages between sessions
Expand All @@ -175,6 +180,10 @@ def __init__(self, server_address, RequestHandlerClass,
# We will lazy init this one if needed
self.event_forwarder = None

if development:
self.logger.info("running frontend in development mode")


def start(self):
""" Starts the server. """
self.logger.info(
Expand Down Expand Up @@ -378,8 +387,10 @@ def _handle_get_root(self, path_match, data):
self.send_header('Content-type', 'text/html; charset=utf-8')
self.end_headers()

# TODO let's be able to switch this based on env
app_url = "build.htm" if False else "home-assistant-main.html"
if self.server.development:
app_url = "polymer/home-assistant-main.html"
else:
app_url = "frontend.html"

write(("<html>"
"<head><title>Home Assistant</title>"
Expand All @@ -390,7 +401,7 @@ def _handle_get_root(self, path_match, data):
"<script"
" src='/static/polymer/bower_components/"
"platform/platform.js'></script>"
"<link rel='import' href='/static/polymer/{}' />"
"<link rel='import' href='/static/{}' />"
"<meta name='viewport' content='width=device-width, "
" user-scalable=no, initial-scale=1.0, "
" minimum-scale=1.0, maximum-scale=1.0' />"
Expand Down
Loading

0 comments on commit e7c648a

Please sign in to comment.