Fix custom output, add test

Fixes https://github.com/esphome/issues/issues/346
This commit is contained in:
Otto Winter 2019-05-27 09:58:55 +02:00
parent 510e53de70
commit dac624231f
No known key found for this signature in database
GPG Key ID: DB66C0BE6013F97E
3 changed files with 27 additions and 0 deletions

View File

@ -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

View File

@ -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); }
};

View File

@ -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