mirror of
https://github.com/esphome/esphome.git
synced 2025-03-15 07:08:20 +00:00
added link from dashboard to web server, if configured
This commit is contained in:
parent
df50b95e5a
commit
6aa89fe608
@ -441,6 +441,7 @@ CONF_WAIT_UNTIL = 'wait_until'
|
|||||||
CONF_WAKEUP_PIN = 'wakeup_pin'
|
CONF_WAKEUP_PIN = 'wakeup_pin'
|
||||||
CONF_WARM_WHITE = 'warm_white'
|
CONF_WARM_WHITE = 'warm_white'
|
||||||
CONF_WARM_WHITE_COLOR_TEMPERATURE = 'warm_white_color_temperature'
|
CONF_WARM_WHITE_COLOR_TEMPERATURE = 'warm_white_color_temperature'
|
||||||
|
CONF_WEB_SERVER = 'web_server'
|
||||||
CONF_WHILE = 'while'
|
CONF_WHILE = 'while'
|
||||||
CONF_WHITE = 'white'
|
CONF_WHITE = 'white'
|
||||||
CONF_WIDTH = 'width'
|
CONF_WIDTH = 'width'
|
||||||
|
@ -11,7 +11,7 @@ import re
|
|||||||
from typing import Any, Dict, List # noqa
|
from typing import Any, Dict, List # noqa
|
||||||
|
|
||||||
from esphome.const import CONF_ARDUINO_VERSION, CONF_ESPHOME, CONF_USE_ADDRESS, CONF_WIFI, \
|
from esphome.const import CONF_ARDUINO_VERSION, CONF_ESPHOME, CONF_USE_ADDRESS, CONF_WIFI, \
|
||||||
SOURCE_FILE_EXTENSIONS
|
SOURCE_FILE_EXTENSIONS, CONF_WEB_SERVER
|
||||||
from esphome.helpers import ensure_unique_string, is_hassio
|
from esphome.helpers import ensure_unique_string, is_hassio
|
||||||
from esphome.py_compat import IS_PY2, integer_types, text_type, string_types
|
from esphome.py_compat import IS_PY2, integer_types, text_type, string_types
|
||||||
from esphome.util import OrderedDict
|
from esphome.util import OrderedDict
|
||||||
@ -594,6 +594,13 @@ class EsphomeCore(object):
|
|||||||
raise ValueError
|
raise ValueError
|
||||||
return self.esp_platform == 'ESP32'
|
return self.esp_platform == 'ESP32'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def web_server_enabled(self):
|
||||||
|
try:
|
||||||
|
return self.config[CONF_WEB_SERVER] is not None
|
||||||
|
except KeyError:
|
||||||
|
False
|
||||||
|
|
||||||
def add_job(self, func, *args, **kwargs):
|
def add_job(self, func, *args, **kwargs):
|
||||||
coro = coroutine(func)
|
coro = coroutine(func)
|
||||||
task = coro(*args, **kwargs)
|
task = coro(*args, **kwargs)
|
||||||
|
@ -430,6 +430,11 @@ class DashboardEntry(object):
|
|||||||
def update_new(self):
|
def update_new(self):
|
||||||
return const.__version__
|
return const.__version__
|
||||||
|
|
||||||
|
@property
|
||||||
|
def web_server_enabled(self):
|
||||||
|
if self.storage is None:
|
||||||
|
return False
|
||||||
|
return self.storage.web_server_enabled
|
||||||
|
|
||||||
class MainRequestHandler(BaseHandler):
|
class MainRequestHandler(BaseHandler):
|
||||||
@authenticated
|
@authenticated
|
||||||
|
@ -67,6 +67,9 @@
|
|||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<span class="card-title">
|
<span class="card-title">
|
||||||
{{ escape(entry.name) }}
|
{{ escape(entry.name) }}
|
||||||
|
{% if entry.web_server_enabled %}
|
||||||
|
<a href="http://{{ escape(entry.address) }}" target="_blank"><i class="material-icons icon-grey">launch</i></a>
|
||||||
|
{% end %}
|
||||||
<i class="material-icons right dropdown-trigger" data-target="dropdown-{{ i }}">more_vert</i>
|
<i class="material-icons right dropdown-trigger" data-target="dropdown-{{ i }}">more_vert</i>
|
||||||
</span>
|
</span>
|
||||||
<p>
|
<p>
|
||||||
|
@ -37,7 +37,7 @@ def trash_storage_path(base_path): # type: (str) -> str
|
|||||||
class StorageJSON(object):
|
class StorageJSON(object):
|
||||||
def __init__(self, storage_version, name, esphome_version,
|
def __init__(self, storage_version, name, esphome_version,
|
||||||
src_version, arduino_version, address, esp_platform, board, build_path,
|
src_version, arduino_version, address, esp_platform, board, build_path,
|
||||||
firmware_bin_path):
|
firmware_bin_path, web_server_enabled):
|
||||||
# Version of the storage JSON schema
|
# Version of the storage JSON schema
|
||||||
assert storage_version is None or isinstance(storage_version, int)
|
assert storage_version is None or isinstance(storage_version, int)
|
||||||
self.storage_version = storage_version # type: int
|
self.storage_version = storage_version # type: int
|
||||||
@ -61,6 +61,8 @@ class StorageJSON(object):
|
|||||||
self.build_path = build_path # type: str
|
self.build_path = build_path # type: str
|
||||||
# The absolute path to the firmware binary
|
# The absolute path to the firmware binary
|
||||||
self.firmware_bin_path = firmware_bin_path # type: str
|
self.firmware_bin_path = firmware_bin_path # type: str
|
||||||
|
# True if web server is enabled
|
||||||
|
self.web_server_enabled = web_server_enabled # type: bool
|
||||||
|
|
||||||
def as_dict(self):
|
def as_dict(self):
|
||||||
return {
|
return {
|
||||||
@ -74,6 +76,7 @@ class StorageJSON(object):
|
|||||||
'board': self.board,
|
'board': self.board,
|
||||||
'build_path': self.build_path,
|
'build_path': self.build_path,
|
||||||
'firmware_bin_path': self.firmware_bin_path,
|
'firmware_bin_path': self.firmware_bin_path,
|
||||||
|
'web_server_enabled': self.web_server_enabled,
|
||||||
}
|
}
|
||||||
|
|
||||||
def to_json(self):
|
def to_json(self):
|
||||||
@ -97,6 +100,7 @@ class StorageJSON(object):
|
|||||||
board=esph.board,
|
board=esph.board,
|
||||||
build_path=esph.build_path,
|
build_path=esph.build_path,
|
||||||
firmware_bin_path=esph.firmware_bin,
|
firmware_bin_path=esph.firmware_bin,
|
||||||
|
web_server_enabled=esph.web_server_enabled,
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -113,6 +117,7 @@ class StorageJSON(object):
|
|||||||
board=board,
|
board=board,
|
||||||
build_path=None,
|
build_path=None,
|
||||||
firmware_bin_path=None,
|
firmware_bin_path=None,
|
||||||
|
web_server_enabled=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -130,9 +135,10 @@ class StorageJSON(object):
|
|||||||
board = storage.get('board')
|
board = storage.get('board')
|
||||||
build_path = storage.get('build_path')
|
build_path = storage.get('build_path')
|
||||||
firmware_bin_path = storage.get('firmware_bin_path')
|
firmware_bin_path = storage.get('firmware_bin_path')
|
||||||
|
web_server_enabled = storage.get('web_server_enabled')
|
||||||
return StorageJSON(storage_version, name, esphome_version,
|
return StorageJSON(storage_version, name, esphome_version,
|
||||||
src_version, arduino_version, address, esp_platform, board, build_path,
|
src_version, arduino_version, address, esp_platform, board, build_path,
|
||||||
firmware_bin_path)
|
firmware_bin_path, web_server_enabled)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load(path): # type: (str) -> Optional[StorageJSON]
|
def load(path): # type: (str) -> Optional[StorageJSON]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user