1
0
mirror of https://github.com/esphome/esphome.git synced 2025-04-15 07:10:33 +01:00
esphome/esphome/components/optolink/switch/optolink_switch.cpp

25 lines
670 B
C++

#ifdef USE_ARDUINO
#include "optolink_switch.h"
#include "../optolink.h"
#include "VitoWiFi.h"
namespace esphome {
namespace optolink {
void OptolinkSwitch::write_state(bool value) {
if (value != 0 && value != 1) {
optolink_->set_error("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());
} else {
ESP_LOGI("OptolinkSwitch", "control of switch %s to value %d", get_component_name().c_str(), value);
update_datapoint((uint8_t) value);
publish_state(value);
}
};
} // namespace optolink
} // namespace esphome
#endif