mirror of
https://github.com/esphome/esphome.git
synced 2024-11-24 16:08:10 +01:00
Combine
This commit is contained in:
parent
35665cc0b9
commit
3dab613b81
4 changed files with 16 additions and 39 deletions
|
@ -71,6 +71,22 @@ class EbyteLoraComponent : public PollingComponent, public uart::UARTDevice {
|
|||
GPIOPin *pin_m1_;
|
||||
pcf8574::PCF8574Component *pcf8574_{nullptr};
|
||||
};
|
||||
class EbyteLoraSwitch : public switch_::Switch, public Component {
|
||||
public:
|
||||
void dump_config() override { LOG_SWITCH("ebyte_lora_switch", "Ebyte Lora Switch", this); }
|
||||
void set_parent(EbyteLoraComponent *parent) { parent_ = parent; }
|
||||
void set_pin(uint8_t pin) { pin_ = pin; }
|
||||
uint8_t get_pin() { return pin_; }
|
||||
void got_state_message(bool state) {
|
||||
ESP_LOGD("ebyte_lora_switch", "Got an update");
|
||||
this->publish_state(state);
|
||||
};
|
||||
|
||||
protected:
|
||||
void write_state(bool state) override { this->parent_->digital_write(this->pin_, state); }
|
||||
EbyteLoraComponent *parent_;
|
||||
uint8_t pin_;
|
||||
};
|
||||
|
||||
} // namespace ebyte_lora
|
||||
} // namespace esphome
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
#include "ebyte_lora_switch.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace ebyte_lora {
|
||||
static const char *const TAG_SWITCH = "ebyte_lora_switch";
|
||||
void EbyteLoraSwitch::write_state(bool state) { this->parent_->digital_write(this->pin_, state); }
|
||||
void EbyteLoraSwitch::dump_config() { LOG_SWITCH(TAG_SWITCH, "Ebyte Lora Switch", this); }
|
||||
} // namespace ebyte_lora
|
||||
} // namespace esphome
|
|
@ -1,30 +0,0 @@
|
|||
#pragma once
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/uart/uart.h"
|
||||
#include "esphome/components/switch/switch.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "../ebyte_lora.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace ebyte_lora {
|
||||
class EbyteLoraSwitch : public switch_::Switch, public Component {
|
||||
public:
|
||||
void dump_config() override;
|
||||
void set_parent(EbyteLoraComponent *parent) { parent_ = parent; }
|
||||
void set_pin(uint8_t pin) { pin_ = pin; }
|
||||
uint8_t get_pin() { return pin_; }
|
||||
void got_state_message(bool state) {
|
||||
ESP_LOGD(TAG, "Got an update");
|
||||
this->publish_state(state);
|
||||
};
|
||||
|
||||
protected:
|
||||
void write_state(bool state) override;
|
||||
EbyteLoraComponent *parent_;
|
||||
uint8_t pin_;
|
||||
};
|
||||
} // namespace ebyte_lora
|
||||
} // namespace esphome
|
Loading…
Reference in a new issue