From b694bcf62a7e199ceb060612eac10a1ec0a1d7ac Mon Sep 17 00:00:00 2001 From: Hermann Kraus Date: Sun, 1 Nov 2020 02:23:37 +0100 Subject: [PATCH 01/11] Fix MQTT topic parsing. The previous code only looked for certain keywords in the topic instead of comparing it completely. For example if mqttDeviceTopic is set to "lights/colorRGB" the MQTT interface is unusable because the search for "/col" will always return a match and therefore any MQTT command is interpreted as a color. The new code checks the full topic. --- wled00/mqtt.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/wled00/mqtt.cpp b/wled00/mqtt.cpp index 46f49e19e..546d9d06e 100644 --- a/wled00/mqtt.cpp +++ b/wled00/mqtt.cpp @@ -64,18 +64,34 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties } DEBUG_PRINTLN(payload); - //no need to check the topic because we only get topics we are subscribed to + size_t topicPrefixLen = strlen(mqttDeviceTopic); + if (strncmp(topic, mqttDeviceTopic, topicPrefixLen) == 0) { + topic += topicPrefixLen; + } else { + size_t topic_prefix_len = strlen(mqttGroupTopic); + if (strncmp(topic, mqttGroupTopic, topicPrefixLen) == 0) { + topic += topicPrefixLen; + } else { + // Topic not used here. Probably a usermod subscribed to this topic. + return; + } + } - if (strstr(topic, "/col")) + //Prefix is stripped from the topic at this point + + if (strcmp(topic, "/col") == 0) { colorFromDecOrHexString(col, (char*)payload); colorUpdated(NOTIFIER_CALL_MODE_DIRECT_CHANGE); - } else if (strstr(topic, "/api")) + } else if (strcmp(topic, "/api") == 0) { String apireq = "win&"; apireq += (char*)payload; handleSet(nullptr, apireq); - } else parseMQTTBriPayload(payload); + } else if (strcmp(topic, "") == 0) + { + parseMQTTBriPayload(payload); + } } From fe3fb622ee61e0d70dc08e39d2164802dbd60159 Mon Sep 17 00:00:00 2001 From: Hermann Kraus Date: Sun, 1 Nov 2020 16:27:23 +0100 Subject: [PATCH 02/11] New usermod: MQTT switches. This user mod adds a function to toggle output pins via MQTT. --- usermods/mqtt_switch_v2/README.md | 46 ++++++ usermods/mqtt_switch_v2/usermod_mqtt_switch.h | 140 ++++++++++++++++++ 2 files changed, 186 insertions(+) create mode 100644 usermods/mqtt_switch_v2/README.md create mode 100644 usermods/mqtt_switch_v2/usermod_mqtt_switch.h diff --git a/usermods/mqtt_switch_v2/README.md b/usermods/mqtt_switch_v2/README.md new file mode 100644 index 000000000..ec64898dc --- /dev/null +++ b/usermods/mqtt_switch_v2/README.md @@ -0,0 +1,46 @@ +# MQTT controllable switches +This usermod allows controlling switches (e.g. relays) via MQTT. + +## Usermod installation + +1. Copy the file `usermod_mqtt_switch.h` to the `wled00` directory. +2. Register the usermod by adding `#include "usermod_mqtt_switch.h"` in the top and `registerUsermod(new UsermodMqttSwitch());` in the bottom of `usermods_list.cpp`. + + +Example `usermods_list.cpp`: + +``` +#include "wled.h" +#include "usermod_mqtt_switch.h" + +void registerUsermods() +{ + usermods.add(new UsermodMqttSwitch()); +} +``` + +## Define pins +Add a define for MQTTSWITCHPINS to platformio_override.ini. +The following example defines 3 switches connected to the GPIO pins 13, 0 and 2: + +``` +[env:livingroom] +board = esp12e +platform = ${common.platform_wled_default} +board_build.ldscript = ${common.ldscript_4m1m} +build_flags = ${common.build_flags_esp8266} + -D LEDPIN=3 + -D BTNPIN=4 + -D RLYPIN=12 + -D RLYMDE=1 + -D STATUSPIN=15 + -D MQTTSWITCHPINS="13, 0, 2" +``` + +## MQTT topics +This usermod listens on `[mqttDeviceTopic]/switch/0/set` (where 0 is replaced with the index of the switch) for commands. Anything starting with `ON` turns on the switch, everything else turns it off. +Feedback about the current state is provided at `[mqttDeviceTopic]/switch/0/state`. + +### Home Assistant auto-discovery +Auto-discovery information is automatically published and you shoudn't have to do anything to register the switches in Home Assistant. + diff --git a/usermods/mqtt_switch_v2/usermod_mqtt_switch.h b/usermods/mqtt_switch_v2/usermod_mqtt_switch.h new file mode 100644 index 000000000..32b3c1bed --- /dev/null +++ b/usermods/mqtt_switch_v2/usermod_mqtt_switch.h @@ -0,0 +1,140 @@ +#pragma once + +#include "wled.h" +#ifndef WLED_ENABLE_MQTT +#error "This user mod requires MQTT to be enabled." +#endif + +#ifndef MQTTSWITCHPINS +#define MQTTSWITCHPINS 12, 0, 2 +//#error "Please define MQTTSWITCHPINS in platformio_override.ini. e.g. -D MQTTSWITCHPINS="12, 0, 2" " +#endif + + +static const uint8_t switchPins[] = {MQTTSWITCHPINS}; +//This is a hack to get the number of pins defined by the user +#define NUM_SWITCH_PINS (sizeof(switchPins)) + +class UsermodMqttSwitch: public Usermod +{ +private: + bool mqttInitialized; + bool switchState[NUM_SWITCH_PINS]; + +public: + UsermodMqttSwitch() : + mqttInitialized(false) + { + } + + void setup() + { + for (int pinNr = 0; pinNr < NUM_SWITCH_PINS; pinNr++) { + pinMode(switchPins[pinNr], OUTPUT); + setState(pinNr, false); + } + } + + void loop() + { + if (!mqttInitialized) { + mqttInit(); + return; // Try again in next loop iteration + } + } + + void mqttInit() + { + if (!mqtt) + return; + mqtt->onMessage( + std::bind(&UsermodMqttSwitch::onMqttMessage, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, + std::placeholders::_5, std::placeholders::_6)); + mqtt->onConnect(std::bind(&UsermodMqttSwitch::onMqttConnect, this, std::placeholders::_1)); + mqttInitialized = true; + } + + void onMqttConnect(bool sessionPresent); + + void onMqttMessage(char *topic, char *payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total); + void updateState(uint8_t pinNr); + + void setState(uint8_t pinNr, bool active) + { + if (pinNr > NUM_SWITCH_PINS) + return; + switchState[pinNr] = active; + digitalWrite((char) switchPins[pinNr], (char) active); + updateState(pinNr); + } +}; + +inline void UsermodMqttSwitch::onMqttConnect(bool sessionPresent) +{ + if (mqttDeviceTopic[0] == 0) + return; + + for (int pinNr = 0; pinNr < NUM_SWITCH_PINS; pinNr++) { + char buf[128]; + StaticJsonDocument<1024> json; + sprintf(buf, "%s Switch %d", serverDescription, pinNr + 1); + json[F("name")] = buf; + + sprintf(buf, "%s/switch/%d", mqttDeviceTopic, pinNr); + json["~"] = buf; + strcat(buf, "/set"); + mqtt->subscribe(buf, 0); + + json[F("stat_t")] = "~/state"; + json[F("cmd_t")] = "~/set"; + json[F("pl_off")] = F("OFF"); + json[F("pl_on")] = F("ON"); + + char uid[16]; + sprintf(uid, "%s_sw%d", escapedMac.c_str(), pinNr); + json[F("unique_id")] = uid; + + strcpy(buf, mqttDeviceTopic); + strcat(buf, "/status"); + json[F("avty_t")] = buf; + json[F("pl_avail")] = F("online"); + json[F("pl_not_avail")] = F("offline"); + //TODO: dev + sprintf(buf, "homeassistant/switch/%s/config", uid); + char json_str[1024]; + size_t payload_size = serializeJson(json, json_str); + mqtt->publish(buf, 0, true, json_str, payload_size); + updateState(pinNr); + } +} + +inline void UsermodMqttSwitch::onMqttMessage(char *topic, char *payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total) +{ + //Note: Payload is not necessarily null terminated. Check "len" instead. + for (int pinNr = 0; pinNr < NUM_SWITCH_PINS; pinNr++) { + char buf[64]; + sprintf(buf, "%s/switch/%d/set", mqttDeviceTopic, pinNr); + if (strcmp(topic, buf) == 0) { + //Any string starting with "ON" is interpreted as ON, everything else as OFF + setState(pinNr, len >= 2 && payload[0] == 'O' && payload[1] == 'N'); + break; + } + } +} + +inline void UsermodMqttSwitch::updateState(uint8_t pinNr) +{ + if (!mqttInitialized) + return; + + if (pinNr > NUM_SWITCH_PINS) + return; + + char buf[64]; + sprintf(buf, "%s/switch/%d/state", mqttDeviceTopic, pinNr); + if (switchState[pinNr]) { + mqtt->publish(buf, 0, false, "ON"); + } else { + mqtt->publish(buf, 0, false, "OFF"); + } +} From b725d66ee3bf6656537b2216c37a0d5c5e36c5f0 Mon Sep 17 00:00:00 2001 From: Hermann Kraus Date: Sun, 1 Nov 2020 18:08:30 +0100 Subject: [PATCH 03/11] Add options for inverted switches and default values. --- usermods/mqtt_switch_v2/README.md | 8 ++++-- usermods/mqtt_switch_v2/usermod_mqtt_switch.h | 25 ++++++++++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/usermods/mqtt_switch_v2/README.md b/usermods/mqtt_switch_v2/README.md index ec64898dc..dc0e259fb 100644 --- a/usermods/mqtt_switch_v2/README.md +++ b/usermods/mqtt_switch_v2/README.md @@ -21,7 +21,7 @@ void registerUsermods() ## Define pins Add a define for MQTTSWITCHPINS to platformio_override.ini. -The following example defines 3 switches connected to the GPIO pins 13, 0 and 2: +The following example defines 3 switches connected to the GPIO pins 13, 5 and 2: ``` [env:livingroom] @@ -34,8 +34,12 @@ build_flags = ${common.build_flags_esp8266} -D RLYPIN=12 -D RLYMDE=1 -D STATUSPIN=15 - -D MQTTSWITCHPINS="13, 0, 2" + -D MQTTSWITCHPINS="13, 5, 2" ``` + +Pins can be inverted by setting `MQTTSWITCHINVERT`. For example `-D MQTTSWITCHINVERT="false, false, true"` would invert the switch on pin 2 in the previous example. + +The default state after booting before any MQTT message can be set by `MQTTSWITCHDEFAULTS`. For example `-D MQTTSWITCHDEFAULTS="ON, OFF, OFF"` would power on the switch on pin 13 and power off switches on pins 5 and 2. ## MQTT topics This usermod listens on `[mqttDeviceTopic]/switch/0/set` (where 0 is replaced with the index of the switch) for commands. Anything starting with `ON` turns on the switch, everything else turns it off. diff --git a/usermods/mqtt_switch_v2/usermod_mqtt_switch.h b/usermods/mqtt_switch_v2/usermod_mqtt_switch.h index 32b3c1bed..40241206d 100644 --- a/usermods/mqtt_switch_v2/usermod_mqtt_switch.h +++ b/usermods/mqtt_switch_v2/usermod_mqtt_switch.h @@ -6,14 +6,31 @@ #endif #ifndef MQTTSWITCHPINS +#error "Please define MQTTSWITCHPINS in platformio_override.ini. e.g. -D MQTTSWITCHPINS="12, 0, 2" " +// The following define helps Eclipse's C++ parser but is never used in production due to the #error statement on the line before #define MQTTSWITCHPINS 12, 0, 2 -//#error "Please define MQTTSWITCHPINS in platformio_override.ini. e.g. -D MQTTSWITCHPINS="12, 0, 2" " #endif +// Default behavior: All outputs active high +#ifndef MQTTSWITCHINVERT +#define MQTTSWITCHINVERT +#endif -static const uint8_t switchPins[] = {MQTTSWITCHPINS}; +// Default behavior: All outputs off +#ifndef MQTTSWITCHDEFAULTS +#define MQTTSWITCHDEFAULTS +#endif + +static const uint8_t switchPins[] = { MQTTSWITCHPINS }; //This is a hack to get the number of pins defined by the user #define NUM_SWITCH_PINS (sizeof(switchPins)) +static const bool switchInvert[NUM_SWITCH_PINS] = { MQTTSWITCHINVERT}; +//Make settings in config file more readable +#define ON 1 +#define OFF 0 +static const bool switchDefaults[NUM_SWITCH_PINS] = { MQTTSWITCHDEFAULTS}; +#undef ON +#undef OFF class UsermodMqttSwitch: public Usermod { @@ -30,8 +47,8 @@ public: void setup() { for (int pinNr = 0; pinNr < NUM_SWITCH_PINS; pinNr++) { + setState(pinNr, switchDefaults[pinNr]); pinMode(switchPins[pinNr], OUTPUT); - setState(pinNr, false); } } @@ -64,7 +81,7 @@ public: if (pinNr > NUM_SWITCH_PINS) return; switchState[pinNr] = active; - digitalWrite((char) switchPins[pinNr], (char) active); + digitalWrite((char) switchPins[pinNr], (char) (switchInvert[pinNr] ? !active : active)); updateState(pinNr); } }; From aa27b855382e5a90f99fdba06cef179a5fb1d678 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Sun, 1 Nov 2020 20:54:35 +0100 Subject: [PATCH 04/11] Re added old C9 palette --- CHANGELOG.md | 5 +++++ wled00/FX.h | 2 +- wled00/palettes.h | 32 ++++++++++++++++++++++---------- wled00/wled.h | 2 +- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 464e92881..989614c5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ### Development versions after the 0.10.2 release +#### Build 2011010 + +- Re-added previous C9 palette +- Renamed new C9 palette + #### Build 2010290 - Colorful effect now supports palettes diff --git a/wled00/FX.h b/wled00/FX.h index e88445510..6c893692f 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -729,7 +729,7 @@ const char JSON_palette_names[] PROGMEM = R"=====([ "Pastel","Sunset 2","Beech","Vintage","Departure","Landscape","Beach","Sherbet","Hult","Hult 64", "Drywet","Jul","Grintage","Rewhi","Tertiary","Fire","Icefire","Cyane","Light Pink","Autumn", "Magenta","Magred","Yelmag","Yelblu","Orange & Teal","Tiamat","April Night","Orangery","C9","Sakura", -"Aurora","Atlantica","C9 2" +"Aurora","Atlantica","C9 2","C9 New" ])====="; #endif diff --git a/wled00/palettes.h b/wled00/palettes.h index 4fca9525b..30d28433f 100644 --- a/wled00/palettes.h +++ b/wled00/palettes.h @@ -13,7 +13,7 @@ #ifndef PalettesWLED_h #define PalettesWLED_h -#define GRADIENT_PALETTE_COUNT 40 +#define GRADIENT_PALETTE_COUNT 41 const byte ib_jul01_gp[] PROGMEM = { 0, 194, 1, 1, @@ -551,14 +551,14 @@ const byte Orangery_gp[] PROGMEM = { //inspired by Mark Kriegsman https://gist.github.com/kriegsman/756ea6dcae8e30845b5a const byte C9_gp[] PROGMEM = { - 0, 255, 5, 0, //red - 60, 255, 5, 0, - 60, 196, 57, 2, //amber (start 61?) - 120, 196, 57, 2, - 120, 6, 126, 2, //green (start 126?) - 180, 6, 126, 2, - 180, 4, 30, 114, //blue (start 191?) - 255, 4, 30, 114}; + 0, 184, 4, 0, //red + 60, 184, 4, 0, + 65, 144, 44, 2, //amber + 125, 144, 44, 2, + 130, 4, 96, 2, //green + 190, 4, 96, 2, + 195, 7, 7, 88, //blue + 255, 7, 7, 88}; const byte Sakura_gp[] PROGMEM = { 0, 196, 19, 10, @@ -594,6 +594,17 @@ const byte Atlantica_gp[] PROGMEM = { 180, 196, 57, 2, 180, 137, 85, 2, //yellow 255, 137, 85, 2}; + + //C9, but brighter and with a less purple blue + const byte C9_new_gp[] PROGMEM = { + 0, 255, 5, 0, //red + 60, 255, 5, 0, + 60, 196, 57, 2, //amber (start 61?) + 120, 196, 57, 2, + 120, 6, 126, 2, //green (start 126?) + 180, 6, 126, 2, + 180, 4, 30, 114, //blue (start 191?) + 255, 4, 30, 114}; // Single array of defined cpt-city color palettes. @@ -640,7 +651,8 @@ const byte* const gGradientPalettes[] PROGMEM = { Sakura_gp, //49-36 Sakura Aurora_gp, //50-37 Aurora Atlantica_gp, //51-38 Atlantica - C9_2_gp //52-39 C9 2 + C9_2_gp, //52-39 C9 2 + C9_new_gp //53-40 C9 New }; #endif diff --git a/wled00/wled.h b/wled00/wled.h index 4df774037..aae7e8c6a 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2010280 +#define VERSION 2011010 // ESP8266-01 (blue) got too little storage space to work with all features of WLED. To use it, you must use ESP8266 Arduino Core v2.4.2 and the setting 512K(No SPIFFS). From b8fcab29ac180ca12e6a1d81870133274051275b Mon Sep 17 00:00:00 2001 From: cschwinne Date: Wed, 4 Nov 2020 23:20:34 +0100 Subject: [PATCH 05/11] Inversed Rain direction (fixes #1147) --- CHANGELOG.md | 4 ++++ wled00/FX.cpp | 10 +++++----- wled00/wled.h | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 989614c5a..dbbb98f2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ### Development versions after the 0.10.2 release +#### Build 2011040 + +- Inversed Rain direction (fixes #1147) + #### Build 2011010 - Re-added previous C9 palette diff --git a/wled00/FX.cpp b/wled00/FX.cpp index ae59d8019..5ad5de2e0 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -1128,12 +1128,12 @@ uint16_t WS2812FX::mode_rain() SEGENV.step += FRAMETIME; if (SEGENV.step > SPEED_FORMULA_L) { SEGENV.step = 0; - //shift all leds right - uint32_t ctemp = getPixelColor(SEGLEN -1); - for(uint16_t i = SEGLEN -1; i > 0; i--) { - setPixelColor(i, getPixelColor(i-1)); + //shift all leds left + uint32_t ctemp = getPixelColor(0); + for(uint16_t i = 0; i < SEGLEN - 1; i++) { + setPixelColor(i, getPixelColor(i+1)); } - setPixelColor(0, ctemp); + setPixelColor(SEGLEN -1, ctemp); SEGENV.aux0++; SEGENV.aux1++; if (SEGENV.aux0 == 0) SEGENV.aux0 = UINT16_MAX; diff --git a/wled00/wled.h b/wled00/wled.h index aae7e8c6a..55bdb7282 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2011010 +#define VERSION 2011040 // ESP8266-01 (blue) got too little storage space to work with all features of WLED. To use it, you must use ESP8266 Arduino Core v2.4.2 and the setting 512K(No SPIFFS). From bcee2c37d7f0940eceac3956a5ea323a9553b26c Mon Sep 17 00:00:00 2001 From: Jeff Sloyer Date: Thu, 5 Nov 2020 14:54:57 -0500 Subject: [PATCH 06/11] correct the copyright year and add a link to the license --- wled00/html_settings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled00/html_settings.h b/wled00/html_settings.h index e17deb117..0424267ea 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -368,7 +368,7 @@ HTTP traffic is unencrypted. An attacker in the same network can intercept form href="https://github.com/Aircoookie/WLED/wiki/Contributors-&-About" target="_blank">Contributors, dependencies and special thanks
A huge thank you to everyone who helped me create WLED!

