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

Warn if not registered properly

This commit is contained in:
Otto Winter
2019-05-21 12:23:38 +02:00
parent a323679771
commit 999c1a5357
9 changed files with 30 additions and 6 deletions

View File

@@ -1,8 +1,9 @@
from esphome.const import CONF_INVERTED, CONF_MODE, CONF_NUMBER, CONF_SETUP_PRIORITY, \
CONF_UPDATE_INTERVAL, CONF_TYPE_ID
from esphome.core import coroutine, ID
from esphome.core import coroutine, ID, CORE
from esphome.cpp_generator import RawExpression, add, get_variable
from esphome.cpp_types import App, GPIOPin
from esphome.py_compat import text_type
@coroutine
@@ -34,6 +35,12 @@ def register_component(var, config):
:param var: The variable representing the component.
:param config: The configuration for the component.
"""
id_ = text_type(var.base)
if id_ not in CORE.component_ids:
raise ValueError(u"Component ID {} was not declared to inherit from Component, "
u"or was registered twice. Please create a bug report with your "
u"configuration.".format(id_))
CORE.component_ids.remove(id_)
if CONF_SETUP_PRIORITY in config:
add(var.set_setup_priority(config[CONF_SETUP_PRIORITY]))
if CONF_UPDATE_INTERVAL in config: