#include HALightBrightness::HALightBrightness(PubSubClient &client, const char *name, const char *unique_id, HALightBrightnessController &baseLight) : HALight(client, name, unique_id, baseLight), light(&baseLight) {} JSON_DOCUMENT_TYPE HALightBrightness::patchConfigJSON(JSON_DOCUMENT_TYPE &doc) { doc["brightness"] = true; doc["brightness_scale"] = light->getBrightnessScale(); return doc; } JSON_DOCUMENT_TYPE HALightBrightness::patchStateJSON(JSON_DOCUMENT_TYPE &doc) { doc["brightness"] = light->getBrightness(); return doc; } void HALightBrightness::handleBrightness(const JSON_DOCUMENT_TYPE &doc) { if (doc.containsKey("brightness")) { light->setBrightness(doc["brightness"]); } } void HALightBrightness::innerHandler(const JSON_DOCUMENT_TYPE &doc) { handleBrightness(doc); delay(50); HALight::innerHandler(doc); }