From 77db8c84015350ce46191cf8ca58e2d00e950600 Mon Sep 17 00:00:00 2001 From: Regev Brody Date: Sun, 19 Feb 2023 21:11:21 +0200 Subject: [PATCH] add SUB_BINARY_SENSOR macro (#4447) --- esphome/components/binary_sensor/binary_sensor.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/esphome/components/binary_sensor/binary_sensor.h b/esphome/components/binary_sensor/binary_sensor.h index 730ded3f94..fbfff63a38 100644 --- a/esphome/components/binary_sensor/binary_sensor.h +++ b/esphome/components/binary_sensor/binary_sensor.h @@ -19,6 +19,15 @@ namespace binary_sensor { } \ } +#define SUB_BINARY_SENSOR(name) \ + protected: \ + binary_sensor::BinarySensor *name##_binary_sensor_{nullptr}; \ +\ + public: \ + void set_##name##_binary_sensor(binary_sensor::BinarySensor *binary_sensor) { \ + this->name##_binary_sensor_ = binary_sensor; \ + } + /** Base class for all binary_sensor-type classes. * * This class includes a callback that components such as MQTT can subscribe to for state changes.