mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 05:47:10 +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/*
|
||||||
!config/home-assistant.conf.default
|
!config/home-assistant.conf.default
|
||||||
homeassistant/components/http/www_static/polymer/bower_components/*
|
homeassistant/components/http/www_static/polymer/bower_components/*
|
||||||
homeassistant/components/http/www_static/polymer/build.htm
|
|
||||||
|
|
||||||
# There is not a better solution afaik..
|
# There is not a better solution afaik..
|
||||||
!config/custom_components
|
!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
|
## 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:
|
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
|
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
|
||||||
npm install bower vulcanize
|
|
||||||
./build_polymer
|
|
||||||
|
|
||||||
python3 start.py
|
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
|
cd homeassistant/components/http/www_static/polymer
|
||||||
bower install
|
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_API_PASSWORD = "api_password"
|
||||||
CONF_SERVER_HOST = "server_host"
|
CONF_SERVER_HOST = "server_host"
|
||||||
CONF_SERVER_PORT = "server_port"
|
CONF_SERVER_PORT = "server_port"
|
||||||
|
CONF_DEVELOPMENT = "development"
|
||||||
|
|
||||||
|
|
||||||
def _get_domain_icon(domain):
|
def _get_domain_icon(domain):
|
||||||
@ -141,8 +142,11 @@ def setup(hass, config):
|
|||||||
|
|
||||||
server_port = config[DOMAIN].get(CONF_SERVER_PORT, rem.SERVER_PORT)
|
server_port = config[DOMAIN].get(CONF_SERVER_PORT, rem.SERVER_PORT)
|
||||||
|
|
||||||
|
development = config[DOMAIN].get(CONF_DEVELOPMENT, "") == "1"
|
||||||
|
|
||||||
server = HomeAssistantHTTPServer((server_host, server_port),
|
server = HomeAssistantHTTPServer((server_host, server_port),
|
||||||
RequestHandler, hass, api_password)
|
RequestHandler, hass, api_password,
|
||||||
|
development)
|
||||||
|
|
||||||
hass.listen_once_event(
|
hass.listen_once_event(
|
||||||
ha.EVENT_HOMEASSISTANT_START,
|
ha.EVENT_HOMEASSISTANT_START,
|
||||||
@ -161,12 +165,13 @@ class HomeAssistantHTTPServer(ThreadingMixIn, HTTPServer):
|
|||||||
""" Handle HTTP requests in a threaded fashion. """
|
""" Handle HTTP requests in a threaded fashion. """
|
||||||
|
|
||||||
def __init__(self, server_address, RequestHandlerClass,
|
def __init__(self, server_address, RequestHandlerClass,
|
||||||
hass, api_password):
|
hass, api_password, development=False):
|
||||||
super().__init__(server_address, RequestHandlerClass)
|
super().__init__(server_address, RequestHandlerClass)
|
||||||
|
|
||||||
|
self.server_address = server_address
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
self.api_password = api_password
|
self.api_password = api_password
|
||||||
self.server_address = server_address
|
self.development = development
|
||||||
self.logger = logging.getLogger(__name__)
|
self.logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# To store flash messages between sessions
|
# To store flash messages between sessions
|
||||||
@ -175,6 +180,10 @@ class HomeAssistantHTTPServer(ThreadingMixIn, HTTPServer):
|
|||||||
# We will lazy init this one if needed
|
# We will lazy init this one if needed
|
||||||
self.event_forwarder = None
|
self.event_forwarder = None
|
||||||
|
|
||||||
|
if development:
|
||||||
|
self.logger.info("running frontend in development mode")
|
||||||
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
""" Starts the server. """
|
""" Starts the server. """
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
@ -378,8 +387,10 @@ class RequestHandler(BaseHTTPRequestHandler):
|
|||||||
self.send_header('Content-type', 'text/html; charset=utf-8')
|
self.send_header('Content-type', 'text/html; charset=utf-8')
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
|
|
||||||
# TODO let's be able to switch this based on env
|
if self.server.development:
|
||||||
app_url = "build.htm" if False else "home-assistant-main.html"
|
app_url = "polymer/home-assistant-main.html"
|
||||||
|
else:
|
||||||
|
app_url = "frontend.html"
|
||||||
|
|
||||||
write(("<html>"
|
write(("<html>"
|
||||||
"<head><title>Home Assistant</title>"
|
"<head><title>Home Assistant</title>"
|
||||||
@ -390,7 +401,7 @@ class RequestHandler(BaseHTTPRequestHandler):
|
|||||||
"<script"
|
"<script"
|
||||||
" src='/static/polymer/bower_components/"
|
" src='/static/polymer/bower_components/"
|
||||||
"platform/platform.js'></script>"
|
"platform/platform.js'></script>"
|
||||||
"<link rel='import' href='/static/polymer/{}' />"
|
"<link rel='import' href='/static/{}' />"
|
||||||
"<meta name='viewport' content='width=device-width, "
|
"<meta name='viewport' content='width=device-width, "
|
||||||
" user-scalable=no, initial-scale=1.0, "
|
" user-scalable=no, initial-scale=1.0, "
|
||||||
" minimum-scale=1.0, maximum-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
|
auto
|
||||||
method="GET"
|
method="GET"
|
||||||
url="/api/states"
|
url="/api/states"
|
||||||
headers='{"HA-access": "{{auth}}"}'
|
headers="{{ha_headers}}"
|
||||||
on-core-response="{{statesLoaded}}"
|
on-core-response="{{statesLoaded}}"
|
||||||
handleAs="json">
|
handleAs="json">
|
||||||
</core-ajax>
|
</core-ajax>
|
||||||
@ -32,7 +32,7 @@
|
|||||||
auto
|
auto
|
||||||
method="GET"
|
method="GET"
|
||||||
url="/api/events"
|
url="/api/events"
|
||||||
headers='{"HA-access": "{{auth}}"}'
|
headers="{{ha_headers}}"
|
||||||
on-core-response="{{eventsLoaded}}"
|
on-core-response="{{eventsLoaded}}"
|
||||||
handleAs="json">
|
handleAs="json">
|
||||||
</core-ajax>
|
</core-ajax>
|
||||||
@ -41,7 +41,7 @@
|
|||||||
auto
|
auto
|
||||||
method="GET"
|
method="GET"
|
||||||
url="/api/services"
|
url="/api/services"
|
||||||
headers='{"HA-access": "{{auth}}"}'
|
headers="{{ha_headers}}"
|
||||||
on-core-response="{{servicesLoaded}}"
|
on-core-response="{{servicesLoaded}}"
|
||||||
handleAs="json">
|
handleAs="json">
|
||||||
</core-ajax>
|
</core-ajax>
|
||||||
@ -49,12 +49,16 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
Polymer({
|
Polymer({
|
||||||
auth: "",
|
auth: "not-set",
|
||||||
states: [],
|
states: [],
|
||||||
services: {},
|
services: {},
|
||||||
events: {},
|
events: {},
|
||||||
stateUpdateTimeout: null,
|
stateUpdateTimeout: null,
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
ha_headers: '{"HA-access": auth}'
|
||||||
|
},
|
||||||
|
|
||||||
created: function() {
|
created: function() {
|
||||||
this.api = this;
|
this.api = this;
|
||||||
|
|
||||||
@ -225,9 +229,9 @@
|
|||||||
}.bind(this)
|
}.bind(this)
|
||||||
|
|
||||||
if(parameters) {
|
if(parameters) {
|
||||||
req.send(JSON.stringify(parameters))
|
req.send(JSON.stringify(parameters));
|
||||||
} else {
|
} else {
|
||||||
req.send()
|
req.send();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -249,7 +253,7 @@
|
|||||||
eventType = eventType || "";
|
eventType = eventType || "";
|
||||||
eventData = eventData || "";
|
eventData = eventData || "";
|
||||||
|
|
||||||
this.$.eventDialog.show(eventType, eventData)
|
this.$.eventDialog.show(eventType, eventData);
|
||||||
},
|
},
|
||||||
|
|
||||||
showCallServiceDialog: function(domain, service, serviceData) {
|
showCallServiceDialog: function(domain, service, serviceData) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user