esphome/esphomeyaml/components/web_server.py

38 lines
1,015 B
Python
Raw Normal View History

import logging
import voluptuous as vol
import esphomeyaml.config_validation as cv
2018-05-14 11:50:56 +02:00
from esphomeyaml import core
from esphomeyaml.const import CONF_PORT, CONF_JS_URL, CONF_CSS_URL, CONF_ID, ESP_PLATFORM_ESP32
2018-05-20 12:41:52 +02:00
from esphomeyaml.helpers import App, add, Pvariable, esphomelib_ns
_LOGGER = logging.getLogger(__name__)
CONFIG_SCHEMA = vol.Schema({
cv.GenerateID('web_server'): cv.register_variable_id,
vol.Optional(CONF_PORT): cv.port,
vol.Optional(CONF_CSS_URL): vol.Url,
vol.Optional(CONF_JS_URL): vol.Url,
})
2018-05-20 12:41:52 +02:00
WebServer = esphomelib_ns.WebServer
def to_code(config):
rhs = App.init_web_server(config.get(CONF_PORT))
2018-05-20 12:41:52 +02:00
web_server = Pvariable(WebServer, config[CONF_ID], rhs)
if CONF_CSS_URL in config:
add(web_server.set_css_url(config[CONF_CSS_URL]))
if CONF_JS_URL in config:
add(web_server.set_js_url(config[CONF_JS_URL]))
2018-05-06 15:56:12 +02:00
BUILD_FLAGS = '-DUSE_WEB_SERVER'
2018-05-14 11:50:56 +02:00
def lib_deps(config):
if core.ESP_PLATFORM == ESP_PLATFORM_ESP32:
return 'FS'
return ''