mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 08:28:12 +01:00
3540b3fbb0
* Web Server * Preparations for 1.3 * Fixes * Fix Lint
29 lines
832 B
Python
29 lines
832 B
Python
import logging
|
|
|
|
import voluptuous as vol
|
|
|
|
import esphomeyaml.config_validation as cv
|
|
from esphomeyaml.const import CONF_PORT, CONF_JS_URL, CONF_CSS_URL, CONF_ID
|
|
from esphomeyaml.helpers import App, add, Pvariable
|
|
|
|
_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,
|
|
})
|
|
|
|
|
|
def to_code(config):
|
|
rhs = App.init_web_server(config.get(CONF_PORT))
|
|
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]))
|
|
|
|
|
|
def build_flags(config):
|
|
return '-DUSE_WEB_SERVER'
|