diff --git a/custom_components/empty_custom_binary_output/empty_custom_binary_output.cpp b/custom_components/empty_custom_binary_output/empty_custom_binary_output.cpp new file mode 100644 index 0000000..85f23df --- /dev/null +++ b/custom_components/empty_custom_binary_output/empty_custom_binary_output.cpp @@ -0,0 +1,20 @@ +#include "empty_custom_binary_output.h" + +namespace esphome { +namespace empty_custom_binary_output { + +void EmptyCustomBinaryOutput::setup(){ + +} + +void EmptyCustomBinaryOutput::write_state(bool state){ + +} + +void EmptyCustomBinaryOutput::dump_config() { + +} + +} //namespace empty_custom_binary_output +} //namespace esphome + diff --git a/custom_components/empty_custom_binary_output/empty_custom_binary_output.h b/custom_components/empty_custom_binary_output/empty_custom_binary_output.h new file mode 100644 index 0000000..9d764d6 --- /dev/null +++ b/custom_components/empty_custom_binary_output/empty_custom_binary_output.h @@ -0,0 +1,18 @@ +#pragma once + +#include "esphome/core/component.h" +#include "esphome/components/output/binary_output.h" + +namespace esphome { +namespace empty_custom_binary_output { + +class EmptyCustomBinaryOutput : public output::BinaryOutput, public Component { + public: + void setup() override; + void write_state(bool state) override; + void dump_config() override; +}; + + +} //namespace empty_custom_binary_output +} //namespace esphome \ No newline at end of file diff --git a/custom_components/empty_custom_binary_output/output.py b/custom_components/empty_custom_binary_output/output.py new file mode 100644 index 0000000..257c106 --- /dev/null +++ b/custom_components/empty_custom_binary_output/output.py @@ -0,0 +1,17 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import output +from esphome.const import CONF_ID + +empty_custom_binary_output_ns = cg.esphome_ns.namespace('empty_custom_binary_output') +EmptyCustomBinaryOutput = empty_custom_binary_output_ns.class_('EmptyCustomBinaryOutput', output.BinaryOutput, + cg.Component) + +CONFIG_SCHEMA = output.BINARY_OUTPUT_SCHEMA.extend({ + cv.Required(CONF_ID): cv.declare_id(EmptyCustomBinaryOutput), +}).extend(cv.COMPONENT_SCHEMA) + +def to_code(config): + var = cg.new_Pvariable(config[CONF_ID]) + yield output.register_output(var, config) + yield cg.register_component(var, config) \ No newline at end of file diff --git a/custom_components/empty_custom_binary_sensor/binary_sensor.py b/custom_components/empty_custom_binary_sensor/binary_sensor.py new file mode 100644 index 0000000..c40c52f --- /dev/null +++ b/custom_components/empty_custom_binary_sensor/binary_sensor.py @@ -0,0 +1,18 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import binary_sensor +from esphome.const import CONF_ID + +empty_custom_binary_sensor_ns = cg.esphome_ns.namespace('empty_custom_binary_sensor') + +EmptyCustomBinarySensor = empty_custom_binary_sensor_ns.class_('EmptyCustomBinarySensor', binary_sensor.BinarySensor, cg.Component) + +CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend({ + cv.GenerateID(): cv.declare_id(EmptyCustomBinarySensor), +}).extend(cv.COMPONENT_SCHEMA) + + +def to_code(config): + var = cg.new_Pvariable(config[CONF_ID]) + yield cg.register_component(var, config) + yield binary_sensor.register_binary_sensor(var, config) \ No newline at end of file diff --git a/custom_components/empty_custom_binary_sensor/empty_custom_binary_sensor.cpp b/custom_components/empty_custom_binary_sensor/empty_custom_binary_sensor.cpp new file mode 100644 index 0000000..d5a8dc3 --- /dev/null +++ b/custom_components/empty_custom_binary_sensor/empty_custom_binary_sensor.cpp @@ -0,0 +1,20 @@ +#include "esphome.h" +#include "empty_custom_binary_sensor.h" + +namespace esphome { +namespace empty_custom_binary_sensor { + +void EmptyCustomBinarySensor::setup() { + +} + +void EmptyCustomBinarySensor::update() { + +} + +void EmptyCustomBinarySensor::dump_config() { + +} + +} //namespace empty_custom_binary_sensor +} //namespace esphome \ No newline at end of file diff --git a/custom_components/empty_custom_binary_sensor/empty_custom_binary_sensor.h b/custom_components/empty_custom_binary_sensor/empty_custom_binary_sensor.h new file mode 100644 index 0000000..459c0ee --- /dev/null +++ b/custom_components/empty_custom_binary_sensor/empty_custom_binary_sensor.h @@ -0,0 +1,17 @@ +#pragma once + +#include "esphome/core/component.h" +#include "esphome/components/binary_sensor/binary_sensor.h" + +namespace esphome { +namespace empty_custom_binary_sensor { + +class EmptyCustomBinarySensor : public binary_sensor::BinarySensor, public PollingComponent { + public: + void setup() override; + void update() override; + void dump_config() override; +}; + +} //namespace empty_custom_binary_sensor +} //namespace esphome \ No newline at end of file diff --git a/custom_components/empty_custom_float_output/empty_custom_float_output.cpp b/custom_components/empty_custom_float_output/empty_custom_float_output.cpp new file mode 100644 index 0000000..9143f48 --- /dev/null +++ b/custom_components/empty_custom_float_output/empty_custom_float_output.cpp @@ -0,0 +1,20 @@ +#include "empty_custom_float_output.h" + +namespace esphome { +namespace empty_custom_float_output { + +void EmptyCustomFloatOutput::setup(){ + +} + +void EmptyCustomFloatOutput::write_state(float state){ + +} + +void EmptyCustomFloatOutput::dump_config() { + +} + +} //namespace empty_custom_float_output +} //namespace esphome + diff --git a/custom_components/empty_custom_float_output/empty_custom_float_output.h b/custom_components/empty_custom_float_output/empty_custom_float_output.h new file mode 100644 index 0000000..29b51fa --- /dev/null +++ b/custom_components/empty_custom_float_output/empty_custom_float_output.h @@ -0,0 +1,18 @@ +#pragma once + +#include "esphome/core/component.h" +#include "esphome/components/output/float_output.h" + +namespace esphome { +namespace empty_custom_float_output { + +class EmptyCustomFloatOutput : public output::FloatOutput, public Component { + public: + void setup() override; + void write_state(float state) override; + void dump_config() override; +}; + + +} //namespace empty_custom_float_output +} //namespace esphome \ No newline at end of file diff --git a/custom_components/empty_custom_float_output/output.py b/custom_components/empty_custom_float_output/output.py new file mode 100644 index 0000000..c6b88da --- /dev/null +++ b/custom_components/empty_custom_float_output/output.py @@ -0,0 +1,17 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import output +from esphome.const import CONF_ID + +empty_custom_float_output_ns = cg.esphome_ns.namespace('empty_custom_float_output') +EmptyCustomFloatOutput = empty_custom_float_output_ns.class_('EmptyCustomFloatOutput', output.FloatOutput, + cg.Component) + +CONFIG_SCHEMA = output.FLOAT_OUTPUT_SCHEMA.extend({ + cv.Required(CONF_ID): cv.declare_id(EmptyCustomFloatOutput), +}).extend(cv.COMPONENT_SCHEMA) + +def to_code(config): + var = cg.new_Pvariable(config[CONF_ID]) + yield output.register_output(var, config) + yield cg.register_component(var, config) \ No newline at end of file diff --git a/custom_components/empty_custom_light/empty_custom_light.cpp b/custom_components/empty_custom_light/empty_custom_light.cpp new file mode 100644 index 0000000..2680d13 --- /dev/null +++ b/custom_components/empty_custom_light/empty_custom_light.cpp @@ -0,0 +1,30 @@ +#include "esphome.h" +#include "empty_custom_light.h" + +namespace esphome { +namespace empty_custom_light { + +void EmptyCustomLightOutput::setup() { + +} + +light::LightTraits EmptyCustomLightOutput::get_traits() { + auto traits = light::LightTraits(); + traits.set_supports_brightness(true); + traits.set_supports_rgb(false); + traits.set_supports_rgb_white_value(false); + traits.set_supports_color_temperature(false); + + return traits; +} + +void EmptyCustomLightOutput::write_state(light::LightState *state) { + +} + +void EmptyCustomLightOutput::dump_config(){ + +} + +} //namespace empty_custom_light +} //namespace esphome \ No newline at end of file diff --git a/custom_components/empty_custom_light/empty_custom_light.h b/custom_components/empty_custom_light/empty_custom_light.h new file mode 100644 index 0000000..7d8b13d --- /dev/null +++ b/custom_components/empty_custom_light/empty_custom_light.h @@ -0,0 +1,22 @@ +#pragma once + +#include "esphome/core/component.h" +#include "esphome/components/light/light_output.h" + +namespace esphome { +namespace empty_custom_light { + +class EmptyCustomLightOutput : public light::LightOutput, public Component { + public: + void setup() override; + light::LightTraits get_traits() override; + void set_output(output::FloatOutput *output) { output_ = output; } + void write_state(light::LightState *state) override; + void dump_config() override; + + protected: + output::FloatOutput *output_; +}; + +} //namespace empty_custom_light +} //namespace esphome \ No newline at end of file diff --git a/custom_components/empty_custom_light/light.py b/custom_components/empty_custom_light/light.py new file mode 100644 index 0000000..65f9b8c --- /dev/null +++ b/custom_components/empty_custom_light/light.py @@ -0,0 +1,19 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import light, output +from esphome.const import CONF_OUTPUT_ID, CONF_OUTPUT + +empty_custom_light_ns = cg.esphome_ns.namespace('empty_custom_light') +EmptyCustomLightOutput = empty_custom_light_ns.class_('EmptyCustomLightOutput', light.LightOutput) + +CONFIG_SCHEMA = light.BRIGHTNESS_ONLY_LIGHT_SCHEMA.extend({ + cv.GenerateID(CONF_OUTPUT_ID): cv.declare_id(EmptyCustomLightOutput), + cv.Required(CONF_OUTPUT): cv.use_id(output.FloatOutput) +}) + +def to_code(config): + var = cg.new_Pvariable(config[CONF_OUTPUT_ID]) + yield light.register_light(var, config) + + out = yield cg.get_variable(config[CONF_OUTPUT]) + cg.add(var.set_output(out)) \ No newline at end of file diff --git a/custom_components/empty_custom_sensor/empty_custom_sensor.cpp b/custom_components/empty_custom_sensor/empty_custom_sensor.cpp new file mode 100644 index 0000000..f0385df --- /dev/null +++ b/custom_components/empty_custom_sensor/empty_custom_sensor.cpp @@ -0,0 +1,24 @@ +#include "esphome.h" +#include "empty_custom_sensor.h" + +namespace esphome { +namespace empty_custom_sensor { + +void EmptyCustomSensor::setup() { + +} + +void EmptyCustomSensor::loop() { + +} + +void EmptyCustomSensor::update() { + +} + +void EmptyCustomSensor::dump_config() { + +} + +} //namespace empty_custom_sensor +} //namespace esphome \ No newline at end of file diff --git a/custom_components/empty_custom_sensor/empty_custom_sensor.h b/custom_components/empty_custom_sensor/empty_custom_sensor.h new file mode 100644 index 0000000..56e3121 --- /dev/null +++ b/custom_components/empty_custom_sensor/empty_custom_sensor.h @@ -0,0 +1,17 @@ +#pragma once + +#include "esphome/core/component.h" +#include "esphome/components/sensor/sensor.h" + +namespace esphome { +namespace empty_custom_sensor { + +class EmptyCustomSensor : public sensor::Sensor, public PollingComponent { + void setup() override; + void loop() override; + void update() override; + void dump_config() override; +}; + +} //namespace empty_custom_sensor +} //namespace esphome \ No newline at end of file diff --git a/custom_components/empty_custom_sensor/sensor.py b/custom_components/empty_custom_sensor/sensor.py new file mode 100644 index 0000000..0190869 --- /dev/null +++ b/custom_components/empty_custom_sensor/sensor.py @@ -0,0 +1,17 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import sensor +from esphome.const import CONF_ID + +empty_custom_sensor_ns = cg.esphome_ns.namespace('empty_custom_sensor') + +EmptyCustomSensor = empty_custom_sensor_ns.class_('EmptyCustomSensor', cg.PollingComponent) + +CONFIG_SCHEMA = cv.Schema({ + cv.GenerateID(): cv.declare_id(EmptyCustomSensor) +}).extend(cv.polling_component_schema('60s')) + +def to_code(config): + var = cg.new_Pvariable(config[CONF_ID]) + yield cg.register_component(var, config) + \ No newline at end of file diff --git a/custom_components/empty_custom_switch/empty_custom_switch.cpp b/custom_components/empty_custom_switch/empty_custom_switch.cpp new file mode 100644 index 0000000..88ef417 --- /dev/null +++ b/custom_components/empty_custom_switch/empty_custom_switch.cpp @@ -0,0 +1,17 @@ +#include "esphome.h" +#include "empty_custom_switch.h" + +namespace esphome { +namespace empty_custom_switch { + + +void EmptyCustomSwitch::setup() { + +} + +void EmptyCustomSwitch::write_state(bool state) { + +} + +} //namespace empty_custom_switch +} //namespace esphome \ No newline at end of file diff --git a/custom_components/empty_custom_switch/empty_custom_switch.h b/custom_components/empty_custom_switch/empty_custom_switch.h new file mode 100644 index 0000000..bcaa613 --- /dev/null +++ b/custom_components/empty_custom_switch/empty_custom_switch.h @@ -0,0 +1,16 @@ +#pragma once + +#include "esphome/core/component.h" +#include "esphome/components/switch/switch.h" + +namespace esphome { +namespace empty_custom_switch { + +class EmptyCustomSwitch : public switch_::Switch, public Component { + public: + void setup() override; + void write_state(bool state) override; +}; + +} //namespace empty_custom_switch +} //namespace esphome \ No newline at end of file diff --git a/custom_components/empty_custom_switch/switch.py b/custom_components/empty_custom_switch/switch.py new file mode 100644 index 0000000..b6f6d19 --- /dev/null +++ b/custom_components/empty_custom_switch/switch.py @@ -0,0 +1,16 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import switch +from esphome.const import CONF_ID + +empty_custom_switch_ns = cg.esphome_ns.namespace('empty_custom_switch') +EmptyCustomSwitch = empty_custom_switch_ns.class_('EmptyCustomSwitch', switch.Switch, cg.Component) + +CONFIG_SCHEMA = switch.SWITCH_SCHEMA.extend({ + cv.GenerateID(): cv.declare_id(EmptyCustomSwitch) +}).extend(cv.COMPONENT_SCHEMA) + +def to_code(config): + var = cg.new_Pvariable(config[CONF_ID]) + yield cg.register_component(var, config) + yield switch.register_switch(var, config) diff --git a/custom_components/example_custom_sensor/example_custom_sensor.cpp b/custom_components/example_custom_sensor/example_custom_sensor.cpp new file mode 100644 index 0000000..f209a8b --- /dev/null +++ b/custom_components/example_custom_sensor/example_custom_sensor.cpp @@ -0,0 +1,24 @@ +#include "esphome.h" +#include "example_custom_sensor.h" + +namespace esphome { +namespace example_custom_sensor { + +void ExampleCustomSensor::setup() { + // This will be called by App.setup() +} + +void ExampleCustomSensor::loop() { + // This will be called by App.loop() +} + +void ExampleCustomSensor::update(){ + // This will be called every "update_interval" milliseconds. +} + +void ExampleCustomSensor::dump_config(){ + +} + +} //namespace example_custom_sensor +} //namespace esphome \ No newline at end of file diff --git a/custom_components/example_custom_sensor/example_custom_sensor.h b/custom_components/example_custom_sensor/example_custom_sensor.h new file mode 100644 index 0000000..78795b9 --- /dev/null +++ b/custom_components/example_custom_sensor/example_custom_sensor.h @@ -0,0 +1,17 @@ +#pragma once + +#include "esphome/core/component.h" +#include "esphome/components/sensor/sensor.h" + +namespace esphome { +namespace example_custom_sensor { + +class ExampleCustomSensor : public sensor::Sensor, public PollingComponent { + void setup() override; + void dump_config() override; + void loop() override; + void update() override; +}; + +} //namespace example_custom_sensor +} //namespace esphome \ No newline at end of file diff --git a/custom_components/example_custom_sensor/sensor.py b/custom_components/example_custom_sensor/sensor.py new file mode 100644 index 0000000..0c9f0b2 --- /dev/null +++ b/custom_components/example_custom_sensor/sensor.py @@ -0,0 +1,17 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import sensor +from esphome.const import CONF_ID + +example_custom_sensor_ns = cg.esphome_ns.namespace('example_custom_sensor') + +ExampleCustomSensor = example_custom_sensor_ns.class_('ExampleCustomSensor', cg.PollingComponent) + +CONFIG_SCHEMA = cv.Schema({ + cv.GenerateID(): cv.declare_id(ExampleCustomSensor) +}).extend(cv.polling_component_schema('60s')) + +def to_code(config): + var = cg.new_Pvariable(config[CONF_ID]) + yield cg.register_component(var, config) + \ No newline at end of file diff --git a/device.yaml b/device.yaml new file mode 100644 index 0000000..62a6435 --- /dev/null +++ b/device.yaml @@ -0,0 +1,5 @@ +esphome: + name: custom_components_test + platform: ESP8266 + board: nodemcuv2 + build_path: .build/custom_components_test \ No newline at end of file diff --git a/test_empty.yaml b/test_empty.yaml new file mode 100644 index 0000000..01a33d2 --- /dev/null +++ b/test_empty.yaml @@ -0,0 +1,26 @@ +packages: + device: !include device.yaml + +sensor: + - platform: empty_custom_sensor + id: empty_custom_sensor_1 + +binary_sensor: + - platform: empty_custom_binary_sensor + id: empty_custom_binary_sensor_1 + +output: + - platform: empty_custom_binary_output + id: empty_custom_binary_output_1 + + - platform: empty_custom_float_output + id: empty_custom_float_output_1 + +light: + - platform: empty_custom_light + id: empty_custom_light_1 + output: empty_custom_float_output_1 + +switch: + - platform: empty_custom_switch + id: empty_custom_switch_1 \ No newline at end of file diff --git a/test_examples.yaml b/test_examples.yaml new file mode 100644 index 0000000..2df6273 --- /dev/null +++ b/test_examples.yaml @@ -0,0 +1,6 @@ +packages: + device: !include device.yaml + +sensor: + - platform: example_custom_sensor + id: example_custom_sensor_1