#ifndef DEVICE_H #define DEVICE_H #include #include #include #include #include #include #include const char version[] = "0.0.1"; #define ACTION_TPC "action/state" #define MODE_SET "mode/set" #define MODE_STATE "mode/state" #define TEMP_SET "temp/set" #define TEMP_STATE "temp/state" #define TEMP_CURRENT "temp/current" #define TEMP_HI_SET "temp_hi/set" #define TEMP_HI_STATE "temp_hi/state" #define TEMP_LO_SET "temp_lo/set" #define TEMP_LO_STATE "temp_lo/state" #define ACTION_OFF "off" #define ACTION_HEATING "heating" #define ACTION_COOLING "cooling" #define ACTION_IDLE "idle" #ifndef DEVICE_NAME #define DEVICE_NAME "MQTT Thermostat" #endif #ifndef DEVICE_MDL #define DEVICE_MDL "Thermostat" #endif #ifndef DEVICE_MF #define DEVICE_MF "" #endif #ifndef ROOT #define ROOT "thermostat/" #endif #ifndef CONFIG_ROOT #define CONFIG_ROOT "homeassistant/climate/" #endif #ifndef MSG_RETAIN #define MSG_RETAIN true #endif #define TOPIC_LIMIT 4 typedef void (*ptr)(uint8_t*); //typedef ptr (*pm)(); const size_t DOC_SIZE = JSON_OBJECT_SIZE(29) + JSON_ARRAY_SIZE(4); struct CommandTopic { ptr CmdFunc; String CmdTopic; }; struct ControlDevice { String name; // "Glycol Chiller" String topic_root; // "brewhouse/" CommandTopic command_topics[TOPIC_LIMIT]; }; ptr CmdLookup(String lookup_topic, ControlDevice devices[], int device_count) { for (int i=0;i