-(c) 2016-2019 Christian Schwinne
Licensed under the MIT license
+(c) 2016-2020 Christian Schwinne
Licensed under the MIT license

Server message: Response error!
)====="; From 8d318e7206203e70a7fd05ec56900f5802b24b2d Mon Sep 17 00:00:00 2001 From: Chris AtLee Date: Fri, 30 Oct 2020 15:18:27 -0400 Subject: [PATCH 07/11] Return remaining nightlight time in json API This returns the number of seconds remaining in the nightlight in the "rem" field of the nightlight ("nl") state. If there is no nightlight active, it returns -1. --- wled00/json.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wled00/json.cpp b/wled00/json.cpp index 62c6a334d..74217b100 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -318,7 +318,12 @@ void serializeState(JsonObject root) nl[F("fade")] = (nightlightMode > NL_MODE_SET); //deprecated nl[F("mode")] = nightlightMode; nl[F("tbri")] = nightlightTargetBri; - + if (nightlightActive) { + nl[F("rem")] = (nightlightDelayMs - (millis() - nightlightStartTime)) / 1000; // seconds remaining + } else { + nl[F("rem")] = -1; + } + JsonObject udpn = root.createNestedObject("udpn"); udpn[F("send")] = notifyDirect; udpn[F("recv")] = receiveNotifications; @@ -326,7 +331,7 @@ void serializeState(JsonObject root) root[F("lor")] = realtimeOverride; root[F("mainseg")] = strip.getMainSegmentId(); - + JsonArray seg = root.createNestedArray("seg"); for (byte s = 0; s < strip.getMaxSegments(); s++) { From bdf04587800c54a1e4a5f9da5ee3523223fecd35 Mon Sep 17 00:00:00 2001 From: e850205 <46200695+e850205@users.noreply.github.com> Date: Mon, 9 Nov 2020 13:14:24 -0600 Subject: [PATCH 08/11] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index a2e94a69f..922d9f950 100644 --- a/readme.md +++ b/readme.md @@ -11,7 +11,7 @@ # Welcome to my project WLED! ✨ -A fast and feature-rich implementation of an ESP8266/ESP32 webserver to control NeoPixel (WS2812B, WS2811, SK6812, APA102) LEDs or also SPI based chipsets like the WS2801! +A fast and feature-rich implementation of an ESP8266/ESP32 webserver to control NeoPixel (WS2812B, WS2811, SK6812) LEDs or also SPI based chipsets like the WS2801 and APA102! ## ⚙️ Features - WS2812FX library integrated for over 100 special effects From ed753b590ca6c63fa4b03c75c9b1231a6c57a57b Mon Sep 17 00:00:00 2001 From: cschwinne Date: Tue, 10 Nov 2020 13:30:42 +0100 Subject: [PATCH 09/11] Add copyright and license link to .htm --- wled00/data/settings_sec.htm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wled00/data/settings_sec.htm b/wled00/data/settings_sec.htm index 08d9427f6..6a860e6b4 100644 --- a/wled00/data/settings_sec.htm +++ b/wled00/data/settings_sec.htm @@ -48,8 +48,8 @@ WLED version ##VERSION##

