its a class now

This commit is contained in:
Drath
2025-09-13 14:18:38 +02:00
parent 16588cb9a9
commit 26a8056693
2 changed files with 56 additions and 40 deletions

View File

@@ -8,13 +8,27 @@
#include <print>
#include <string>
#define HASS_ADDRESS "home.drath.win"
#define HASS_TOKEN "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI0MzUxMTZiY2VjNTg0MTI3OGI4YmU0NTY4ZGQ5MzIyYiIsImlhdCI6MTc1NzQzMDI0MCwiZXhwIjoyMDcyNzkwMjQwfQ.6wKTlxEA0FLWfv-qW35vewUSvTxdVrZWqFwHT5Khu6E"
#define HASS_ENTITY "sensor.gniazdko_komputer_moc"
int hass_connect();
void hass_service(int timeout_ms = 0);
float hass_get();
void hass_disconnect();
class HomeAssistant {
private:
std::string address;
std::string entity;
uint16_t id = 2;
std::string tx;
struct lws_context *context = NULL;
lws *websock = NULL;
void event_handler(struct lws *wsi, enum lws_callback_reasons reason, char *in);
static int callback(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len);
public:
HomeAssistant(std::string addr, std::string ent);
~HomeAssistant();
float state = 0.0f;
int connect();
void service(int timeout_ms = 0);
void disconnect();
};
#endif