#pragma once #include class HALightController { public: virtual void setState(bool state) = 0; virtual bool getState() = 0; }; #define JSON_DOCUMENT_TYPE StaticJsonDocument<256> class HALight : public HAControllableDevice { private: HALightController *light; protected: virtual JSON_DOCUMENT_TYPE createConfigJSON(); virtual JSON_DOCUMENT_TYPE patchConfigJSON(JSON_DOCUMENT_TYPE &doc); virtual JSON_DOCUMENT_TYPE createStateJSON(); virtual JSON_DOCUMENT_TYPE patchStateJSON(JSON_DOCUMENT_TYPE &doc); virtual void innerHandler(const JSON_DOCUMENT_TYPE &doc); HALight(PubSubClient &client, const char *name, const char *unique_id); public: HALight(PubSubClient &client, const char *name, const char *unique_id, HALightController &baseLight); void handle(char *topic, byte *payload, unsigned int length) override; void sendConfig() override; void sendState() override; };