1212 * A compatible IR RX modules SHOULD be connected to ESP
1313 * if you want to capture & decode IR nessages. e.g. GPIO14 (D5)
1414 * See 'IR_RX' in IRMQTTServer.h.
15- * GPIOs are configurable from the http://<your_esp8266 's_ip_address>/gpio
15+ * GPIOs are configurable from the http://<your_esp 's_ip_address>/gpio
1616 * page.
1717 *
1818 * WARN: This is *very* advanced & complicated example code. Not for beginners.
5656 * https://github.com/tzapu/WiFiManager#how-it-works
5757 *
5858 * If you need to reset the WiFi and saved settings to go back to "First Boot",
59- * visit: http://<your_esp8266 's_ip_address>/reset
59+ * visit: http://<your_esp 's_ip_address>/reset
6060 *
6161 * ## Normal Use (After initial setup)
62- * Enter 'http://<your_esp8266 's_ip_address/' in your browser & follow the
62+ * Enter 'http://<your_esp 's_ip_address/' in your browser & follow the
6363 * instructions there to send IR codes via HTTP/HTML.
64- * Visit the http://<your_esp8266 's_ip_address>/gpio page to configure the GPIOs
64+ * Visit the http://<your_esp 's_ip_address>/gpio page to configure the GPIOs
6565 * for the IR LED(s) and/or IR RX demodulator.
6666 *
6767 * You can send URLs like the following, with similar data type limitations as
6868 * the MQTT formating in the next section. e.g:
69- * http://<your_esp8266 's_ip_address>/ir?type=7&code=E0E09966
70- * http://<your_esp8266 's_ip_address>/ir?type=4&code=0xf50&bits=12
71- * http://<your_esp8266 's_ip_address>/ir?code=C1A2E21D&repeats=8&type=19
72- * http://<your_esp8266 's_ip_address>/ir?type=31&code=40000,1,1,96,24,24,24,48,24,24,24,24,24,48,24,24,24,24,24,48,24,24,24,24,24,24,24,24,1058
73- * http://<your_esp8266 's_ip_address>/ir?type=18&code=190B8050000000E0190B8070000010f0
74- * http://<your_esp8266 's_ip_address>/ir?repeats=1&type=25&code=0000,006E,0022,0002,0155,00AA,0015,0040,0015,0040,0015,0015,0015,0015,0015,0015,0015,0015,0015,0015,0015,0040,0015,0040,0015,0015,0015,0040,0015,0015,0015,0015,0015,0015,0015,0040,0015,0015,0015,0015,0015,0040,0015,0040,0015,0015,0015,0015,0015,0015,0015,0015,0015,0015,0015,0040,0015,0015,0015,0015,0015,0040,0015,0040,0015,0040,0015,0040,0015,0040,0015,0640,0155,0055,0015,0E40
69+ * http://<your_esp 's_ip_address>/ir?type=7&code=E0E09966
70+ * http://<your_esp 's_ip_address>/ir?type=4&code=0xf50&bits=12
71+ * http://<your_esp 's_ip_address>/ir?code=C1A2E21D&repeats=8&type=19
72+ * http://<your_esp 's_ip_address>/ir?type=31&code=40000,1,1,96,24,24,24,48,24,24,24,24,24,48,24,24,24,24,24,48,24,24,24,24,24,24,24,24,1058
73+ * http://<your_esp 's_ip_address>/ir?type=18&code=190B8050000000E0190B8070000010f0
74+ * http://<your_esp 's_ip_address>/ir?repeats=1&type=25&code=0000,006E,0022,0002,0155,00AA,0015,0040,0015,0040,0015,0015,0015,0015,0015,0015,0015,0015,0015,0015,0015,0040,0015,0040,0015,0015,0015,0040,0015,0015,0015,0015,0015,0015,0015,0040,0015,0015,0015,0015,0015,0040,0015,0040,0015,0015,0015,0015,0015,0015,0015,0015,0015,0015,0015,0040,0015,0015,0015,0015,0015,0040,0015,0040,0015,0040,0015,0040,0015,0040,0015,0640,0155,0055,0015,0E40
7575 * If you have enabled more than 1 TX GPIO, you can use the "channel" argument:
76- * http://<your_esp8266 's_ip_address>/ir?channel=0&type=7&code=E0E09966
77- * http://<your_esp8266 's_ip_address>/ir?channel=1&type=7&code=E0E09966
76+ * http://<your_esp 's_ip_address>/ir?channel=0&type=7&code=E0E09966
77+ * http://<your_esp 's_ip_address>/ir?channel=1&type=7&code=E0E09966
7878 *
7979 * or
8080 *
241241 * - "dry"
242242 * - "fan_only"
243243 * fan_modes:
244- * - "auto "
245- * - "min "
246- * - "low "
247- * - "medium "
248- * - "high "
249- * - "max "
244+ * - "Auto "
245+ * - "Min "
246+ * - "Low "
247+ * - "Medium "
248+ * - "High "
249+ * - "Max "
250250 * swing_modes:
251- * - "off "
252- * - "auto "
253- * - "highest "
254- * - "high "
255- * - "middle "
256- * - "low "
257- * - "lowest "
251+ * - "Off "
252+ * - "Auto "
253+ * - "Highest "
254+ * - "High "
255+ * - "Middle "
256+ * - "Low "
257+ * - "Lowest "
258258 * power_command_topic: "ir_server/ac/cmnd/power"
259259 * mode_command_topic: "ir_server/ac/cmnd/mode"
260260 * mode_state_topic: "ir_server/ac/stat/mode"
284284 * first TX GPIO climate. You will need to manually configure the others.
285285 *
286286 * ### via HTTP:
287- * Use the "http://<your_esp8266 's_ip_address>/aircon/set" URL and pass on
287+ * Use the "http://<your_esp 's_ip_address>/aircon/set" URL and pass on
288288 * the arguments as needed to control your device. See the `KEY_*` #defines
289289 * in the code for all the parameters.
290290 * i.e. protocol, model, power, mode, temp, fanspeed, swingv, swingh, quiet,
291291 * turbo, light, beep, econo, sleep, filter, clean, use_celsius, channel
292292 * Example:
293- * http://<your_esp8266 's_ip_address>/aircon/set?channel=0&protocol=PANASONIC_AC&model=LKE&power=on&mode=auto&fanspeed=min&temp=23
293+ * http://<your_esp 's_ip_address>/aircon/set?channel=0&protocol=PANASONIC_AC&model=LKE&power=on&mode=auto&fanspeed=min&temp=23
294294 *
295295 * NOTE: If you don't set the channel, the first GPIO (Channel 0) is used.
296296 *
353353#include < IRremoteESP8266.h>
354354#include < IRrecv.h>
355355#include < IRsend.h>
356+ #include < IRtext.h>
356357#include < IRtimer.h>
357358#include < IRutils.h>
358359#include < IRac.h>
@@ -1181,7 +1182,7 @@ void handleAdmin(void) {
11811182#endif // MQTT_ENABLE
11821183 html += htmlButton (
11831184 kUrlReboot , F (" Reboot" ),
1184- F (" A simple reboot of the ESP8266 . <small>ie. No changes</small><br>"
1185+ F (" A simple reboot of the ESP . <small>ie. No changes</small><br>"
11851186 " <br>" ));
11861187 html += htmlButton (
11871188 kUrlWipe , F (" Wipe Settings" ),
@@ -2514,6 +2515,8 @@ void sendMQTTDiscovery(const char *topic) {
25142515 " \" pow_cmd_t\" :\" ~/" MQTT_CLIMATE_CMND " /" KEY_POWER " \" ,"
25152516 " \" mode_cmd_t\" :\" ~/" MQTT_CLIMATE_CMND " /" KEY_MODE " \" ,"
25162517 " \" mode_stat_t\" :\" ~/" MQTT_CLIMATE_STAT " /" KEY_MODE " \" ,"
2518+ // I don't know why, but the modes need to be lower case to work with
2519+ // Home Assistant & Google Home.
25172520 " \" modes\" :[\" off\" ,\" auto\" ,\" cool\" ,\" heat\" ,\" dry\" ,\" fan_only\" ],"
25182521 " \" temp_cmd_t\" :\" ~/" MQTT_CLIMATE_CMND " /" KEY_TEMP " \" ,"
25192522 " \" temp_stat_t\" :\" ~/" MQTT_CLIMATE_STAT " /" KEY_TEMP " \" ,"
@@ -2522,11 +2525,13 @@ void sendMQTTDiscovery(const char *topic) {
25222525 " \" temp_step\" :\" 1\" ,"
25232526 " \" fan_mode_cmd_t\" :\" ~/" MQTT_CLIMATE_CMND " /" KEY_FANSPEED " \" ,"
25242527 " \" fan_mode_stat_t\" :\" ~/" MQTT_CLIMATE_STAT " /" KEY_FANSPEED " \" ,"
2525- " \" fan_modes\" :[\" auto\" ,\" min\" ,\" low\" ,\" medium\" ,\" high\" ,\" max\" ],"
2528+ " \" fan_modes\" :[\" " D_STR_AUTO " \" ,\" " D_STR_MIN " \" ,\" " D_STR_LOW " \" ,\" "
2529+ D_STR_MEDIUM " \" ,\" " D_STR_HIGH " \" ,\" " D_STR_MAX " \" ],"
25262530 " \" swing_mode_cmd_t\" :\" ~/" MQTT_CLIMATE_CMND " /" KEY_SWINGV " \" ,"
25272531 " \" swing_mode_stat_t\" :\" ~/" MQTT_CLIMATE_STAT " /" KEY_SWINGV " \" ,"
2528- " \" swing_modes\" :["
2529- " \" off\" ,\" auto\" ,\" highest\" ,\" high\" ,\" middle\" ,\" low\" ,\" lowest\" ]"
2532+ " \" swing_modes\" :[\" " D_STR_OFF " \" ,\" " D_STR_AUTO " \" ,\" " D_STR_HIGHEST
2533+ " \" ,\" " D_STR_HIGH " \" ,\" " D_STR_MIDDLE " \" ,\" "
2534+ D_STR_LOW " \" ,\" " D_STR_LOWEST " \" ]"
25302535 " }" ).c_str (), true )) {
25312536 mqttLog (" MQTT climate discovery successful sent." );
25322537 hasDiscoveryBeenSent = true ;
@@ -2961,28 +2966,26 @@ bool sendClimate(const String topic_prefix, const bool retain,
29612966 diff = true ;
29622967 success &= sendInt (topic_prefix + KEY_MODEL , next.model , retain);
29632968 }
2969+ String mode_str = IRac::opmodeToString (next.mode );
2970+ // I don't know why, but the modes need to be lower case to work with
2971+ // Home Assistant & Google Home.
2972+ mode_str.toLowerCase ();
29642973#if MQTT_CLIMATE_HA_MODE
29652974 // Home Assistant want's these two bound together.
29662975 if (prev.power != next.power || prev.mode != next.mode || forceMQTT) {
2967- diff = true ;
29682976 success &= sendBool (topic_prefix + KEY_POWER , next.power , retain);
2969- success &= sendString (topic_prefix + KEY_MODE ,
2970- (next.power ? IRac::opmodeToString (next.mode )
2971- : F (" off" )),
2972- retain);
2973- }
2977+ if (!next.power ) mode_str = F (" off" );
29742978#else // MQTT_CLIMATE_HA_MODE
29752979 // In non-Home Assistant mode, power and mode are not bound together.
29762980 if (prev.power != next.power || forceMQTT) {
29772981 diff = true ;
29782982 success &= sendBool (topic_prefix + KEY_POWER , next.power , retain);
29792983 }
29802984 if (prev.mode != next.mode || forceMQTT) {
2985+ #endif // MQTT_CLIMATE_HA_MODE
2986+ success &= sendString (topic_prefix + KEY_MODE , mode_str, retain);
29812987 diff = true ;
2982- success &= sendString (topic_prefix + KEY_MODE ,
2983- IRac::opmodeToString (next.mode ), retain);
29842988 }
2985- #endif // MQTT_CLIMATE_HA_MODE
29862989 if (prev.degrees != next.degrees || forceMQTT) {
29872990 diff = true ;
29882991 success &= sendFloat (topic_prefix + KEY_TEMP , next.degrees , retain);
0 commit comments