From 7dcdf80f4929260471db944012522a14905497c6 Mon Sep 17 00:00:00 2001 From: Regev Brody Date: Mon, 29 May 2023 00:44:35 +0300 Subject: [PATCH] add SUB_SWITCH macro (#4898) --- esphome/components/switch/switch.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/esphome/components/switch/switch.h b/esphome/components/switch/switch.h index 9daac4ee23..b5395a2c83 100644 --- a/esphome/components/switch/switch.h +++ b/esphome/components/switch/switch.h @@ -8,6 +8,13 @@ namespace esphome { namespace switch_ { +#define SUB_SWITCH(name) \ + protected: \ + switch_::Switch *name##_switch_{nullptr}; \ +\ + public: \ + void set_##name##_switch(switch_::Switch *s) { this->name##_switch_ = s; } + // bit0: on/off. bit1: persistent. bit2: inverted. bit3: disabled const int RESTORE_MODE_ON_MASK = 0x01; const int RESTORE_MODE_PERSISTENT_MASK = 0x02;