diff --git a/esphome/config_validation.py b/esphome/config_validation.py index ad0d90fcd3..466c540c81 100644 --- a/esphome/config_validation.py +++ b/esphome/config_validation.py @@ -1092,6 +1092,7 @@ def typed_schema(schemas, **kwargs): key_v = key_validator(value.pop(key)) value = schemas[key_v](value) value[key] = key_v + return value return validator diff --git a/tests/custom.h b/tests/custom.h index 7a5edbbf61..b392819efb 100644 --- a/tests/custom.h +++ b/tests/custom.h @@ -26,3 +26,13 @@ class CustomComponent : public PollingComponent { void setup() override { ESP_LOGD("custom_component", "Setup"); } void update() override { ESP_LOGD("custom_component", "Update"); } }; + +class CustomBinaryOutput : public BinaryOutput, public Component { + protected: + void write_state(bool state) override { ESP_LOGD("custom_output", "Setting %s", ONOFF(state)); } +}; + +class CustomFloatOutput : public FloatOutput, public Component { + protected: + void write_state(float state) override { ESP_LOGD("custom_output", "Setting %f", state); } +}; diff --git a/tests/test3.yaml b/tests/test3.yaml index 7fcc7e1e60..9b41efd7fb 100644 --- a/tests/test3.yaml +++ b/tests/test3.yaml @@ -377,6 +377,22 @@ output: id: out pin: D3 frequency: 50Hz + - platform: custom + type: binary + lambda: |- + auto s = new CustomBinaryOutput(); + App.register_component(s); + return {s}; + outputs: + - id: custom_binary + - platform: custom + type: float + lambda: |- + auto s = new CustomFloatOutput(); + App.register_component(s); + return {s}; + outputs: + - id: custom_float mcp23017: id: mcp