mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-13 16:13:32 +02:00
Add Micronova component (#4760)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Co-authored-by: Graham Brown <grahambrown11@gmail.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#include "micronova_switch.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace micronova {
|
||||
|
||||
void MicroNovaSwitch::write_state(bool state) {
|
||||
switch (this->get_function()) {
|
||||
case MicroNovaFunctions::STOVE_FUNCTION_SWITCH:
|
||||
if (state) {
|
||||
// Only send power-on when current state is Off
|
||||
if (this->micronova_->get_current_stove_state() == 0) {
|
||||
this->micronova_->write_address(this->memory_location_, this->memory_address_, this->memory_data_on_);
|
||||
this->publish_state(true);
|
||||
} else
|
||||
ESP_LOGW(TAG, "Unable to turn stove on, invalid state: %d", micronova_->get_current_stove_state());
|
||||
} else {
|
||||
// don't send power-off when status is Off or Final cleaning
|
||||
if (this->micronova_->get_current_stove_state() != 0 && micronova_->get_current_stove_state() != 6) {
|
||||
this->micronova_->write_address(this->memory_location_, this->memory_address_, this->memory_data_off_);
|
||||
this->publish_state(false);
|
||||
} else
|
||||
ESP_LOGW(TAG, "Unable to turn stove off, invalid state: %d", micronova_->get_current_stove_state());
|
||||
}
|
||||
this->micronova_->update();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace micronova
|
||||
} // namespace esphome
|
||||
Reference in New Issue
Block a user