mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-19 04:33:27 +02:00
a4867a00ea
* Activate owning-memory clang-tidy check * Lint * Lint * Fix issue with new NfcTag constructor * Update pointers for number and select * Add back the NOLINT to display buffer * Fix merge * DSMR fixes * Nextion fixes * Fix pipsolar * Fix lwip socket * Format * Change socket fix Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
38 lines
1.4 KiB
C++
38 lines
1.4 KiB
C++
#pragma once
|
|
#include "esphome/core/component.h"
|
|
#include "esphome/components/switch/switch.h"
|
|
#include "../nextion_component.h"
|
|
#include "../nextion_base.h"
|
|
|
|
namespace esphome {
|
|
namespace nextion {
|
|
class NextionSwitch;
|
|
|
|
class NextionSwitch : public NextionComponent,
|
|
public switch_::Switch,
|
|
public PollingComponent,
|
|
public std::enable_shared_from_this<NextionSwitch> {
|
|
public:
|
|
NextionSwitch(NextionBase *nextion) { this->nextion_ = nextion; }
|
|
|
|
void update() override;
|
|
void update_component() override { this->update(); }
|
|
void process_bool(const std::string &variable_name, bool on) override;
|
|
|
|
void set_state(bool state) override { this->set_state(state, true, true); }
|
|
void set_state(bool state, bool publish) override { this->set_state(state, publish, true); }
|
|
void set_state(bool state, bool publish, bool send_to_nextion) override;
|
|
|
|
void send_state_to_nextion() override { this->set_state(this->state, false, true); };
|
|
NextionQueueType get_queue_type() override { return NextionQueueType::SWITCH; }
|
|
void set_state_from_string(const std::string &state_value, bool publish, bool send_to_nextion) override {}
|
|
void set_state_from_int(int state_value, bool publish, bool send_to_nextion) override {
|
|
this->set_state(state_value != 0, publish, send_to_nextion);
|
|
}
|
|
|
|
protected:
|
|
void write_state(bool state) override;
|
|
};
|
|
} // namespace nextion
|
|
} // namespace esphome
|