initial commit
This commit is contained in:
27
esphome/components/ehmtx/select/__init__.py
Normal file
27
esphome/components/ehmtx/select/__init__.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import select
|
||||
from esphome.const import (
|
||||
CONF_ID,
|
||||
)
|
||||
|
||||
CONF_EHMTX = "ehmtx"
|
||||
select_ns = cg.esphome_ns.namespace("esphome")
|
||||
|
||||
EHMTXSelect = select_ns.class_(
|
||||
"EhmtxSelect", select.Select, cg.PollingComponent
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = cv.All(
|
||||
select.SELECT_SCHEMA.extend(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(EHMTXSelect),
|
||||
}
|
||||
).extend(cv.polling_component_schema("30s")),
|
||||
)
|
||||
|
||||
async def to_code(config):
|
||||
cg.add_define("USE_EHMTX_SELECT")
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
await cg.register_component(var, config)
|
||||
await select.register_select(var, config, options=[])
|
||||
Binary file not shown.
33
esphome/components/ehmtx/select/ehmtx_select.cpp
Normal file
33
esphome/components/ehmtx/select/ehmtx_select.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "ehmtx_select.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
|
||||
static const char *const TAG = "ehmtx.select";
|
||||
|
||||
void EhmtxSelect::setup() {
|
||||
this->publish_state("initializing...");
|
||||
}
|
||||
|
||||
void EhmtxSelect::update() {
|
||||
if (this->parent != NULL) {
|
||||
std::string value;
|
||||
value = this->parent->get_current();
|
||||
this->publish_state(value);
|
||||
}
|
||||
}
|
||||
|
||||
void EhmtxSelect::dump_config() {
|
||||
LOG_SELECT(TAG," ", this);
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
}
|
||||
|
||||
void EhmtxSelect::control(const std::string &value) {
|
||||
// value from HA => check if displayable
|
||||
if (this->parent != NULL) {
|
||||
ESP_LOGD(TAG, "select control to: %s",value.c_str());
|
||||
this->parent->force_screen(value.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace esphome
|
||||
22
esphome/components/ehmtx/select/ehmtx_select.h
Normal file
22
esphome/components/ehmtx/select/ehmtx_select.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome.h"
|
||||
|
||||
namespace esphome {
|
||||
|
||||
class EHMTX;
|
||||
|
||||
class EhmtxSelect : public select::Select, public PollingComponent {
|
||||
public:
|
||||
|
||||
void setup() override;
|
||||
void update() override;
|
||||
void dump_config() override;
|
||||
float get_setup_priority() const override { return setup_priority::LATE; }
|
||||
EHMTX *parent;
|
||||
|
||||
protected:
|
||||
void control(const std::string &value) override;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user