parent
fce81d14a9
commit
54c7dabb67
@ -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,3 @@
|
||||
import esphome.codegen as cg
|
||||
|
||||
empty_custom_fan_ns = cg.esphome_ns.namespace('empty_custom_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_custom_fan_ns
|
||||
|
||||
EmptyCustomFan = empty_custom_fan_ns.class_('EmptyCustomFan', cg.Component)
|
||||
|
||||
CONFIG_SCHEMA = fan.FAN_SCHEMA.extend({
|
||||
cv.GenerateID(CONF_OUTPUT_ID): cv.declare_id(EmptyCustomFan),
|
||||
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,24 @@
|
||||
#include "empty_custom_fan.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_custom_fan {
|
||||
|
||||
static const char *TAG = "empty_custom_fan.fan";
|
||||
|
||||
void EmptyCustomFan::setup() {
|
||||
auto traits = fan::FanTraits(this->oscillating_ != nullptr, false, this->direction_ != nullptr);
|
||||
this->fan_->set_traits(traits);
|
||||
this->fan_->add_on_state_callback([this]() { this->next_update_ = true; });
|
||||
}
|
||||
|
||||
void EmptyCustomFan::loop() {
|
||||
|
||||
}
|
||||
|
||||
void EmptyCustomFan::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "Fan '%s':", this->fan_->get_name().c_str());
|
||||
}
|
||||
|
||||
} // namespace binary
|
||||
} // namespace empty_custom_fan
|
||||
@ -0,0 +1,29 @@
|
||||
#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_custom_fan {
|
||||
|
||||
class EmptyCustomFan : 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;
|
||||
void set_oscillating(output::BinaryOutput *oscillating) { this->oscillating_ = oscillating; }
|
||||
void set_direction(output::BinaryOutput *direction) { this->direction_ = direction; }
|
||||
|
||||
protected:
|
||||
fan::FanState *fan_;
|
||||
output::BinaryOutput *output_;
|
||||
output::BinaryOutput *oscillating_{nullptr};
|
||||
output::BinaryOutput *direction_{nullptr};
|
||||
bool next_update_{true};
|
||||
};
|
||||
|
||||
} // namespace empty_custom_fan
|
||||
} // namespace esphome
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in new issue