Contributors, dependencies and special thanks
A huge thank you to everyone who helped me create WLED!

- (c) 2016-2019 Christian Schwinne
- Licensed under the MIT license

+ (c) 2016-2020 Christian Schwinne
+ Licensed under the MIT license

Server message: Response error!
From 1b3ed80d375533f8cabf03242b6e35f53ff9b87c Mon Sep 17 00:00:00 2001 From: Aircoookie Date: Tue, 10 Nov 2020 23:36:28 +0100 Subject: [PATCH 10/11] Replace readme tutorials with link to tutorial overview wiki page --- readme.md | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/readme.md b/readme.md index 922d9f950..c3a1f2add 100644 --- a/readme.md +++ b/readme.md @@ -47,15 +47,7 @@ A fast and feature-rich implementation of an ESP8266/ESP32 webserver to control See the [wiki](https://github.com/Aircoookie/WLED/wiki)! -DrZzs has made some excellent video guides: -[Introduction, hardware and installation](https://www.youtube.com/watch?v=tXvtxwK3jRk) -[Settings, tips and tricks](https://www.youtube.com/watch?v=6eCE2BpLaUQ) - -If you'd rather read, here is a very [detailed step-by-step beginner tutorial](https://tynick.com/blog/11-03-2019/getting-started-with-wled-on-esp8266/) by tynick! - -Russian speakers, check out the videos by Room31: -[WLED Firmware Overview: Interface and Settings](https://youtu.be/h7lKsczEI7E) -[ESP8266 based LED controller for WS2812b strip. WLED Firmware + OpenHAB](https://youtu.be/K4ioTt3XvGc) +[On this page](https://github.com/Aircoookie/WLED/wiki/Learning-the-ropes) you can find excellent tutorials made by the community and helpful tools to help you get your new lamp up and running! ## 🖼️ Images From 560f72a320f5a3c75f649c82c022dfdac4f339bc Mon Sep 17 00:00:00 2001 From: cschwinne Date: Thu, 12 Nov 2020 09:13:08 +0100 Subject: [PATCH 11/11] Add JSON receiving to MQTT /api --- CHANGELOG.md | 4 ++++ wled00/mqtt.cpp | 12 +++++++++--- wled00/wled.h | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dbbb98f2d..4581c0ab4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ### Development versions after the 0.10.2 release +#### Build 2011120 + +- Added the ability for the /api MQTT topic to receive JSON API payloads + #### Build 2011040 - Inversed Rain direction (fixes #1147) diff --git a/wled00/mqtt.cpp b/wled00/mqtt.cpp index 546d9d06e..15cb0c5df 100644 --- a/wled00/mqtt.cpp +++ b/wled00/mqtt.cpp @@ -85,9 +85,15 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties colorUpdated(NOTIFIER_CALL_MODE_DIRECT_CHANGE); } else if (strcmp(topic, "/api") == 0) { - String apireq = "win&"; - apireq += (char*)payload; - handleSet(nullptr, apireq); + if (payload[0] == '{') { //JSON API + DynamicJsonDocument doc(JSON_BUFFER_SIZE); + deserializeJson(doc, payload); + deserializeState(doc.as()); + } else { //HTTP API + String apireq = "win&"; + apireq += (char*)payload; + handleSet(nullptr, apireq); + } } else if (strcmp(topic, "") == 0) { parseMQTTBriPayload(payload); diff --git a/wled00/wled.h b/wled00/wled.h index 55bdb7282..064a1f2b0 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2011040 +#define VERSION 2011120 // ESP8266-01 (blue) got too little storage space to work with all features of WLED. To use it, you must use ESP8266 Arduino Core v2.4.2 and the setting 512K(No SPIFFS).