From 926adb88c7ab84b33aa293daedcce05cd3558c3a Mon Sep 17 00:00:00 2001 From: gitolicious Date: Sun, 26 May 2019 12:05:37 +0000 Subject: [PATCH] fixed loaded_integrations plus linter changes --- esphome/const.py | 2 +- esphome/core.py | 4 ++-- esphome/dashboard/dashboard.py | 4 ++-- esphome/dashboard/templates/index.html | 2 +- esphome/storage_json.py | 9 +++++---- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/esphome/const.py b/esphome/const.py index 1b3a4e62a0..2b00cf9d2e 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -200,7 +200,7 @@ CONF_LEVEL = 'level' CONF_LG = 'lg' CONF_LIBRARIES = 'libraries' CONF_LIGHT = 'light' -CONF_LOADED_INTEGRATIONS = 'loaded_integration' +CONF_LOADED_INTEGRATIONS = 'loaded_integrations' CONF_LOCAL = 'local' CONF_LOGGER = 'logger' CONF_LOGS = 'logs' diff --git a/esphome/core.py b/esphome/core.py index d3d2bbc488..7aaf6b2c70 100644 --- a/esphome/core.py +++ b/esphome/core.py @@ -11,7 +11,7 @@ import re from typing import Any, Dict, List # noqa 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.py_compat import IS_PY2, integer_types, text_type, string_types from esphome.util import OrderedDict @@ -757,4 +757,4 @@ class EnumValue(object): CORE = EsphomeCore() ConfigType = Dict[str, Any] -CoreType = EsphomeCore \ No newline at end of file +CoreType = EsphomeCore diff --git a/esphome/dashboard/dashboard.py b/esphome/dashboard/dashboard.py index 567850049a..22a7dfa105 100644 --- a/esphome/dashboard/dashboard.py +++ b/esphome/dashboard/dashboard.py @@ -431,10 +431,10 @@ class DashboardEntry(object): return const.__version__ @property - def web_server_enabled(self): + def loaded_integrations(self): if self.storage is None: return False - return self.storage.web_server_enabled + return self.storage.loaded_integrations class MainRequestHandler(BaseHandler): diff --git a/esphome/dashboard/templates/index.html b/esphome/dashboard/templates/index.html index ff13c2f167..edf1123c63 100644 --- a/esphome/dashboard/templates/index.html +++ b/esphome/dashboard/templates/index.html @@ -67,7 +67,7 @@
{{ escape(entry.name) }} - {% if entry.web_server_enabled %} + {% if entry.loaded_integrations and 'web_server' in entry.loaded_integrations %} launch {% end %} more_vert diff --git a/esphome/storage_json.py b/esphome/storage_json.py index 5346dcd596..7141793d0e 100644 --- a/esphome/storage_json.py +++ b/esphome/storage_json.py @@ -62,7 +62,7 @@ class StorageJSON(object): # The absolute path to the firmware binary self.firmware_bin_path = firmware_bin_path # type: str # 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): return { @@ -76,7 +76,8 @@ class StorageJSON(object): 'board': self.board, 'build_path': self.build_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): @@ -100,7 +101,7 @@ class StorageJSON(object): board=esph.board, build_path=esph.build_path, firmware_bin_path=esph.firmware_bin, - loaded_integrations=list(sorted(esph.loaded_integrations)), + loaded_integrations=esph.loaded_integrations, ) @staticmethod @@ -220,4 +221,4 @@ class EsphomeStorageJSON(object): ) def __eq__(self, o): # type: (Any) -> bool - return isinstance(o, EsphomeStorageJSON) and self.as_dict() == o.as_dict() \ No newline at end of file + return isinstance(o, EsphomeStorageJSON) and self.as_dict() == o.as_dict()