ESPHome 2025.12.3
Loading...
Searching...
No Matches
micronova_switch.cpp
Go to the documentation of this file.
1#include "micronova_switch.h"
2
3namespace esphome::micronova {
4
6 if (state) {
7 // Only send power-on when current state is Off
8 if (this->raw_state_ == 0) {
10 this->publish_state(true);
11 } else {
12 ESP_LOGW(TAG, "Unable to turn stove on, invalid state: %d", this->raw_state_);
13 }
14 } else {
15 // don't send power-off when status is Off or Final cleaning
16 if (this->raw_state_ != 0 && this->raw_state_ != 6) {
18 this->publish_state(false);
19 } else {
20 ESP_LOGW(TAG, "Unable to turn stove off, invalid state: %d", this->raw_state_);
21 }
22 }
23 this->set_needs_update(true);
24}
25
27 this->raw_state_ = value_from_stove;
28 if (value_from_stove == -1) {
29 ESP_LOGE(TAG, "Error reading stove state");
30 return;
31 }
32
33 // set the stove switch to on for any value but 0
34 bool state = value_from_stove != 0;
35 this->publish_state(state);
36}
37
38} // namespace esphome::micronova
void write_address(uint8_t location, uint8_t address, uint8_t data)
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:56
void publish_state(bool state)
Publish a state to the front-end from the back-end.
Definition switch.cpp:57
bool state
Definition fan.h:0