esphome-tw7100/number/tw7100_number.cpp

39 lines
961 B
C++
Raw Permalink Normal View History

2024-09-17 23:06:18 +02:00
#include "../tw7100.h"
#include "tw7100_number.h"
#include "esphome/core/log.h"
#include "esphome/core/defines.h"
#include "esphome/core/helpers.h"
namespace esphome {
namespace tw7100 {
void tw7100Number::setup() {
static const char *const TAG = "tw7100Number::setup()";
ESP_LOGV(TAG, "setup done");
}
void tw7100Number::dump_config() {
static const char *const TAG = "dump_config()";
ESP_LOGCONFIG(TAG, "TW7100:");
LOG_NUMBER(TAG, "tw7100Number", this);
}
void tw7100Number::control(float value) {
static const char *const TAG = "tw7100Number::control()";
std::string param;
2024-09-18 02:00:41 +02:00
param = std::to_string((int)value);
ESP_LOGV(TAG, "%s: %s (from %i)", cmd_, param, (int)value);
2024-09-17 23:06:18 +02:00
if (param.length() > 0 && state != value) {
parent_->push_cmd(cmd_, param);
ESP_LOGV("", "CMD: %s, PARAM: %s", cmd_.c_str(), param.c_str());
}
publish_state(value);
ESP_LOGV(TAG, "control done");
};
} // namespace tw7100
} // namespace esphome