rename folder

This commit is contained in:
2023-12-17 20:31:18 +01:00
parent 9ee2ee5864
commit 90b58c7e4d
76 changed files with 0 additions and 0 deletions
+33
View File
@@ -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))
+34
View File
@@ -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
+25
View File
@@ -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