1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-04 04:12:23 +01:00

Cleanup dashboard JS (#491)

* Cleanup dashboard JS

* Add vscode

* Save start_mark/end_mark

* Updates

* Updates

* Remove need for cv.nameable

It's a bit hacky but removes so much bloat from integrations

* Add enum helper

* Document APIs, and Improvements

* Fixes

* Fixes

* Update PULL_REQUEST_TEMPLATE.md

* Updates

* Updates

* Updates
This commit is contained in:
Otto Winter
2019-04-22 21:56:30 +02:00
committed by GitHub
parent 6682c43dfa
commit 8e75980ebd
359 changed files with 4395 additions and 4223 deletions

View File

@@ -1,4 +1,5 @@
from esphome.const import CONF_INVERTED, CONF_MODE, CONF_NUMBER, CONF_SETUP_PRIORITY
from esphome.const import CONF_INVERTED, CONF_MODE, CONF_NUMBER, CONF_SETUP_PRIORITY, \
CONF_UPDATE_INTERVAL, CONF_TYPE_ID
from esphome.core import coroutine
from esphome.cpp_generator import RawExpression, add
from esphome.cpp_types import App, GPIOPin
@@ -6,10 +7,14 @@ from esphome.cpp_types import App, GPIOPin
@coroutine
def gpio_pin_expression(conf):
"""Generate an expression for the given pin option.
This is a coroutine, you must await it with a 'yield' expression!
"""
if conf is None:
return
from esphome import pins
for key, (_, func) in pins.PIN_SCHEMA_REGISTRY.items():
for key, (func, _) in pins.PIN_SCHEMA_REGISTRY.items():
if key in conf:
yield coroutine(func)(conf)
return
@@ -21,17 +26,34 @@ def gpio_pin_expression(conf):
@coroutine
def register_component(obj, config):
def register_component(var, config):
"""Register the given obj as a component.
This is a coroutine, you must await it with a 'yield' expression!
:param var: The variable representing the component.
:param config: The configuration for the component.
"""
if CONF_SETUP_PRIORITY in config:
add(obj.set_setup_priority(config[CONF_SETUP_PRIORITY]))
add(App.register_component(obj))
add(var.set_setup_priority(config[CONF_SETUP_PRIORITY]))
if CONF_UPDATE_INTERVAL in config:
add(var.set_update_interval(config[CONF_UPDATE_INTERVAL]))
add(App.register_component(var))
yield var
def extract_registry_entry_config(registry, full_config):
# type: (Registry, ConfigType) -> RegistryEntry
key, config = next((k, v) for k, v in full_config.items() if k in registry)
return registry[key], config
@coroutine
def build_registry_entry(registry, full_config):
key, config = next((k, v) for k, v in full_config.items() if k in registry)
builder = coroutine(registry[key][1])
yield builder(config)
registry_entry, config = extract_registry_entry_config(registry, full_config)
type_id = full_config[CONF_TYPE_ID]
builder = registry_entry.coroutine_fun
yield builder(config, type_id)
@coroutine