Bugfixes
regarding MQTT hostname https://github.com/toblum/McLighting/issues/361#issuecomment-492682506_
This commit is contained in:
@@ -361,18 +361,18 @@ void initMqtt() {
|
|||||||
snprintf(mqtt_clientid, sizeof(mqtt_clientid), "%s", HOSTNAME);
|
snprintf(mqtt_clientid, sizeof(mqtt_clientid), "%s", HOSTNAME);
|
||||||
#endif
|
#endif
|
||||||
mqtt_clientid[sizeof(mqtt_clientid) - 1] = 0x00;
|
mqtt_clientid[sizeof(mqtt_clientid) - 1] = 0x00;
|
||||||
snprintf(mqtt_will_topic, sizeof(mqtt_will_topic), "%s/config", HOSTNAME);
|
snprintf(mqtt_will_topic, sizeof(mqtt_will_topic), "%s/config", mqtt_clientid);
|
||||||
mqtt_will_topic[sizeof(mqtt_will_topic) - 1] = 0x00;
|
mqtt_will_topic[sizeof(mqtt_will_topic) - 1] = 0x00;
|
||||||
snprintf(mqtt_intopic, sizeof(mqtt_intopic), "%s/in", HOSTNAME);
|
snprintf(mqtt_intopic, sizeof(mqtt_intopic), "%s/in", mqtt_clientid);
|
||||||
mqtt_intopic[sizeof(mqtt_intopic) - 1] = 0x00;
|
mqtt_intopic[sizeof(mqtt_intopic) - 1] = 0x00;
|
||||||
snprintf(mqtt_outtopic, sizeof(mqtt_outtopic), "%s/out", HOSTNAME);
|
snprintf(mqtt_outtopic, sizeof(mqtt_outtopic), "%s/out", mqtt_clientid);
|
||||||
mqtt_outtopic[sizeof(mqtt_outtopic) - 1] = 0x00;
|
mqtt_outtopic[sizeof(mqtt_outtopic) - 1] = 0x00;
|
||||||
#if defined(MQTT_HOME_ASSISTANT_SUPPORT)
|
#if defined(MQTT_HOME_ASSISTANT_SUPPORT)
|
||||||
snprintf(mqtt_ha_config, sizeof(mqtt_ha_config), "homeassistant/light/%s/config", HOSTNAME);
|
snprintf(mqtt_ha_config, sizeof(mqtt_ha_config), "homeassistant/light/%s/config", mqtt_clientid);
|
||||||
mqtt_ha_config[sizeof(mqtt_ha_config) - 1] = 0x00;
|
mqtt_ha_config[sizeof(mqtt_ha_config) - 1] = 0x00;
|
||||||
snprintf(mqtt_ha_state_in, sizeof(mqtt_ha_state_in), "home/%s_ha/state/in", HOSTNAME);
|
snprintf(mqtt_ha_state_in, sizeof(mqtt_ha_state_in), "home/%s_ha/state/in", mqtt_clientid);
|
||||||
mqtt_ha_state_in[sizeof(mqtt_ha_state_in) - 1] = 0x00;
|
mqtt_ha_state_in[sizeof(mqtt_ha_state_in) - 1] = 0x00;
|
||||||
snprintf(mqtt_ha_state_out, sizeof(mqtt_ha_state_out), "home/%s_ha/state/out", HOSTNAME);
|
snprintf(mqtt_ha_state_out, sizeof(mqtt_ha_state_out), "home/%s_ha/state/out", mqtt_clientid);
|
||||||
mqtt_ha_state_out[sizeof(mqtt_ha_state_out) - 1] = 0x00;
|
mqtt_ha_state_out[sizeof(mqtt_ha_state_out) - 1] = 0x00;
|
||||||
#endif
|
#endif
|
||||||
if ((strlen(mqtt_host) != 0) && (mqtt_port != 0)) {
|
if ((strlen(mqtt_host) != 0) && (mqtt_port != 0)) {
|
||||||
|
|||||||
@@ -8,11 +8,11 @@
|
|||||||
#define LED_PIN 3 // PIN (15 / D8) where neopixel / WS2811 strip is attached; is configurable, if USE_WS2812FX_DMA is not defined. Just for the start
|
#define LED_PIN 3 // PIN (15 / D8) where neopixel / WS2811 strip is attached; is configurable, if USE_WS2812FX_DMA is not defined. Just for the start
|
||||||
#define NUMLEDS 50 // Number of leds in the; is configurable just for the start
|
#define NUMLEDS 50 // Number of leds in the; is configurable just for the start
|
||||||
#define RGBORDER "GRBW" // RGBOrder; is configurable just for the start
|
#define RGBORDER "GRBW" // RGBOrder; is configurable just for the start
|
||||||
#define FX_OPTIONS 48 // ws2812fx Options 56 = SIZE_SMALL + FADE_MEDIUM is configurable just for the start; for WS2812FX setSegment OPTIONS, see: https://github.com/kitesurfer1404/WS2812FX/blob/master/extras/WS2812FX%20Users%20Guide.md
|
#define FX_OPTIONS 48 // ws2812fx Options 48 = SIZE_SMALL + FADE_MEDIUM is configurable just for the start; for WS2812FX setSegment OPTIONS, see: https://github.com/kitesurfer1404/WS2812FX/blob/master/extras/WS2812FX%20Users%20Guide.md
|
||||||
//#define LED_TYPE_WS2811 // Uncomment, if LED type uses 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
|
//#define LED_TYPE_WS2811 // Uncomment, if LED type uses 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
|
||||||
#define LED_BUILTIN 2 // ESP-12F has the built in LED on GPIO2, see https://github.com/esp8266/Arduino/issues/2192
|
#define LED_BUILTIN 2 // ESP-12F has the built in LED on GPIO2, see https://github.com/esp8266/Arduino/issues/2192
|
||||||
|
|
||||||
char HOSTNAME[65] = "McLightingRGBW"; // Friedly hostname is configurable just for the start
|
char HOSTNAME[65] = "McLightingRGBW"; // Friedly hostname is configurable just for the start. Hostname should not contain spaces as this can break Home Assistant discovery if used.
|
||||||
|
|
||||||
#define ENABLE_OTA 1 // If defined, enable Arduino OTA code. If set to 0 enable Arduino OTA code, if set to 1 enable ESP8266HTTPUpdateServer OTA code.
|
#define ENABLE_OTA 1 // If defined, enable Arduino OTA code. If set to 0 enable Arduino OTA code, if set to 1 enable ESP8266HTTPUpdateServer OTA code.
|
||||||
#define ENABLE_MQTT 1 // If defined use MQTT OR AMQTT, if set to 0 enable MQTT client code, see: https://github.com/toblum/McLighting/wiki/MQTT-API, if set to 1, enable Async MQTT code, see: https://github.com/marvinroger/async-mqtt-client
|
#define ENABLE_MQTT 1 // If defined use MQTT OR AMQTT, if set to 0 enable MQTT client code, see: https://github.com/toblum/McLighting/wiki/MQTT-API, if set to 1, enable Async MQTT code, see: https://github.com/marvinroger/async-mqtt-client
|
||||||
@@ -20,8 +20,11 @@ char HOSTNAME[65] = "McLightingRGBW"; // Friedly hostname is configurable just
|
|||||||
#define ENABLE_HOMEASSISTANT // If defined, enable Homeassistant integration, ENABLE_MQTT must be active
|
#define ENABLE_HOMEASSISTANT // If defined, enable Homeassistant integration, ENABLE_MQTT must be active
|
||||||
#define MQTT_HOME_ASSISTANT_SUPPORT // If defined, use AMQTT and select Tools -> IwIP Variant -> Higher Bandwidth
|
#define MQTT_HOME_ASSISTANT_SUPPORT // If defined, use AMQTT and select Tools -> IwIP Variant -> Higher Bandwidth
|
||||||
#define ENABLE_BUTTON 14 // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control, the value defines the input pin (14 / D5) for switching the LED strip on / off, connect this PIN to ground to trigger button.
|
#define ENABLE_BUTTON 14 // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control, the value defines the input pin (14 / D5) for switching the LED strip on / off, connect this PIN to ground to trigger button.
|
||||||
#define ENABLE_BUTTON_GY33 12 // If defined, enable button handling code for GY-33 color sensor to scan color. The value defines the input pin (12 / D6) for read color data with RGB sensor, connect this PIN to ground to trigger button.
|
//#define ENABLE_BUTTON_GY33 12 // If defined, enable button handling code for GY-33 color sensor to scan color. The value defines the input pin (12 / D6) for read color data with RGB sensor, connect this PIN to ground to trigger button.
|
||||||
#define ENABLE_REMOTE 13 // If defined, enable Remote Control via TSOP31238. The value defines the input pin (13 / D7) for TSOP31238 Out
|
#if defined(ENABLE_BUTTON_GY33)
|
||||||
|
#define GAMMA 2.5 // Gamma correction for GY-33 sensor
|
||||||
|
#endif
|
||||||
|
//#define ENABLE_REMOTE 13 // If defined, enable Remote Control via TSOP31238. The value defines the input pin (13 / D7) for TSOP31238 Out
|
||||||
|
|
||||||
#define ENABLE_STATE_SAVE 1 // If defined, load saved state on reboot and save state. If set to 0 from EEPROM, if set to 1 from SPIFFS
|
#define ENABLE_STATE_SAVE 1 // If defined, load saved state on reboot and save state. If set to 0 from EEPROM, if set to 1 from SPIFFS
|
||||||
|
|
||||||
@@ -34,7 +37,7 @@ char HOSTNAME[65] = "McLightingRGBW"; // Friedly hostname is configurable just
|
|||||||
#if defined(ENABLE_E131)
|
#if defined(ENABLE_E131)
|
||||||
#define MULTICAST false
|
#define MULTICAST false
|
||||||
#define START_UNIVERSE 1 // First DMX Universe to listen for
|
#define START_UNIVERSE 1 // First DMX Universe to listen for
|
||||||
uint8_t END_UNIVERSE = 1; // Total number of Universes to listen for, starting at UNIVERSE
|
uint8_t END_UNIVERSE = START_UNIVERSE; // Total number of Universes to listen for, starting at UNIVERSE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1325,7 +1325,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
const size_t bufferSize = JSON_ARRAY_SIZE(strip->getModeCount()+ 4) + JSON_OBJECT_SIZE(11) + 1500;
|
const size_t bufferSize = JSON_ARRAY_SIZE(strip->getModeCount()+ 4) + JSON_OBJECT_SIZE(11) + 1500;
|
||||||
DynamicJsonDocument jsonBuffer(bufferSize);
|
DynamicJsonDocument jsonBuffer(bufferSize);
|
||||||
JsonObject root = jsonBuffer.to<JsonObject>();
|
JsonObject root = jsonBuffer.to<JsonObject>();
|
||||||
root["name"] = HOSTNAME;
|
root["name"] = mqtt_clientid;
|
||||||
#if defined(MQTT_HOME_ASSISTANT_0_87_SUPPORT)
|
#if defined(MQTT_HOME_ASSISTANT_0_87_SUPPORT)
|
||||||
root["schema"] = "json";
|
root["schema"] = "json";
|
||||||
#else
|
#else
|
||||||
@@ -1438,7 +1438,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
const size_t bufferSize = JSON_ARRAY_SIZE(strip->getModeCount()+ 4) + JSON_OBJECT_SIZE(11) + 1500;
|
const size_t bufferSize = JSON_ARRAY_SIZE(strip->getModeCount()+ 4) + JSON_OBJECT_SIZE(11) + 1500;
|
||||||
DynamicJsonDocument jsonBuffer(bufferSize);
|
DynamicJsonDocument jsonBuffer(bufferSize);
|
||||||
JsonObject root = jsonBuffer.to<JsonObject>();
|
JsonObject root = jsonBuffer.to<JsonObject>();
|
||||||
root["name"] = HOSTNAME;
|
root["name"] = mqtt_clientid;
|
||||||
#if defined(MQTT_HOME_ASSISTANT_0_87_SUPPORT)
|
#if defined(MQTT_HOME_ASSISTANT_0_87_SUPPORT)
|
||||||
root["schema"] = "json";
|
root["schema"] = "json";
|
||||||
#else
|
#else
|
||||||
@@ -1576,7 +1576,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
uint8_t r, g, b, col, conf;
|
uint8_t r, g, b, col, conf;
|
||||||
tcs.getData(&r, &g, &b, &col, &conf);
|
tcs.getData(&r, &g, &b, &col, &conf);
|
||||||
DBG_OUTPUT_PORT.printf("Colors: R: [%d] G: [%d] B: [%d] Color: [%d] Conf: [%d]\r\n", (int)r, (int)g, (int)b, (int)col, (int)conf);
|
DBG_OUTPUT_PORT.printf("Colors: R: [%d] G: [%d] B: [%d] Color: [%d] Conf: [%d]\r\n", (int)r, (int)g, (int)b, (int)col, (int)conf);
|
||||||
main_color.red = (pow((r/255.0), 2.5)*255); main_color.green = (pow((g/255.0), 2.5)*255); main_color.blue = (pow((b/255.0), 2.5)*255);main_color.white = 0;
|
main_color.red = (pow((r/255.0), GAMMA)*255); main_color.green = (pow((g/255.0), GAMMA)*255); main_color.blue = (pow((b/255.0), GAMMA)*255);main_color.white = 0;
|
||||||
ws2812fx_mode = FX_MODE_STATIC;
|
ws2812fx_mode = FX_MODE_STATIC;
|
||||||
prevmode = HOLD;
|
prevmode = HOLD;
|
||||||
mode = SET_ALL;
|
mode = SET_ALL;
|
||||||
@@ -1718,7 +1718,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
checkRGBOrder(tmp_rgbOrder);
|
checkRGBOrder(tmp_rgbOrder);
|
||||||
uint8_t temp_pin;
|
uint8_t temp_pin;
|
||||||
checkPin((uint8_t) root["ws_pin"]);
|
checkPin((uint8_t) root["ws_pin"]);
|
||||||
WS2812FXStripSettings.fxoptions = ((constrain(root["ws_fxopt"].as<uint8_t>(), 0, 255) >> 1) << 1);
|
WS2812FXStripSettings.fxoptions = constrain(root["ws_fxopt"].as<uint8_t>(), 0, 255) && 0xFE;
|
||||||
jsonBuffer.clear();
|
jsonBuffer.clear();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define SKETCH_VERSION "2.2.4.rgbw.3c"
|
#define SKETCH_VERSION "2.2.4.RU1.rgbw.3c"
|
||||||
|
|||||||
@@ -149,4 +149,7 @@
|
|||||||
*
|
*
|
||||||
* 26 Mar 2019
|
* 26 Mar 2019
|
||||||
* Bugfixes
|
* Bugfixes
|
||||||
|
*
|
||||||
|
* 19 May 2010
|
||||||
|
* Bugfixes regarding MQTT Hostname
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user