rename folder
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
output:
|
||||
- platform: empty_binary_output
|
||||
id: empty_binary_output_1
|
||||
```
|
||||
@@ -0,0 +1,23 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "empty_binary_output.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_binary_output {
|
||||
|
||||
static const char *TAG = "empty_binary_output.binary_output";
|
||||
|
||||
void EmptyBinaryOutput::setup(){
|
||||
|
||||
}
|
||||
|
||||
void EmptyBinaryOutput::write_state(bool state){
|
||||
|
||||
}
|
||||
|
||||
void EmptyBinaryOutput::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "Custom binary output");
|
||||
}
|
||||
|
||||
} //namespace empty_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_binary_output {
|
||||
|
||||
class EmptyBinaryOutput : public output::BinaryOutput, public Component {
|
||||
public:
|
||||
void setup() override;
|
||||
void write_state(bool state) override;
|
||||
void dump_config() override;
|
||||
};
|
||||
|
||||
|
||||
} //namespace empty_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_binary_output_ns = cg.esphome_ns.namespace('empty_binary_output')
|
||||
EmptyBinaryOutput = empty_binary_output_ns.class_('EmptyBinaryOutput', output.BinaryOutput,
|
||||
cg.Component)
|
||||
|
||||
CONFIG_SCHEMA = output.BINARY_OUTPUT_SCHEMA.extend({
|
||||
cv.Required(CONF_ID): cv.declare_id(EmptyBinaryOutput),
|
||||
}).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,7 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
binary_sensor:
|
||||
- platform: empty_binary_sensor
|
||||
name: Empty binary sensor
|
||||
```
|
||||
@@ -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_binary_sensor_ns = cg.esphome_ns.namespace('empty_binary_sensor')
|
||||
|
||||
EmptyBinarySensor = empty_binary_sensor_ns.class_('EmptyBinarySensor', binary_sensor.BinarySensor, cg.Component)
|
||||
|
||||
CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_id(EmptyBinarySensor),
|
||||
}).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,22 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "empty_binary_sensor.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_binary_sensor {
|
||||
|
||||
static const char *TAG = "empty_binary_sensor.binary_sensor";
|
||||
|
||||
void EmptyBinarySensor::setup() {
|
||||
|
||||
}
|
||||
|
||||
void EmptyBinarySensor::update() {
|
||||
|
||||
}
|
||||
|
||||
void EmptyBinarySensor::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "Custom binary sensor");
|
||||
}
|
||||
|
||||
} //namespace empty_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_binary_sensor {
|
||||
|
||||
class EmptyBinarySensor : public binary_sensor::BinarySensor, public PollingComponent {
|
||||
public:
|
||||
void setup() override;
|
||||
void update() override;
|
||||
void dump_config() override;
|
||||
};
|
||||
|
||||
} //namespace empty_binary_sensor
|
||||
} //namespace esphome
|
||||
@@ -0,0 +1,6 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
empty_component:
|
||||
id: empty_component_1
|
||||
```
|
||||
@@ -0,0 +1,14 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_ID
|
||||
|
||||
empty_component_ns = cg.esphome_ns.namespace('empty_component')
|
||||
EmptyComponent = empty_component_ns.class_('EmptyComponent', cg.Component)
|
||||
|
||||
CONFIG_SCHEMA = cv.Schema({
|
||||
cv.GenerateID(): cv.declare_id(EmptyComponent)
|
||||
}).extend(cv.COMPONENT_SCHEMA)
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
yield cg.register_component(var, config)
|
||||
@@ -0,0 +1,23 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "empty_component.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_component {
|
||||
|
||||
static const char *TAG = "empty_component.component";
|
||||
|
||||
void EmptyComponent::setup() {
|
||||
|
||||
}
|
||||
|
||||
void EmptyComponent::loop() {
|
||||
|
||||
}
|
||||
|
||||
void EmptyComponent::dump_config(){
|
||||
ESP_LOGCONFIG(TAG, "Empty component");
|
||||
}
|
||||
|
||||
|
||||
} // namespace empty_component
|
||||
} // namespace esphome
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_component {
|
||||
|
||||
class EmptyComponent : public Component {
|
||||
public:
|
||||
void setup() override;
|
||||
void loop() override;
|
||||
void dump_config() override;
|
||||
};
|
||||
|
||||
|
||||
} // namespace empty_component
|
||||
} // namespace esphome
|
||||
@@ -0,0 +1,12 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
sensor:
|
||||
- platform: empty_compound_sensor
|
||||
sensor1:
|
||||
name: Sensor 1
|
||||
sensor2:
|
||||
name: Sensor 2
|
||||
sensor3:
|
||||
name: Sensor 3
|
||||
```
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "empty_compound_sensor.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_compound_sensor {
|
||||
|
||||
static const char *TAG = "empty_compound_sensor.sensor";
|
||||
|
||||
void EmptyCompoundSensor::setup() {
|
||||
|
||||
}
|
||||
|
||||
void EmptyCompoundSensor::loop() {
|
||||
|
||||
}
|
||||
|
||||
void EmptyCompoundSensor::update() {
|
||||
if (this->sensor1_ != nullptr)
|
||||
this->sensor1_->publish_state(1.0f);
|
||||
if (this->sensor2_ != nullptr)
|
||||
this->sensor2_->publish_state(2.0f);
|
||||
if (this->sensor3_ != nullptr)
|
||||
this->sensor3_->publish_state(3.0f);
|
||||
}
|
||||
|
||||
void EmptyCompoundSensor::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "Empty compound sensor");
|
||||
}
|
||||
|
||||
} //namespace empty_compound_sensor
|
||||
} //namespace esphome
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_compound_sensor {
|
||||
|
||||
class EmptyCompoundSensor : public sensor::Sensor, public PollingComponent {
|
||||
public:
|
||||
void set_sensor1(sensor::Sensor *sensor1) { sensor1_ = sensor1; }
|
||||
void set_sensor2(sensor::Sensor *sensor2) { sensor2_ = sensor2; }
|
||||
void set_sensor3(sensor::Sensor *sensor3) { sensor3_ = sensor3; }
|
||||
|
||||
void setup() override;
|
||||
void loop() override;
|
||||
void update() override;
|
||||
void dump_config() override;
|
||||
|
||||
protected:
|
||||
sensor::Sensor *sensor1_;
|
||||
sensor::Sensor *sensor2_;
|
||||
sensor::Sensor *sensor3_;
|
||||
};
|
||||
|
||||
} //namespace empty_compound_sensor
|
||||
} //namespace esphome
|
||||
@@ -0,0 +1,42 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import sensor
|
||||
from esphome.const import CONF_ID, UNIT_EMPTY, ICON_EMPTY
|
||||
|
||||
empty_compound_sensor_ns = cg.esphome_ns.namespace('empty_compound_sensor')
|
||||
EmptyCompoundSensor = empty_compound_sensor_ns.class_('EmptyCompoundSensor', cg.PollingComponent)
|
||||
|
||||
CONF_SENSOR1 = "sensor1"
|
||||
CONF_SENSOR2 = "sensor2"
|
||||
CONF_SENSOR3 = "sensor3"
|
||||
|
||||
CONFIG_SCHEMA = cv.Schema({
|
||||
cv.GenerateID(): cv.declare_id(EmptyCompoundSensor),
|
||||
cv.Optional(CONF_SENSOR1):
|
||||
sensor.sensor_schema(UNIT_EMPTY, ICON_EMPTY, 1).extend(),
|
||||
cv.Optional(CONF_SENSOR2):
|
||||
sensor.sensor_schema(UNIT_EMPTY, ICON_EMPTY, 1).extend(),
|
||||
cv.Optional(CONF_SENSOR3):
|
||||
sensor.sensor_schema(UNIT_EMPTY, ICON_EMPTY, 1).extend()
|
||||
}).extend(cv.polling_component_schema('60s'))
|
||||
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
yield cg.register_component(var, config)
|
||||
|
||||
if CONF_SENSOR1 in config:
|
||||
conf = config[CONF_SENSOR1]
|
||||
sens = yield sensor.new_sensor(conf)
|
||||
cg.add(var.set_sensor1(sens))
|
||||
|
||||
if CONF_SENSOR2 in config:
|
||||
conf = config[CONF_SENSOR2]
|
||||
sens = yield sensor.new_sensor(conf)
|
||||
cg.add(var.set_sensor2(sens))
|
||||
|
||||
if CONF_SENSOR3 in config:
|
||||
conf = config[CONF_SENSOR3]
|
||||
sens = yield sensor.new_sensor(conf)
|
||||
cg.add(var.set_sensor3(sens))
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
cover:
|
||||
platform: empty_cover
|
||||
name: Empty cover
|
||||
```
|
||||
@@ -0,0 +1,18 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome import automation
|
||||
from esphome.components import cover
|
||||
from esphome.const import CONF_ID
|
||||
|
||||
empty_cover_ns = cg.esphome_ns.namespace('empty_cover')
|
||||
EmptyCover = empty_cover_ns.class_('EmptyCover', cover.Cover, cg.Component)
|
||||
|
||||
CONFIG_SCHEMA = cover.COVER_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_id(EmptyCover)
|
||||
}).extend(cv.COMPONENT_SCHEMA)
|
||||
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
yield cg.register_component(var, config)
|
||||
yield cover.register_cover(var, config)
|
||||
@@ -0,0 +1,35 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "empty_cover.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_cover {
|
||||
|
||||
static const char *TAG = "empty_cover.cover";
|
||||
|
||||
void EmptyCover::setup() {
|
||||
|
||||
}
|
||||
|
||||
void EmptyCover::loop() {
|
||||
|
||||
}
|
||||
|
||||
void EmptyCover::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "Empty cover");
|
||||
}
|
||||
|
||||
cover::CoverTraits EmptyCover::get_traits() {
|
||||
auto traits = cover::CoverTraits();
|
||||
traits.set_is_assumed_state(false);
|
||||
traits.set_supports_position(false);
|
||||
traits.set_supports_tilt(false);
|
||||
|
||||
return traits;
|
||||
}
|
||||
|
||||
void EmptyCover::control(const cover::CoverCall &call) {
|
||||
|
||||
}
|
||||
|
||||
} // namespace empty_cover
|
||||
} // namespace esphome
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/cover/cover.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_cover {
|
||||
|
||||
class EmptyCover : public cover::Cover, public Component {
|
||||
public:
|
||||
void setup() override;
|
||||
void loop() override;
|
||||
void dump_config() override;
|
||||
cover::CoverTraits get_traits() override;
|
||||
|
||||
protected:
|
||||
void control(const cover::CoverCall &call) override;
|
||||
};
|
||||
|
||||
} // namespace empty_cover
|
||||
} // namespace esphome
|
||||
@@ -0,0 +1,13 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
fan:
|
||||
- platform: empty_fan
|
||||
name: Empty fan
|
||||
output: gpio_d1
|
||||
|
||||
output:
|
||||
- platform: gpio
|
||||
pin: D1
|
||||
id: gpio_d1
|
||||
```
|
||||
@@ -0,0 +1,3 @@
|
||||
import esphome.codegen as cg
|
||||
|
||||
empty_fan_ns = cg.esphome_ns.namespace('empty_fan')
|
||||
@@ -0,0 +1,33 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import fan, output
|
||||
from esphome.const import CONF_DIRECTION_OUTPUT, CONF_OSCILLATION_OUTPUT, \
|
||||
CONF_OUTPUT, CONF_OUTPUT_ID
|
||||
from .. import empty_fan_ns
|
||||
|
||||
EmptyFan = empty_fan_ns.class_('EmptyFan', cg.Component)
|
||||
|
||||
CONFIG_SCHEMA = fan.FAN_SCHEMA.extend({
|
||||
cv.GenerateID(CONF_OUTPUT_ID): cv.declare_id(EmptyFan),
|
||||
cv.Required(CONF_OUTPUT): cv.use_id(output.BinaryOutput),
|
||||
cv.Optional(CONF_DIRECTION_OUTPUT): cv.use_id(output.BinaryOutput),
|
||||
cv.Optional(CONF_OSCILLATION_OUTPUT): cv.use_id(output.BinaryOutput),
|
||||
}).extend(cv.COMPONENT_SCHEMA)
|
||||
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_OUTPUT_ID])
|
||||
yield cg.register_component(var, config)
|
||||
|
||||
fan_ = yield fan.create_fan_state(config)
|
||||
cg.add(var.set_fan(fan_))
|
||||
output_ = yield cg.get_variable(config[CONF_OUTPUT])
|
||||
cg.add(var.set_output(output_))
|
||||
|
||||
if CONF_OSCILLATION_OUTPUT in config:
|
||||
oscillation_output = yield cg.get_variable(config[CONF_OSCILLATION_OUTPUT])
|
||||
cg.add(var.set_oscillating(oscillation_output))
|
||||
|
||||
if CONF_DIRECTION_OUTPUT in config:
|
||||
direction_output = yield cg.get_variable(config[CONF_DIRECTION_OUTPUT])
|
||||
cg.add(var.set_direction(direction_output))
|
||||
@@ -0,0 +1,34 @@
|
||||
#include "empty_fan.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_fan {
|
||||
|
||||
static const char *TAG = "empty_fan.fan";
|
||||
|
||||
void EmptyFan::setup() {
|
||||
auto traits = fan::FanTraits();
|
||||
traits.set_direction(false);
|
||||
traits.set_oscillation(false);
|
||||
traits.set_speed(false);
|
||||
|
||||
this->fan_->set_traits(traits);
|
||||
|
||||
this->fan_->add_on_state_callback([this]() { this->next_update_ = true; });
|
||||
}
|
||||
|
||||
void EmptyFan::loop() {
|
||||
if (!this->next_update_) {
|
||||
return; //no state change, nothing to do
|
||||
}
|
||||
this->next_update_ = false;
|
||||
|
||||
//there was a state change, do something here.
|
||||
}
|
||||
|
||||
void EmptyFan::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "Empty fan");
|
||||
}
|
||||
|
||||
} // namespace binary
|
||||
} // namespace empty_fan
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/output/binary_output.h"
|
||||
#include "esphome/components/fan/fan_state.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_fan {
|
||||
|
||||
class EmptyFan : public Component {
|
||||
public:
|
||||
void set_fan(fan::FanState *fan) { fan_ = fan; }
|
||||
void set_output(output::BinaryOutput *output) { output_ = output; }
|
||||
void setup() override;
|
||||
void loop() override;
|
||||
void dump_config() override;
|
||||
|
||||
protected:
|
||||
fan::FanState *fan_;
|
||||
output::BinaryOutput *output_;
|
||||
bool next_update_{true};
|
||||
};
|
||||
|
||||
} // namespace empty_fan
|
||||
} // namespace esphome
|
||||
@@ -0,0 +1,7 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
output:
|
||||
- platform: empty_float_output
|
||||
id: empty_float_output_1
|
||||
```
|
||||
@@ -0,0 +1,23 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "empty_float_output.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_float_output {
|
||||
|
||||
static const char *TAG = "empty_float_output.output";
|
||||
|
||||
void EmptyFloatOutput::setup(){
|
||||
|
||||
}
|
||||
|
||||
void EmptyFloatOutput::write_state(float state){
|
||||
|
||||
}
|
||||
|
||||
void EmptyFloatOutput::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "Empty custom float output");
|
||||
}
|
||||
|
||||
} //namespace empty_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_float_output {
|
||||
|
||||
class EmptyFloatOutput : public output::FloatOutput, public Component {
|
||||
public:
|
||||
void setup() override;
|
||||
void write_state(float state) override;
|
||||
void dump_config() override;
|
||||
};
|
||||
|
||||
|
||||
} //namespace empty_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_float_output_ns = cg.esphome_ns.namespace('empty_float_output')
|
||||
EmptyFloatOutput = empty_float_output_ns.class_('EmptyFloatOutput', output.FloatOutput,
|
||||
cg.Component)
|
||||
|
||||
CONFIG_SCHEMA = output.FLOAT_OUTPUT_SCHEMA.extend({
|
||||
cv.Required(CONF_ID): cv.declare_id(EmptyFloatOutput),
|
||||
}).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,11 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
empty_i2c_component:
|
||||
id: empty_i2c_component_1
|
||||
address: 0x01 # optional
|
||||
|
||||
i2c:
|
||||
sda: 4
|
||||
scl: 5
|
||||
```
|
||||
@@ -0,0 +1,20 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import i2c, sensor
|
||||
from esphome.const import CONF_ID
|
||||
|
||||
DEPENDENCIES = ['i2c']
|
||||
|
||||
CONF_I2C_ADDR = 0x01
|
||||
|
||||
empty_i2c_component_ns = cg.esphome_ns.namespace('empty_i2c_component')
|
||||
EmptyI2CComponent = empty_i2c_component_ns.class_('EmptyI2CComponent', cg.Component, i2c.I2CDevice)
|
||||
|
||||
CONFIG_SCHEMA = cv.Schema({
|
||||
cv.GenerateID(): cv.declare_id(EmptyI2CComponent)
|
||||
}).extend(cv.COMPONENT_SCHEMA).extend(i2c.i2c_device_schema(CONF_I2C_ADDR))
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
yield cg.register_component(var, config)
|
||||
yield i2c.register_i2c_device(var, config)
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "empty_i2c_component.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_i2c_component {
|
||||
|
||||
static const char *TAG = "empty_i2c_component.component";
|
||||
|
||||
void EmptyI2CComponent::setup() {
|
||||
this->write_register(0x0, 0x1, 0x1);
|
||||
}
|
||||
|
||||
void EmptyI2CComponent::loop() {
|
||||
this->write_register(0x0, 0x1, 0x1);
|
||||
delay(1000);
|
||||
this->write_register(0x0, 0x0, 0x1);
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void EmptyI2CComponent::dump_config(){
|
||||
ESP_LOGCONFIG(TAG, "Empty I2C component");
|
||||
}
|
||||
|
||||
|
||||
} // namespace empty_i2c_component
|
||||
} // namespace esphome
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/i2c/i2c.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_i2c_component {
|
||||
|
||||
class EmptyI2CComponent : public i2c::I2CDevice, public Component {
|
||||
public:
|
||||
void setup() override;
|
||||
void loop() override;
|
||||
void dump_config() override;
|
||||
};
|
||||
|
||||
|
||||
} // namespace empty_i2c_component
|
||||
} // namespace esphome
|
||||
@@ -0,0 +1,11 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
sensor:
|
||||
- platform: empty_i2c_sensor
|
||||
name: Empty I2C sensor
|
||||
|
||||
i2c:
|
||||
sda: 4
|
||||
scl: 5
|
||||
```
|
||||
@@ -0,0 +1,22 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "empty_i2c_sensor.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_i2c_sensor {
|
||||
|
||||
static const char *TAG = "empty_i2c_sensor.sensor";
|
||||
|
||||
void EmptyI2CSensor::setup(){
|
||||
|
||||
}
|
||||
|
||||
void EmptyI2CSensor::update(){
|
||||
|
||||
}
|
||||
|
||||
void EmptyI2CSensor::dump_config(){
|
||||
|
||||
}
|
||||
|
||||
} // namespace EmptyI2CSensor
|
||||
} // namespace esphome
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
#include "esphome/components/i2c/i2c.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_i2c_sensor {
|
||||
|
||||
class EmptyI2CSensor : public sensor::Sensor, public PollingComponent, public i2c::I2CDevice {
|
||||
public:
|
||||
void setup() override;
|
||||
void update() override;
|
||||
void dump_config() override;
|
||||
};
|
||||
|
||||
} // namespace EmptyI2CSensor
|
||||
} // namespace esphome
|
||||
@@ -0,0 +1,22 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import i2c, sensor
|
||||
from esphome.const import CONF_ID, ICON_EMPTY, UNIT_EMPTY
|
||||
|
||||
DEPENDENCIES = ['i2c']
|
||||
|
||||
CONF_I2C_ADDR = 0x01
|
||||
|
||||
empty_i2c_sensor_ns = cg.esphome_ns.namespace('empty_i2c_sensor')
|
||||
EmptyI2CSensor = empty_i2c_sensor_ns.class_('EmptyI2CSensor', cg.PollingComponent, i2c.I2CDevice)
|
||||
|
||||
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_EMPTY, ICON_EMPTY, 1).extend({
|
||||
cv.GenerateID(): cv.declare_id(EmptyI2CSensor),
|
||||
}).extend(cv.polling_component_schema('60s')).extend(i2c.i2c_device_schema(CONF_I2C_ADDR))
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
yield cg.register_component(var, config)
|
||||
yield sensor.register_sensor(var, config)
|
||||
yield i2c.register_i2c_device(var, config)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
light:
|
||||
- platform: empty_light
|
||||
name: Empty light
|
||||
output: pwm_output
|
||||
|
||||
output:
|
||||
- platform: esp8266_pwm
|
||||
pin: D1
|
||||
frequency: 1000 Hz
|
||||
id: pwm_output
|
||||
```
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "empty_light.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_light {
|
||||
|
||||
static const char *TAG = "empty_light.light";
|
||||
|
||||
void EmptyLightOutput::setup() {
|
||||
|
||||
}
|
||||
|
||||
light::LightTraits EmptyLightOutput::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 EmptyLightOutput::write_state(light::LightState *state) {
|
||||
|
||||
}
|
||||
|
||||
void EmptyLightOutput::dump_config(){
|
||||
ESP_LOGCONFIG(TAG, "Empty custom light");
|
||||
}
|
||||
|
||||
} //namespace empty_light
|
||||
} //namespace esphome
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/output/float_output.h"
|
||||
#include "esphome/components/light/light_output.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_light {
|
||||
|
||||
class EmptyLightOutput : 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_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_light_ns = cg.esphome_ns.namespace('empty_light')
|
||||
EmptyLightOutput = empty_light_ns.class_('EmptyLightOutput', light.LightOutput)
|
||||
|
||||
CONFIG_SCHEMA = light.BRIGHTNESS_ONLY_LIGHT_SCHEMA.extend({
|
||||
cv.GenerateID(CONF_OUTPUT_ID): cv.declare_id(EmptyLightOutput),
|
||||
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,7 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
sensor:
|
||||
- platform: empty_sensor
|
||||
name: Empty sensor
|
||||
```
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "empty_sensor.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_sensor {
|
||||
|
||||
static const char *TAG = "empty_sensor.sensor";
|
||||
|
||||
void EmptySensor::setup() {
|
||||
|
||||
}
|
||||
|
||||
void EmptySensor::loop() {
|
||||
|
||||
}
|
||||
|
||||
void EmptySensor::update() {
|
||||
|
||||
}
|
||||
|
||||
void EmptySensor::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "Empty custom sensor");
|
||||
}
|
||||
|
||||
} //namespace empty_sensor
|
||||
} //namespace esphome
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_sensor {
|
||||
|
||||
class EmptySensor : public sensor::Sensor, public PollingComponent {
|
||||
void setup() override;
|
||||
void loop() override;
|
||||
void update() override;
|
||||
void dump_config() override;
|
||||
};
|
||||
|
||||
} //namespace empty_sensor
|
||||
} //namespace esphome
|
||||
@@ -0,0 +1,18 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import sensor
|
||||
from esphome.const import CONF_ID, UNIT_EMPTY, ICON_EMPTY
|
||||
|
||||
empty_sensor_ns = cg.esphome_ns.namespace('empty_sensor')
|
||||
|
||||
EmptySensor = empty_sensor_ns.class_('EmptySensor', cg.PollingComponent)
|
||||
|
||||
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_EMPTY, ICON_EMPTY, 1).extend({
|
||||
cv.GenerateID(): cv.declare_id(EmptySensor)
|
||||
}).extend(cv.polling_component_schema('60s'))
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
yield cg.register_component(var, config)
|
||||
yield sensor.register_sensor(var, config)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
empty_sensor_hub:
|
||||
id: empty_sensor_hub_1
|
||||
|
||||
sensor:
|
||||
- platform: empty_sensor_hub
|
||||
name: Sensor for empty sensor hub 1
|
||||
empty_sensor_hub_id: empty_sensor_hub_1
|
||||
|
||||
- platform: empty_sensor_hub
|
||||
name: Sensor for empty sensor hub 2
|
||||
empty_sensor_hub_id: empty_sensor_hub_1
|
||||
|
||||
text_sensor:
|
||||
- platform: empty_sensor_hub
|
||||
name: Text sensor for empty sensor hub 1
|
||||
empty_sensor_hub_id: empty_sensor_hub_1
|
||||
|
||||
- platform: empty_sensor_hub
|
||||
name: Text sensor for empty sensor hub 2
|
||||
empty_sensor_hub_id: empty_sensor_hub_1
|
||||
|
||||
binary_sensor:
|
||||
- platform: empty_sensor_hub
|
||||
name: Binary sensor for empty sensor hub 1
|
||||
empty_sensor_hub_id: empty_sensor_hub_1
|
||||
|
||||
- platform: empty_sensor_hub
|
||||
name: Binary sensor for empty sensor hub 2
|
||||
empty_sensor_hub_id: empty_sensor_hub_1
|
||||
```
|
||||
@@ -0,0 +1,20 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_ID
|
||||
|
||||
AUTO_LOAD = ['sensor','text_sensor', 'binary_sensor']
|
||||
MULTI_CONF = True
|
||||
|
||||
CONF_HUB_ID = 'empty_sensor_hub_id'
|
||||
|
||||
empty_sensor_hub_ns = cg.esphome_ns.namespace('empty_sensor_hub')
|
||||
|
||||
EmptySensorHub = empty_sensor_hub_ns.class_('EmptySensorHub', cg.Component)
|
||||
|
||||
CONFIG_SCHEMA = cv.Schema({
|
||||
cv.GenerateID(): cv.declare_id(EmptySensorHub),
|
||||
}).extend(cv.COMPONENT_SCHEMA)
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
yield cg.register_component(var, config)
|
||||
@@ -0,0 +1,23 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import binary_sensor
|
||||
from esphome.const import CONF_ID
|
||||
from . import EmptySensorHub, CONF_HUB_ID
|
||||
|
||||
DEPENDENCIES = ['empty_sensor_hub']
|
||||
|
||||
binary_sensor_ns = cg.esphome_ns.namespace('binary_sensor')
|
||||
BinarySensor = binary_sensor_ns.class_('BinarySensor', binary_sensor.BinarySensor, cg.Nameable)
|
||||
|
||||
CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_id(BinarySensor),
|
||||
cv.GenerateID(CONF_HUB_ID): cv.use_id(EmptySensorHub)
|
||||
}).extend(cv.COMPONENT_SCHEMA)
|
||||
|
||||
def to_code(config):
|
||||
paren = yield cg.get_variable(config[CONF_HUB_ID])
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
|
||||
yield binary_sensor.register_binary_sensor(var, config)
|
||||
|
||||
cg.add(paren.register_binary_sensor(var))
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "empty_sensor_hub.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_sensor_hub {
|
||||
|
||||
static const char *TAG = "empty_sensor_hub.component";
|
||||
|
||||
void EmptySensorHub::setup(){
|
||||
|
||||
}
|
||||
|
||||
void EmptySensorHub::dump_config(){
|
||||
for (auto *sensor : this->sensors_) {
|
||||
LOG_SENSOR(" ", "Sensor", sensor);
|
||||
}
|
||||
|
||||
for(auto *text_sensor : this->text_sensors_){
|
||||
LOG_TEXT_SENSOR(" ", "Text sensor", text_sensor);
|
||||
}
|
||||
|
||||
for(auto *binary_sensor : this->binary_sensors_){
|
||||
LOG_BINARY_SENSOR(" ", "Binary sensor", binary_sensor);
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace empty_sensor_hub
|
||||
} //namespace esphome
|
||||
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
#include "esphome/components/binary_sensor/binary_sensor.h"
|
||||
#include "esphome/components/text_sensor/text_sensor.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_sensor_hub {
|
||||
|
||||
class EmptySensorHub : public Component {
|
||||
public:
|
||||
void register_sensor(sensor::Sensor *obj) { this->sensors_.push_back(obj); }
|
||||
void register_text_sensor(text_sensor::TextSensor *obj) { this->text_sensors_.push_back(obj); }
|
||||
void register_binary_sensor(binary_sensor::BinarySensor *obj) { this->binary_sensors_.push_back(obj); }
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
|
||||
protected:
|
||||
std::vector<sensor::Sensor *> sensors_;
|
||||
std::vector<text_sensor::TextSensor *> text_sensors_;
|
||||
std::vector<binary_sensor::BinarySensor *> binary_sensors_;
|
||||
};
|
||||
|
||||
} //namespace empty_sensor_hub
|
||||
} //namespace esphome
|
||||
@@ -0,0 +1,23 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import sensor
|
||||
from esphome.const import CONF_ID, UNIT_EMPTY, ICON_EMPTY
|
||||
from . import EmptySensorHub, CONF_HUB_ID
|
||||
|
||||
DEPENDENCIES = ['empty_sensor_hub']
|
||||
|
||||
sensor_ns = cg.esphome_ns.namespace('sensor')
|
||||
Sensor = sensor_ns.class_('Sensor', sensor.Sensor, cg.Nameable)
|
||||
|
||||
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_EMPTY, ICON_EMPTY, 1).extend({
|
||||
cv.GenerateID(): cv.declare_id(Sensor),
|
||||
cv.GenerateID(CONF_HUB_ID): cv.use_id(EmptySensorHub)
|
||||
}).extend(cv.COMPONENT_SCHEMA)
|
||||
|
||||
def to_code(config):
|
||||
paren = yield cg.get_variable(config[CONF_HUB_ID])
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
|
||||
yield sensor.register_sensor(var, config)
|
||||
|
||||
cg.add(paren.register_sensor(var))
|
||||
@@ -0,0 +1,23 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import text_sensor
|
||||
from esphome.const import CONF_ID
|
||||
from . import EmptySensorHub, CONF_HUB_ID
|
||||
|
||||
DEPENDENCIES = ['empty_sensor_hub']
|
||||
|
||||
text_sensor_ns = cg.esphome_ns.namespace('text_sensor')
|
||||
TextSensor = text_sensor_ns.class_('TextSensor', text_sensor.TextSensor, cg.Nameable)
|
||||
|
||||
CONFIG_SCHEMA = text_sensor.TEXT_SENSOR_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_id(TextSensor),
|
||||
cv.GenerateID(CONF_HUB_ID): cv.use_id(EmptySensorHub)
|
||||
}).extend(cv.COMPONENT_SCHEMA)
|
||||
|
||||
def to_code(config):
|
||||
paren = yield cg.get_variable(config[CONF_HUB_ID])
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
|
||||
yield text_sensor.register_text_sensor(var, config)
|
||||
|
||||
cg.add(paren.register_text_sensor(var))
|
||||
@@ -0,0 +1,11 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
empty_spi_component:
|
||||
id: empty_spi_component_1
|
||||
cs_pin: D8
|
||||
|
||||
spi:
|
||||
clk_pin: D5
|
||||
miso_pin: D6
|
||||
```
|
||||
@@ -0,0 +1,18 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import spi
|
||||
from esphome.const import CONF_ID
|
||||
|
||||
DEPENDENCIES = ['spi']
|
||||
|
||||
empty_spi_component_ns = cg.esphome_ns.namespace('empty_spi_component')
|
||||
EmptySPIComponent = empty_spi_component_ns.class_('EmptySPIComponent', cg.Component, spi.SPIDevice)
|
||||
|
||||
CONFIG_SCHEMA = cv.Schema({
|
||||
cv.GenerateID(): cv.declare_id(EmptySPIComponent)
|
||||
}).extend(cv.COMPONENT_SCHEMA).extend(spi.spi_device_schema(cs_pin_required=True))
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
yield cg.register_component(var, config)
|
||||
yield spi.register_spi_device(var, config)
|
||||
@@ -0,0 +1,22 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "empty_spi_component.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_spi_component {
|
||||
|
||||
static const char *TAG = "empty_spi_component.component";
|
||||
|
||||
void EmptySPIComponent::setup() {
|
||||
|
||||
}
|
||||
|
||||
void EmptySPIComponent::loop() {
|
||||
|
||||
}
|
||||
|
||||
void EmptySPIComponent::dump_config(){
|
||||
ESP_LOGCONFIG(TAG, "Empty SPI component");
|
||||
}
|
||||
|
||||
} // namespace empty_spi_component
|
||||
} // namespace esphome
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/spi/spi.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_spi_component {
|
||||
|
||||
class EmptySPIComponent : public Component,
|
||||
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST,spi::CLOCK_POLARITY_LOW,
|
||||
spi::CLOCK_PHASE_LEADING,spi::DATA_RATE_1KHZ> {
|
||||
public:
|
||||
void setup() override;
|
||||
void loop() override;
|
||||
void dump_config() override;
|
||||
};
|
||||
|
||||
|
||||
} // namespace empty_spi_component
|
||||
} // namespace esphome
|
||||
@@ -0,0 +1,12 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
sensor:
|
||||
- platform: empty_spi_sensor
|
||||
name: Empty SPI sensor
|
||||
cs_pin: D8
|
||||
|
||||
spi:
|
||||
clk_pin: D5
|
||||
miso_pin: D6
|
||||
```
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "empty_spi_sensor.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_spi_sensor {
|
||||
|
||||
static const char *TAG = "empty_spi_sensor.sensor";
|
||||
|
||||
void EmptySPISensor::setup() {
|
||||
|
||||
}
|
||||
|
||||
void EmptySPISensor::update() {
|
||||
|
||||
}
|
||||
|
||||
void EmptySPISensor::loop() {
|
||||
|
||||
}
|
||||
|
||||
void EmptySPISensor::dump_config(){
|
||||
ESP_LOGCONFIG(TAG, "Empty SPI sensor");
|
||||
}
|
||||
|
||||
} // namespace empty_spi_sensor
|
||||
} // namespace esphome
|
||||
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
#include "esphome/components/spi/spi.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_spi_sensor {
|
||||
|
||||
class EmptySPISensor : public sensor::Sensor,
|
||||
public PollingComponent,
|
||||
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW, spi::CLOCK_PHASE_LEADING,
|
||||
spi::DATA_RATE_1KHZ> {
|
||||
public:
|
||||
void setup() override;
|
||||
void update() override;
|
||||
void loop() override;
|
||||
void dump_config() override;
|
||||
};
|
||||
|
||||
} // namespace empty_spi_sensor
|
||||
} // namespace esphome
|
||||
@@ -0,0 +1,22 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import spi, sensor
|
||||
from esphome.const import CONF_ID, ICON_EMPTY, UNIT_EMPTY
|
||||
|
||||
DEPENDENCIES = ['spi']
|
||||
|
||||
empty_spi_sensor_ns = cg.esphome_ns.namespace('empty_spi_sensor')
|
||||
EmptySPISensor = empty_spi_sensor_ns.class_('EmptySPISensor', cg.PollingComponent,
|
||||
spi.SPIDevice)
|
||||
|
||||
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_EMPTY, ICON_EMPTY, 1).extend({
|
||||
cv.GenerateID(): cv.declare_id(EmptySPISensor),
|
||||
}).extend(cv.polling_component_schema('60s')).extend(spi.spi_device_schema())
|
||||
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
yield cg.register_component(var, config)
|
||||
yield sensor.register_sensor(var, config)
|
||||
yield spi.register_spi_device(var, config)
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
switch:
|
||||
- platform: empty_switch
|
||||
name: Empty switch
|
||||
```
|
||||
@@ -0,0 +1,22 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "empty_switch.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_switch {
|
||||
|
||||
static const char *TAG = "empty_switch.switch";
|
||||
|
||||
void EmptySwitch::setup() {
|
||||
|
||||
}
|
||||
|
||||
void EmptySwitch::write_state(bool state) {
|
||||
|
||||
}
|
||||
|
||||
void EmptySwitch::dump_config(){
|
||||
ESP_LOGCONFIG(TAG, "Empty custom switch");
|
||||
}
|
||||
|
||||
} //namespace empty_switch
|
||||
} //namespace esphome
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/switch/switch.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_switch {
|
||||
|
||||
class EmptySwitch : public switch_::Switch, public Component {
|
||||
public:
|
||||
void setup() override;
|
||||
void write_state(bool state) override;
|
||||
void dump_config() override;
|
||||
};
|
||||
|
||||
} //namespace empty_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_switch_ns = cg.esphome_ns.namespace('empty_switch')
|
||||
EmptySwitch = empty_switch_ns.class_('EmptySwitch', switch.Switch, cg.Component)
|
||||
|
||||
CONFIG_SCHEMA = switch.SWITCH_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_id(EmptySwitch)
|
||||
}).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,7 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
text_sensor:
|
||||
- platform: empty_text_sensor
|
||||
name: Empty text sensor
|
||||
```
|
||||
@@ -0,0 +1,18 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "empty_text_sensor.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_text_sensor {
|
||||
|
||||
static const char *TAG = "empty_text_sensor.text_sensor";
|
||||
|
||||
void EmptyTextSensor::setup() {
|
||||
|
||||
}
|
||||
|
||||
void EmptyTextSensor::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "Empty text sensor");
|
||||
}
|
||||
|
||||
} // namespace empty_text_sensor
|
||||
} // namespace esphome
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/text_sensor/text_sensor.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_text_sensor {
|
||||
|
||||
class EmptyTextSensor : public text_sensor::TextSensor, public Component {
|
||||
public:
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
};
|
||||
|
||||
} // namespace empty_text_sensor
|
||||
} // namespace esphome
|
||||
@@ -0,0 +1,18 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import text_sensor
|
||||
from esphome.const import CONF_ID
|
||||
|
||||
empty_text_sensor_ns = cg.esphome_ns.namespace('empty_text_sensor')
|
||||
EmptyTextSensor = empty_text_sensor_ns.class_('EmptyTextSensor', text_sensor.TextSensor, cg.Component)
|
||||
|
||||
CONFIG_SCHEMA = text_sensor.TEXT_SENSOR_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_id(EmptyTextSensor)
|
||||
}).extend(cv.COMPONENT_SCHEMA)
|
||||
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
yield text_sensor.register_text_sensor(var, config)
|
||||
yield cg.register_component(var, config)
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
empty_uart_component:
|
||||
id: empty_uart_component_1
|
||||
|
||||
uart:
|
||||
tx_pin: D0
|
||||
rx_pin: D1
|
||||
baud_rate: 9600
|
||||
```
|
||||
@@ -0,0 +1,18 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import uart
|
||||
from esphome.const import CONF_ID
|
||||
|
||||
DEPENDENCIES = ['uart']
|
||||
|
||||
empty_uart_component_ns = cg.esphome_ns.namespace('empty_uart_component')
|
||||
EmptyUARTComponent = empty_uart_component_ns.class_('EmptyUARTComponent', cg.Component, uart.UARTDevice)
|
||||
|
||||
CONFIG_SCHEMA = cv.Schema({
|
||||
cv.GenerateID(): cv.declare_id(EmptyUARTComponent)
|
||||
}).extend(cv.COMPONENT_SCHEMA).extend(uart.UART_DEVICE_SCHEMA)
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
yield cg.register_component(var, config)
|
||||
yield uart.register_uart_device(var, config)
|
||||
@@ -0,0 +1,22 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "empty_uart_component.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_uart_component {
|
||||
|
||||
static const char *TAG = "empty_uart_component.component";
|
||||
|
||||
void EmptyUARTComponent::setup() {
|
||||
|
||||
}
|
||||
|
||||
void EmptyUARTComponent::loop() {
|
||||
|
||||
}
|
||||
|
||||
void EmptyUARTComponent::dump_config(){
|
||||
ESP_LOGCONFIG(TAG, "Empty UART component");
|
||||
}
|
||||
|
||||
} // namespace empty_uart_component
|
||||
} // namespace esphome
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/uart/uart.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_uart_component {
|
||||
|
||||
class EmptyUARTComponent : public uart::UARTDevice, public Component {
|
||||
public:
|
||||
void setup() override;
|
||||
void loop() override;
|
||||
void dump_config() override;
|
||||
};
|
||||
|
||||
|
||||
} // namespace empty_uart_component
|
||||
} // namespace esphome
|
||||
@@ -0,0 +1,12 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
sensor:
|
||||
- platform: empty_uart_sensor
|
||||
name: Empty UART sensor
|
||||
|
||||
uart:
|
||||
tx_pin: D0
|
||||
rx_pin: D1
|
||||
baud_rate: 9600
|
||||
```
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "empty_uart_sensor.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_uart_sensor {
|
||||
|
||||
static const char *TAG = "empty_uart_sensor.sensor";
|
||||
|
||||
void EmptyUARTSensor::setup() {
|
||||
|
||||
}
|
||||
|
||||
void EmptyUARTSensor::update() {
|
||||
|
||||
}
|
||||
|
||||
void EmptyUARTSensor::loop() {
|
||||
|
||||
}
|
||||
|
||||
void EmptyUARTSensor::dump_config(){
|
||||
ESP_LOGCONFIG(TAG, "Empty UART sensor");
|
||||
}
|
||||
|
||||
} // namespace empty_UART_sensor
|
||||
} // namespace esphome
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
#include "esphome/components/uart/uart.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_uart_sensor {
|
||||
|
||||
class EmptyUARTSensor : public sensor::Sensor, public PollingComponent, public uart::UARTDevice {
|
||||
public:
|
||||
void setup() override;
|
||||
void update() override;
|
||||
void loop() override;
|
||||
void dump_config() override;
|
||||
};
|
||||
|
||||
} // namespace empty_uart_sensor
|
||||
} // namespace esphome
|
||||
@@ -0,0 +1,20 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import uart, sensor
|
||||
from esphome.const import CONF_ID, ICON_EMPTY, UNIT_EMPTY
|
||||
|
||||
DEPENDENCIES = ['uart']
|
||||
|
||||
empty_uart_sensor_ns = cg.esphome_ns.namespace('empty_uart_sensor')
|
||||
EmptyUARTSensor = empty_uart_sensor_ns.class_('EmptyUARTSensor', cg.PollingComponent, uart.UARTDevice)
|
||||
|
||||
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_EMPTY, ICON_EMPTY, 1).extend({
|
||||
cv.GenerateID(): cv.declare_id(EmptyUARTSensor),
|
||||
}).extend(cv.polling_component_schema('60s')).extend(uart.UART_DEVICE_SCHEMA)
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
yield cg.register_component(var, config)
|
||||
yield sensor.register_sensor(var, config)
|
||||
yield uart.register_uart_device(var, config)
|
||||
|
||||
Reference in New Issue
Block a user