Skip to content

Commit 721c5b8

Browse files
mbronkcrankyoldgit
andauthored
Examples: IRMQTTServer extended with new A/C common fields (#1940)
Adds iFeel/sensorTemp/command support. IRMQTTServer build fix on Windows (naive) bump version number as this is a significant change of operation & functionality Signed-off-by: Mateusz Bronk <[email protected]> Co-authored-by: Mateusz Bronk <[email protected]> Co-authored-by: David Conran <[email protected]>
1 parent ddc9ec1 commit 721c5b8

File tree

2 files changed

+140
-27
lines changed

2 files changed

+140
-27
lines changed

examples/IRMQTTServer/IRMQTTServer.h

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,18 +253,27 @@ const uint16_t kMinUnknownSize = 2 * 10;
253253
#define KEY_JSON "json"
254254
#define KEY_RESEND "resend"
255255
#define KEY_VCC "vcc"
256+
#define KEY_COMMAND "command"
257+
#define KEY_SENSORTEMP "sensortemp"
258+
#define KEY_IFEEL "ifeel"
256259

257260
// HTML arguments we will parse for IR code information.
258261
#define KEY_TYPE "type" // KEY_PROTOCOL is also checked too.
259262
#define KEY_CODE "code"
260263
#define KEY_BITS "bits"
261264
#define KEY_REPEAT "repeats"
262265
#define KEY_CHANNEL "channel" // Which IR TX channel to send on.
266+
#define KEY_SENSORTEMP_DISABLED "sensortemp_disabled" // For HTML form only,
267+
// not sent via MQTT
268+
// nor JSON
263269

264270
// GPIO html/config keys
265271
#define KEY_TX_GPIO "tx"
266272
#define KEY_RX_GPIO "rx"
267273

274+
// Miscellaneous constants
275+
#define TOGGLE_JS_FN_NAME "ToggleInputBasedOnCheckbox"
276+
268277
// Text for Last Will & Testament status messages.
269278
const char* const kLwtOnline = "Online";
270279
const char* const kLwtOffline = "Offline";
@@ -290,7 +299,7 @@ const uint16_t kJsonAcStateMaxSize = 1024; // Bytes
290299
// ----------------- End of User Configuration Section -------------------------
291300

292301
// Constants
293-
#define _MY_VERSION_ "v1.7.2"
302+
#define _MY_VERSION_ "v1.8.0"
294303

295304
const uint8_t kRebootTime = 15; // Seconds
296305
const uint8_t kQuickDisplayTime = 2; // Seconds
@@ -358,7 +367,8 @@ static const char kClimateTopics[] PROGMEM =
358367
"(" KEY_PROTOCOL "|" KEY_MODEL "|" KEY_POWER "|" KEY_MODE "|" KEY_TEMP "|"
359368
KEY_FANSPEED "|" KEY_SWINGV "|" KEY_SWINGH "|" KEY_QUIET "|"
360369
KEY_TURBO "|" KEY_LIGHT "|" KEY_BEEP "|" KEY_ECONO "|" KEY_SLEEP "|"
361-
KEY_FILTER "|" KEY_CLEAN "|" KEY_CELSIUS "|" KEY_RESEND
370+
KEY_FILTER "|" KEY_CLEAN "|" KEY_CELSIUS "|" KEY_RESEND "|" KEY_COMMAND "|"
371+
"|" KEY_SENSORTEMP "|" KEY_IFEEL
362372
#if MQTT_CLIMATE_JSON
363373
"|" KEY_JSON
364374
#endif // MQTT_CLIMATE_JSON
@@ -367,6 +377,7 @@ static const char* const kMqttTopics[] = {
367377
KEY_PROTOCOL, KEY_MODEL, KEY_POWER, KEY_MODE, KEY_TEMP, KEY_FANSPEED,
368378
KEY_SWINGV, KEY_SWINGH, KEY_QUIET, KEY_TURBO, KEY_LIGHT, KEY_BEEP,
369379
KEY_ECONO, KEY_SLEEP, KEY_FILTER, KEY_CLEAN, KEY_CELSIUS, KEY_RESEND,
380+
KEY_COMMAND, KEY_SENSORTEMP, KEY_IFEEL
370381
KEY_JSON}; // KEY_JSON needs to be the last one.
371382

372383

@@ -410,17 +421,22 @@ int8_t getDefaultTxGpio(void);
410421
String genStatTopic(const uint16_t channel = 0);
411422
String listOfTxGpios(void);
412423
bool hasUnsafeHTMLChars(String input);
413-
String htmlHeader(const String title, const String h1_text = "");
424+
String htmlHeader(const String title, const String h1_text = "",
425+
const String headScriptsJS = "");
414426
String htmlEnd(void);
415427
String htmlButton(const String url, const String button,
416428
const String text = "");
417429
String htmlMenu(void);
418430
void handleRoot(void);
419431
String addJsReloadUrl(const String url, const uint16_t timeout_s,
420432
const bool notify);
433+
String getJsToggleCheckbox(const String functionName = TOGGLE_JS_FN_NAME);
421434
void handleExamples(void);
422435
String htmlOptionItem(const String value, const String text, bool selected);
423436
String htmlSelectBool(const String name, const bool def);
437+
String htmlDisableCheckbox(const String name, const String targetControlId,
438+
const bool checked,
439+
const String toggleJsFnName = TOGGLE_JS_FN_NAME);
424440
String htmlSelectClimateProtocol(const String name, const decode_type_t def);
425441
String htmlSelectAcStateProtocol(const String name, const decode_type_t def,
426442
const bool simple);

0 commit comments

Comments
 (0)