mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 05:24:53 +01:00
Fix host network (#280)
* Fix Add-On host network mode * Split up esphomeyaml tests * Fix perms * Fix * Add esphomeyaml_version option * Revert change to travis.yml
This commit is contained in:
parent
2e65d6c02c
commit
a8c17e5d05
9 changed files with 62 additions and 17 deletions
|
@ -58,10 +58,15 @@ Example add-on configuration:
|
|||
{
|
||||
"ssl": false,
|
||||
"certfile": "fullchain.pem",
|
||||
"keyfile": "privkey.pem"
|
||||
"keyfile": "privkey.pem",
|
||||
"port": 6052
|
||||
}
|
||||
```
|
||||
|
||||
### Option: `port`
|
||||
|
||||
The port to start the dashboard server on. Default is 6052.
|
||||
|
||||
### Option: `ssl`
|
||||
|
||||
Enables/Disables encrypted SSL (HTTPS) connections to the web server of this add-on.
|
||||
|
@ -87,6 +92,15 @@ The private key file to use for SSL. If this file doesn't exist, the add-on star
|
|||
Adding this option to the add-on configuration allows you to disable
|
||||
authentication by setting it to `true`.
|
||||
|
||||
### Option: `esphomeyaml_version`
|
||||
|
||||
Manually override which esphomeyaml version to use in the addon.
|
||||
For example to install the latest development version, use `"esphomeyaml_version": "dev"`,
|
||||
or for version 1.10.0: `"esphomeyaml_version": "v1.10.0""`.
|
||||
|
||||
Please note that this does not always work and is only meant for testing, usually the
|
||||
esphomeyaml add-on and dashboard version must match to guarantee a working system.
|
||||
|
||||
[discord-shield]: https://img.shields.io/discord/429907082951524364.svg
|
||||
[dht22]: https://esphomelib.com/esphomeyaml/components/sensor/dht.html
|
||||
[discord]: https://discord.me/KhAMKrd
|
||||
|
|
|
@ -18,9 +18,6 @@
|
|||
"homeassistant_api": false,
|
||||
"host_network": true,
|
||||
"boot": "auto",
|
||||
"ports": {
|
||||
"6052/tcp": 6052
|
||||
},
|
||||
"map": [
|
||||
"ssl",
|
||||
"config:rw"
|
||||
|
@ -28,12 +25,15 @@
|
|||
"options": {
|
||||
"ssl": false,
|
||||
"certfile": "fullchain.pem",
|
||||
"keyfile": "privkey.pem"
|
||||
"keyfile": "privkey.pem",
|
||||
"port": 6052
|
||||
},
|
||||
"schema": {
|
||||
"ssl": "bool",
|
||||
"certfile": "str",
|
||||
"keyfile": "str",
|
||||
"leave_front_door_open": "bool?"
|
||||
"port": "int",
|
||||
"leave_front_door_open": "bool?",
|
||||
"esphomeyaml_version": "str?"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ source /usr/lib/hassio-addons/base.sh
|
|||
|
||||
declare certfile
|
||||
declare keyfile
|
||||
declare port
|
||||
|
||||
mkdir -p /var/log/nginx
|
||||
|
||||
|
@ -22,3 +23,6 @@ if hass.config.true 'ssl'; then
|
|||
sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/nginx.conf
|
||||
sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/nginx.conf
|
||||
fi
|
||||
|
||||
port=$(hass.config.get 'port')
|
||||
sed -i "s/%%port%%/${port}/g" /etc/nginx/nginx.conf
|
||||
|
|
14
esphomeyaml-edge/rootfs/etc/cont-init.d/30-esphomeyaml.sh
Normal file
14
esphomeyaml-edge/rootfs/etc/cont-init.d/30-esphomeyaml.sh
Normal file
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: esphomeyaml
|
||||
# This files installs the user esphomeyaml version if specified
|
||||
# ==============================================================================
|
||||
# shellcheck disable=SC1091
|
||||
source /usr/lib/hassio-addons/base.sh
|
||||
|
||||
declare esphomeyaml_version
|
||||
|
||||
if hass.config.has_value 'esphomeyaml_version'; then
|
||||
esphomeyaml_version=$(hass.config.get 'esphomeyaml_version')
|
||||
pip2 install --no-cache-dir --no-binary :all: "https://github.com/OttoWinter/esphomeyaml/archive/${esphomeyaml_version}.zip"
|
||||
end
|
|
@ -15,7 +15,7 @@ http {
|
|||
|
||||
upstream esphomeyaml {
|
||||
ip_hash;
|
||||
server 127.0.0.1:80;
|
||||
server unix:/var/run/esphomeyaml.sock;
|
||||
}
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
|
@ -24,7 +24,7 @@ http {
|
|||
|
||||
server {
|
||||
server_name hassio.local;
|
||||
listen 6052 default_server ssl;
|
||||
listen %%port%% default_server ssl;
|
||||
root /dev/null;
|
||||
|
||||
ssl_certificate /ssl/%%certfile%%;
|
||||
|
|
|
@ -15,7 +15,7 @@ http {
|
|||
|
||||
upstream esphomeyaml {
|
||||
ip_hash;
|
||||
server 127.0.0.1:80;
|
||||
server unix:/var/run/esphomeyaml.sock;
|
||||
}
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
|
@ -24,7 +24,7 @@ http {
|
|||
|
||||
server {
|
||||
server_name hassio.local;
|
||||
listen 6052 default_server;
|
||||
listen %%port%% default_server;
|
||||
root /dev/null;
|
||||
|
||||
location / {
|
||||
|
|
|
@ -11,4 +11,4 @@ if hass.config.true 'leave_front_door_open'; then
|
|||
fi
|
||||
|
||||
hass.log.info "Starting esphomeyaml dashboard..."
|
||||
exec esphomeyaml /config/esphomeyaml dashboard --port 80 --hassio
|
||||
exec esphomeyaml /config/esphomeyaml dashboard --socket /var/run/esphomeyaml.sock --hassio
|
||||
|
|
|
@ -450,6 +450,8 @@ def parse_args(argv):
|
|||
help="Internal flag used to tell esphomeyaml is started as a Hass.io "
|
||||
"add-on.",
|
||||
action="store_true")
|
||||
dashboard.add_argument("--socket",
|
||||
help="Make the dashboard serve under a unix socket", type=str)
|
||||
|
||||
subparsers.add_parser('hass-config',
|
||||
help="Dump the configuration entries that should be added "
|
||||
|
|
|
@ -13,6 +13,8 @@ import threading
|
|||
|
||||
import tornado
|
||||
import tornado.concurrent
|
||||
import tornado.httpserver
|
||||
import tornado.netutil
|
||||
import tornado.gen
|
||||
import tornado.ioloop
|
||||
import tornado.iostream
|
||||
|
@ -548,15 +550,22 @@ def start_web_server(args):
|
|||
storage.save(path)
|
||||
COOKIE_SECRET = storage.cookie_secret
|
||||
|
||||
_LOGGER.info("Starting dashboard web server on port %s and configuration dir %s...",
|
||||
args.port, CONFIG_DIR)
|
||||
app = make_app(args.verbose)
|
||||
app.listen(args.port)
|
||||
if args.socket is not None:
|
||||
_LOGGER.info("Starting dashboard web server on unix socket %s and configuration dir %s...",
|
||||
args.socket, CONFIG_DIR)
|
||||
server = tornado.httpserver.HTTPServer(app)
|
||||
socket = tornado.netutil.bind_unix_socket(args.socket, mode=0o666)
|
||||
server.add_socket(socket)
|
||||
else:
|
||||
_LOGGER.info("Starting dashboard web server on port %s and configuration dir %s...",
|
||||
args.port, CONFIG_DIR)
|
||||
app.listen(args.port)
|
||||
|
||||
if args.open_ui:
|
||||
import webbrowser
|
||||
if args.open_ui:
|
||||
import webbrowser
|
||||
|
||||
webbrowser.open('localhost:{}'.format(args.port))
|
||||
webbrowser.open('localhost:{}'.format(args.port))
|
||||
|
||||
ping_thread = PingThread()
|
||||
ping_thread.start()
|
||||
|
@ -567,3 +576,5 @@ def start_web_server(args):
|
|||
STOP_EVENT.set()
|
||||
PING_REQUEST.set()
|
||||
ping_thread.join()
|
||||
if args.socket is not None:
|
||||
os.remove(args.socket)
|
||||
|
|
Loading…
Reference in a new issue