1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-15 15:18:16 +00:00

fixed loaded_integrations

plus linter changes
This commit is contained in:
gitolicious 2019-05-26 12:05:37 +00:00
parent f8c5528cc4
commit 926adb88c7
5 changed files with 11 additions and 10 deletions

View File

@ -200,7 +200,7 @@ CONF_LEVEL = 'level'
CONF_LG = 'lg' CONF_LG = 'lg'
CONF_LIBRARIES = 'libraries' CONF_LIBRARIES = 'libraries'
CONF_LIGHT = 'light' CONF_LIGHT = 'light'
CONF_LOADED_INTEGRATIONS = 'loaded_integration' CONF_LOADED_INTEGRATIONS = 'loaded_integrations'
CONF_LOCAL = 'local' CONF_LOCAL = 'local'
CONF_LOGGER = 'logger' CONF_LOGGER = 'logger'
CONF_LOGS = 'logs' CONF_LOGS = 'logs'

View File

@ -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, CONF_LOADED_INTEGRATIONS SOURCE_FILE_EXTENSIONS
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

View File

@ -431,10 +431,10 @@ class DashboardEntry(object):
return const.__version__ return const.__version__
@property @property
def web_server_enabled(self): def loaded_integrations(self):
if self.storage is None: if self.storage is None:
return False return False
return self.storage.web_server_enabled return self.storage.loaded_integrations
class MainRequestHandler(BaseHandler): class MainRequestHandler(BaseHandler):

View File

@ -67,7 +67,7 @@
<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 %} {% if entry.loaded_integrations and 'web_server' in entry.loaded_integrations %}
<a href="http://{{ escape(entry.address) }}" target="_blank"><i class="material-icons icon-grey">launch</i></a> <a href="http://{{ escape(entry.address) }}" target="_blank"><i class="material-icons icon-grey">launch</i></a>
{% end %} {% 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>

View File

@ -62,7 +62,7 @@ class StorageJSON(object):
# 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
# A list of strings of names of loaded integrations # A list of strings of names of loaded integrations
self.loaded_integrations = loaded_integrations # type: list[str] self.loaded_integrations = loaded_integrations # type: set[str]
def as_dict(self): def as_dict(self):
return { return {
@ -76,7 +76,8 @@ 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,
'loaded_integrations ': self.loaded_integrations, 'loaded_integrations':
sorted(self.loaded_integrations) if self.loaded_integrations is not None else [],
} }
def to_json(self): def to_json(self):
@ -100,7 +101,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,
loaded_integrations=list(sorted(esph.loaded_integrations)), loaded_integrations=esph.loaded_integrations,
) )
@staticmethod @staticmethod