mirror of
https://github.com/home-assistant/core.git
synced 2025-07-07 13:27:09 +00:00
Home Assistant contains pre-compiled version of polymer components
This commit is contained in:
parent
5596ac7d55
commit
e7c648a2c3
1
.gitignore
vendored
1
.gitignore
vendored
@ -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
|
||||
|
@ -28,7 +28,7 @@ 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:
|
||||
|
||||
@ -36,8 +36,6 @@ Run the following code to get up and running with the minimum setup:
|
||||
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
|
||||
```
|
||||
|
@ -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
|
||||
|
@ -119,6 +119,7 @@ DOMAIN_ICONS = {
|
||||
CONF_API_PASSWORD = "api_password"
|
||||
CONF_SERVER_HOST = "server_host"
|
||||
CONF_SERVER_PORT = "server_port"
|
||||
CONF_DEVELOPMENT = "development"
|
||||
|
||||
|
||||
def _get_domain_icon(domain):
|
||||
@ -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,
|
||||
@ -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
|
||||
@ -175,6 +180,10 @@ class HomeAssistantHTTPServer(ThreadingMixIn, HTTPServer):
|
||||
# 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(
|
||||
@ -378,8 +387,10 @@ class RequestHandler(BaseHTTPRequestHandler):
|
||||
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>"
|
||||
@ -390,7 +401,7 @@ class RequestHandler(BaseHTTPRequestHandler):
|
||||
"<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' />"
|
||||
|
9976
homeassistant/components/http/www_static/frontend.html
Normal file
9976
homeassistant/components/http/www_static/frontend.html
Normal file
File diff suppressed because it is too large
Load Diff
@ -23,7 +23,7 @@
|
||||
auto
|
||||
method="GET"
|
||||
url="/api/states"
|
||||
headers='{"HA-access": "{{auth}}"}'
|
||||
headers="{{ha_headers}}"
|
||||
on-core-response="{{statesLoaded}}"
|
||||
handleAs="json">
|
||||
</core-ajax>
|
||||
@ -32,7 +32,7 @@
|
||||
auto
|
||||
method="GET"
|
||||
url="/api/events"
|
||||
headers='{"HA-access": "{{auth}}"}'
|
||||
headers="{{ha_headers}}"
|
||||
on-core-response="{{eventsLoaded}}"
|
||||
handleAs="json">
|
||||
</core-ajax>
|
||||
@ -41,7 +41,7 @@
|
||||
auto
|
||||
method="GET"
|
||||
url="/api/services"
|
||||
headers='{"HA-access": "{{auth}}"}'
|
||||
headers="{{ha_headers}}"
|
||||
on-core-response="{{servicesLoaded}}"
|
||||
handleAs="json">
|
||||
</core-ajax>
|
||||
@ -49,12 +49,16 @@
|
||||
</template>
|
||||
<script>
|
||||
Polymer({
|
||||
auth: "",
|
||||
auth: "not-set",
|
||||
states: [],
|
||||
services: {},
|
||||
events: {},
|
||||
stateUpdateTimeout: null,
|
||||
|
||||
computed: {
|
||||
ha_headers: '{"HA-access": auth}'
|
||||
},
|
||||
|
||||
created: function() {
|
||||
this.api = this;
|
||||
|
||||
@ -225,9 +229,9 @@
|
||||
}.bind(this)
|
||||
|
||||
if(parameters) {
|
||||
req.send(JSON.stringify(parameters))
|
||||
req.send(JSON.stringify(parameters));
|
||||
} else {
|
||||
req.send()
|
||||
req.send();
|
||||
}
|
||||
},
|
||||
|
||||
@ -249,7 +253,7 @@
|
||||
eventType = eventType || "";
|
||||
eventData = eventData || "";
|
||||
|
||||
this.$.eventDialog.show(eventType, eventData)
|
||||
this.$.eventDialog.show(eventType, eventData);
|
||||
},
|
||||
|
||||
showCallServiceDialog: function(domain, service, serviceData) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user