2022-06-05 10:14:23 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <HAControllableDevice.hpp>
|
|
|
|
|
|
|
|
class HALightController {
|
|
|
|
public:
|
|
|
|
virtual void setState(bool state) = 0;
|
|
|
|
virtual bool getState() = 0;
|
|
|
|
};
|
|
|
|
|
2022-12-30 18:31:20 +03:00
|
|
|
#define JSON_DOCUMENT_TYPE StaticJsonDocument<256>
|
|
|
|
|
2022-06-05 10:14:23 +03:00
|
|
|
class HALight : public HAControllableDevice {
|
|
|
|
private:
|
|
|
|
HALightController *light;
|
|
|
|
|
2022-12-30 18:31:20 +03:00
|
|
|
protected:
|
|
|
|
virtual JSON_DOCUMENT_TYPE createConfigJSON();
|
|
|
|
virtual JSON_DOCUMENT_TYPE createStateJSON();
|
|
|
|
virtual void innerHanlder(JSON_DOCUMENT_TYPE &doc);
|
|
|
|
HALight(PubSubClient &client, const char *name, const char *unique_id);
|
2022-06-05 10:14:23 +03:00
|
|
|
public:
|
|
|
|
HALight(PubSubClient &client, const char *name, const char *unique_id,
|
|
|
|
HALightController &baseLight);
|
|
|
|
void handle(char *topic, byte *payload, unsigned int length);
|
|
|
|
void sendConfig();
|
|
|
|
void sendState();
|
|
|
|
};
|