diff --git a/esphome/components/ebyte_lora/ebyte_lora.h b/esphome/components/ebyte_lora/ebyte_lora.h index 376f9199c6..ab8403c936 100644 --- a/esphome/components/ebyte_lora/ebyte_lora.h +++ b/esphome/components/ebyte_lora/ebyte_lora.h @@ -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 diff --git a/esphome/components/ebyte_lora/switch/__init__.py b/esphome/components/ebyte_lora/switch.py similarity index 100% rename from esphome/components/ebyte_lora/switch/__init__.py rename to esphome/components/ebyte_lora/switch.py diff --git a/esphome/components/ebyte_lora/switch/ebyte_lora_switch.cpp b/esphome/components/ebyte_lora/switch/ebyte_lora_switch.cpp deleted file mode 100644 index ca7da6d642..0000000000 --- a/esphome/components/ebyte_lora/switch/ebyte_lora_switch.cpp +++ /dev/null @@ -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 diff --git a/esphome/components/ebyte_lora/switch/ebyte_lora_switch.h b/esphome/components/ebyte_lora/switch/ebyte_lora_switch.h deleted file mode 100644 index 44e2e59721..0000000000 --- a/esphome/components/ebyte_lora/switch/ebyte_lora_switch.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -#include -#include -#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