начинает создавать библиотеку HA

This commit is contained in:
2022-06-05 10:14:23 +03:00
parent 283016d424
commit 820aba5fd7
16 changed files with 363 additions and 21 deletions

View File

@@ -0,0 +1,23 @@
#include <HAControllableDevice.hpp>
HAControllableDevice::HAControllableDevice(PubSubClient &client,
const char *device_type,
const char *name,
const char *unique_id)
: HADevice(client, device_type, name, unique_id) {
setupCommandTopic();
}
void HAControllableDevice::setupCommandTopic() {
command_topic_size = strlen(device_topic) + 4 + 1;
command_topic = (char *)malloc(command_topic_size);
strcpy(command_topic, device_topic);
strcat(command_topic, "/cmd");
}
void HAControllableDevice::subscribeToCommandTopic() {
Serial.print("Subscribe to ");
Serial.println(command_topic);
client.subscribe(command_topic);
};