mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 17:27:59 +01:00
using TAG for ESP_LOG
This commit is contained in:
parent
c6caf84377
commit
50821fd22b
4 changed files with 14 additions and 8 deletions
|
@ -26,7 +26,7 @@ CONFIG_SCHEMA = (
|
|||
{
|
||||
cv.GenerateID(): cv.declare_id(OptolinkNumber),
|
||||
cv.Required(CONF_MAX_VALUE): cv.float_,
|
||||
cv.Required(CONF_MIN_VALUE): cv.float_range(min=0.0),
|
||||
cv.Required(CONF_MIN_VALUE): cv.float_range(),
|
||||
cv.Required(CONF_STEP): cv.float_,
|
||||
cv.Required(CONF_ADDRESS): cv.hex_uint32_t,
|
||||
cv.Required(CONF_BYTES): cv.one_of(1, 2, 4, int=True),
|
||||
|
|
|
@ -7,12 +7,14 @@
|
|||
namespace esphome {
|
||||
namespace optolink {
|
||||
|
||||
static const char *const TAG = "optolink.number";
|
||||
|
||||
void OptolinkNumber::control(float value) {
|
||||
if (value > traits.get_max_value() || value < traits.get_min_value()) {
|
||||
set_optolink_state("datapoint value of number %s not in allowed range", get_component_name().c_str());
|
||||
ESP_LOGE("OptolinkNumber", "datapoint value of number %s not in allowed range", get_component_name().c_str());
|
||||
ESP_LOGE(TAG, "datapoint value of number %s not in allowed range", get_component_name().c_str());
|
||||
} else {
|
||||
ESP_LOGI("OptolinkNumber", "control of number %s to value %f", get_component_name().c_str(), value);
|
||||
ESP_LOGI(TAG, "control of number %s to value %f", get_component_name().c_str(), value);
|
||||
write_datapoint_value(value);
|
||||
publish_state(value);
|
||||
}
|
||||
|
|
|
@ -7,17 +7,19 @@
|
|||
namespace esphome {
|
||||
namespace optolink {
|
||||
|
||||
static const char *const TAG = "optolink.select";
|
||||
|
||||
void OptolinkSelect::control(const std::string &value) {
|
||||
for (auto it = mapping_->begin(); it != mapping_->end(); ++it) {
|
||||
if (it->second == value) {
|
||||
ESP_LOGI("OptolinkSelect", "control of select %s to value %s", get_component_name().c_str(), it->first.c_str());
|
||||
ESP_LOGI(TAG, "control of select %s to value %s", get_component_name().c_str(), it->first.c_str());
|
||||
write_datapoint_value(std::stof(it->first));
|
||||
publish_state(it->second);
|
||||
break;
|
||||
}
|
||||
if (it == mapping_->end()) {
|
||||
set_optolink_state("unknown value %s of select %s", value.c_str(), get_component_name().c_str());
|
||||
ESP_LOGE("OptolinkSelect", "unknown value %s of select %s", value.c_str(), get_component_name().c_str());
|
||||
ESP_LOGE(TAG, "unknown value %s of select %s", value.c_str(), get_component_name().c_str());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -26,7 +28,7 @@ void OptolinkSelect::datapoint_value_changed(std::string key) {
|
|||
auto pos = mapping_->find(key);
|
||||
if (pos == mapping_->end()) {
|
||||
set_optolink_state("value %s not found in select %s", key.c_str(), get_component_name().c_str());
|
||||
ESP_LOGE("OptolinkSelect", "value %s not found in select %s", key.c_str(), get_component_name().c_str());
|
||||
ESP_LOGE(TAG, "value %s not found in select %s", key.c_str(), get_component_name().c_str());
|
||||
} else {
|
||||
publish_state(pos->second);
|
||||
}
|
||||
|
|
|
@ -7,12 +7,14 @@
|
|||
namespace esphome {
|
||||
namespace optolink {
|
||||
|
||||
static const char *const TAG = "optolink.switch";
|
||||
|
||||
void OptolinkSwitch::write_state(bool value) {
|
||||
if (value != 0 && value != 1) {
|
||||
set_optolink_state("datapoint value of switch %s not 0 or 1", get_component_name().c_str());
|
||||
ESP_LOGE("OptolinkSwitch", "datapoint value of switch %s not 0 or 1", get_component_name().c_str());
|
||||
ESP_LOGE(TAG, "datapoint value of switch %s not 0 or 1", get_component_name().c_str());
|
||||
} else {
|
||||
ESP_LOGI("OptolinkSwitch", "control of switch %s to value %d", get_component_name().c_str(), value);
|
||||
ESP_LOGI(TAG, "control of switch %s to value %d", get_component_name().c_str(), value);
|
||||
write_datapoint_value((uint8_t) value);
|
||||
publish_state(value);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue