first empty components

master
HB 5 years ago
parent 889b8027ca
commit 6bf96357eb

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -0,0 +1,5 @@
esphome:
name: custom_components_test
platform: ESP8266
board: nodemcuv2
build_path: .build/custom_components_test

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

@ -0,0 +1,6 @@
packages:
device: !include device.yaml
sensor:
- platform: example_custom_sensor
id: example_custom_sensor_1
Loading…
Cancel
Save