ESPHome 2026.3.0
Loading...
Searching...
No Matches
micronova_switch.cpp
Go to the documentation of this file.
1#include "micronova_switch.h"
2
3namespace esphome::micronova {
4
5static const char *const TAG = "micronova.switch";
6
8 LOG_SWITCH("", "Micronova switch", this);
9 this->dump_base_config();
10}
11
13 if (state) {
14 // Only send power-on when current state is Off
15 if (this->raw_state_ == 0) {
16 if (this->micronova_->queue_write_command(this->memory_location_, this->memory_address_, this->memory_data_on_)) {
17 this->publish_state(true);
18 }
19 } else {
20 ESP_LOGW(TAG, "Unable to turn stove on, invalid state: %d", this->raw_state_);
21 }
22 } else {
23 // don't send power-off when status is Off or Final cleaning
24 if (this->raw_state_ != 0 && this->raw_state_ != 6) {
25 if (this->micronova_->queue_write_command(this->memory_location_, this->memory_address_,
26 this->memory_data_off_)) {
27 this->publish_state(false);
28 }
29 } else {
30 ESP_LOGW(TAG, "Unable to turn stove off, invalid state: %d", this->raw_state_);
31 }
32 }
33}
34
36 if (value_from_stove == -1) {
37 ESP_LOGE(TAG, "Error reading stove state");
38 return;
39 }
40 this->raw_state_ = value_from_stove;
41
42 // set the stove switch to on for any value but 0
43 bool state = value_from_stove != 0;
44 this->publish_state(state);
45}
46
47} // namespace esphome::micronova
bool queue_write_command(uint8_t location, uint8_t address, uint8_t data)
Queue a write command to the stove (processed before reads)
void write_state(bool state) override
void process_value_from_stove(int value_from_stove) override
bool state
The current reported state of the binary sensor.
Definition switch.h:55
void publish_state(bool state)
Publish a state to the front-end from the back-end.
Definition switch.cpp:56
bool state
Definition fan.h:2