HA 0.87 support

- fix https://github.com/toblum/McLighting/issues/327
This commit is contained in:
Debashish Sahu 2019-02-08 16:00:50 -05:00
parent 39a773805e
commit f82e944d5d
2 changed files with 7 additions and 3 deletions

View file

@ -37,7 +37,7 @@ const char HOSTNAME[] = "McLighting01"; // Friedly hostname
#endif
#ifdef MQTT_HOME_ASSISTANT_SUPPORT
#define MQTT_HOME_ASSISTANT_0_84_SUPPORT // Comment if using HA version < 0.84
#define MQTT_HOME_ASSISTANT_0_87_SUPPORT // Comment if using HA version < 0.87
#endif
#if defined(USE_WS2812FX_DMA) and defined(USE_WS2812FX_UART)

View file

@ -1010,14 +1010,16 @@ void checkForRequests() {
DynamicJsonDocument jsonBuffer(JSON_ARRAY_SIZE(strip->getModeCount()) + JSON_OBJECT_SIZE(12) + 1500);
JsonObject json = jsonBuffer.to<JsonObject>();
json["name"] = HOSTNAME;
#ifdef MQTT_HOME_ASSISTANT_0_84_SUPPORT
#ifdef MQTT_HOME_ASSISTANT_0_87_SUPPORT
json["schema"] = "json";
#else
json["platform"] = "mqtt_json";
#endif
json["state_topic"] = mqtt_ha_state_out;
json["command_topic"] = mqtt_ha_state_in;
#ifndef MQTT_HOME_ASSISTANT_0_87_SUPPORT
json["on_command_type"] = "first";
#endif
json["brightness"] = "true";
json["rgb"] = "true";
json["optimistic"] = "false";
@ -1097,14 +1099,16 @@ void checkForRequests() {
DynamicJsonDocument jsonBuffer(JSON_ARRAY_SIZE(strip->getModeCount()) + JSON_OBJECT_SIZE(12) + 1500);
JsonObject json = jsonBuffer.to<JsonObject>();
json["name"] = HOSTNAME;
#ifdef MQTT_HOME_ASSISTANT_0_84_SUPPORT
#ifdef MQTT_HOME_ASSISTANT_0_87_SUPPORT
json["schema"] = "json";
#else
json["platform"] = "mqtt_json";
#endif
json["state_topic"] = mqtt_ha_state_out;
json["command_topic"] = mqtt_ha_state_in;
#ifndef MQTT_HOME_ASSISTANT_0_87_SUPPORT
json["on_command_type"] = "first";
#endif
json["brightness"] = "true";
json["rgb"] = "true";
json["optimistic"] = "false";