mirror of
https://github.com/esphome/esphome.git
synced 2025-09-02 03:12:20 +01:00
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
23 lines
708 B
C++
23 lines
708 B
C++
#include "pipsolar_output.h"
|
|
#include "esphome/core/helpers.h"
|
|
#include "esphome/core/log.h"
|
|
|
|
namespace esphome {
|
|
namespace pipsolar {
|
|
|
|
static const char *const TAG = "pipsolar.output";
|
|
|
|
void PipsolarOutput::write_state(float state) {
|
|
char tmp[10];
|
|
sprintf(tmp, this->set_command_.c_str(), state);
|
|
|
|
if (std::find(this->possible_values_.begin(), this->possible_values_.end(), state) != this->possible_values_.end()) {
|
|
ESP_LOGD(TAG, "Will write: %s out of value %f / %02.0f", tmp, state, state);
|
|
this->parent_->switch_command(std::string(tmp));
|
|
} else {
|
|
ESP_LOGD(TAG, "Will not write: %s as it is not in list of allowed values", tmp);
|
|
}
|
|
}
|
|
} // namespace pipsolar
|
|
} // namespace esphome
|