1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-15 07:08:20 +00:00

included loaded_integration in storage json

This commit is contained in:
gitolicious 2019-05-26 11:25:45 +00:00
parent 3969473ee8
commit 2a52a4d7ed
3 changed files with 12 additions and 16 deletions

View File

@ -200,6 +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_LOCAL = 'local' CONF_LOCAL = 'local'
CONF_LOGGER = 'logger' CONF_LOGGER = 'logger'
CONF_LOGS = 'logs' CONF_LOGS = 'logs'
@ -441,7 +442,6 @@ 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'

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_WEB_SERVER SOURCE_FILE_EXTENSIONS, CONF_LOADED_INTEGRATIONS
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,10 +594,6 @@ class EsphomeCore(object):
raise ValueError raise ValueError
return self.esp_platform == 'ESP32' return self.esp_platform == 'ESP32'
@property
def web_server_enabled(self):
return CONF_WEB_SERVER in self.loaded_integrations
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)
@ -761,4 +757,4 @@ class EnumValue(object):
CORE = EsphomeCore() CORE = EsphomeCore()
ConfigType = Dict[str, Any] ConfigType = Dict[str, Any]
CoreType = EsphomeCore CoreType = EsphomeCore

View File

@ -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, web_server_enabled): firmware_bin_path, loaded_integrations):
# 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,8 +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 # A list of strings of names of loaded integrations
self.web_server_enabled = web_server_enabled # type: bool self.loaded_integrations = loaded_integrations # type: list[str]
def as_dict(self): def as_dict(self):
return { return {
@ -76,7 +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, 'loaded_integrations ': self.loaded_integrations,
} }
def to_json(self): def to_json(self):
@ -100,7 +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, loaded_integrations=list(sorted(esph.loaded_integrations)),
) )
@staticmethod @staticmethod
@ -117,7 +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, loaded_integrations=[],
) )
@staticmethod @staticmethod
@ -135,10 +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') loaded_integrations = storage.get('loaded_integrations')
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, web_server_enabled) firmware_bin_path, loaded_integrations)
@staticmethod @staticmethod
def load(path): # type: (str) -> Optional[StorageJSON] def load(path): # type: (str) -> Optional[StorageJSON]
@ -220,4 +220,4 @@ class EsphomeStorageJSON(object):
) )
def __eq__(self, o): # type: (Any) -> bool def __eq__(self, o): # type: (Any) -> bool
return isinstance(o, EsphomeStorageJSON) and self.as_dict() == o.as_dict() return isinstance(o, EsphomeStorageJSON) and self.as_dict() == o.as_dict()