mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	Fix css/js file loading for webserver when esphome not executed form config directory (#2207)
This commit is contained in:
		| @@ -13,7 +13,7 @@ from esphome.const import ( | |||||||
|     CONF_USERNAME, |     CONF_USERNAME, | ||||||
|     CONF_PASSWORD, |     CONF_PASSWORD, | ||||||
| ) | ) | ||||||
| from esphome.core import coroutine_with_priority | from esphome.core import CORE, coroutine_with_priority | ||||||
|  |  | ||||||
| AUTO_LOAD = ["json", "web_server_base"] | AUTO_LOAD = ["json", "web_server_base"] | ||||||
|  |  | ||||||
| @@ -61,9 +61,11 @@ async def to_code(config): | |||||||
|         cg.add(var.set_password(config[CONF_AUTH][CONF_PASSWORD])) |         cg.add(var.set_password(config[CONF_AUTH][CONF_PASSWORD])) | ||||||
|     if CONF_CSS_INCLUDE in config: |     if CONF_CSS_INCLUDE in config: | ||||||
|         cg.add_define("WEBSERVER_CSS_INCLUDE") |         cg.add_define("WEBSERVER_CSS_INCLUDE") | ||||||
|         with open(config[CONF_CSS_INCLUDE], "r") as myfile: |         path = CORE.relative_config_path(config[CONF_CSS_INCLUDE]) | ||||||
|  |         with open(path, "r") as myfile: | ||||||
|             cg.add(var.set_css_include(myfile.read())) |             cg.add(var.set_css_include(myfile.read())) | ||||||
|     if CONF_JS_INCLUDE in config: |     if CONF_JS_INCLUDE in config: | ||||||
|         cg.add_define("WEBSERVER_JS_INCLUDE") |         cg.add_define("WEBSERVER_JS_INCLUDE") | ||||||
|         with open(config[CONF_JS_INCLUDE], "r") as myfile: |         path = CORE.relative_config_path(config[CONF_JS_INCLUDE]) | ||||||
|  |         with open(path, "r") as myfile: | ||||||
|             cg.add(var.set_js_include(myfile.read())) |             cg.add(var.set_js_include(myfile.read())) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user