diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index c6ea5f58..4e45275f 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -888,6 +888,14 @@ #define HOMEASSISTANT_ENABLED 0 // Integration not enabled by default #define HOMEASSISTANT_PREFIX "homeassistant" // Default MQTT prefix +#ifndef HOMEASSISTANT_PAYLOAD_ON +#define HOMEASSISTANT_PAYLOAD_ON "1" // Payload for ON and available messages +#endif + +#ifndef HOMEASSISTANT_PAYLOAD_OFF +#define HOMEASSISTANT_PAYLOAD_OFF "0" // Payload for OFF and unavailable messages +#endif + // ----------------------------------------------------------------------------- // INFLUXDB // ----------------------------------------------------------------------------- diff --git a/code/espurna/homeassistant.ino b/code/espurna/homeassistant.ino index 9b8c8934..5d725f80 100644 --- a/code/espurna/homeassistant.ino +++ b/code/espurna/homeassistant.ino @@ -73,11 +73,11 @@ void _haSendSwitch(unsigned char i, JsonObject& config) { if (relayCount()) { config["state_topic"] = mqttTopic(MQTT_TOPIC_RELAY, i, false); config["command_topic"] = mqttTopic(MQTT_TOPIC_RELAY, i, true); - config["payload_on"] = String("1"); - config["payload_off"] = String("0"); + config["payload_on"] = String(HOMEASSISTANT_PAYLOAD_ON); + config["payload_off"] = String(HOMEASSISTANT_PAYLOAD_OFF); config["availability_topic"] = mqttTopic(MQTT_TOPIC_STATUS, false); - config["payload_available"] = String("1"); - config["payload_not_available"] = String("0"); + config["payload_available"] = String(HOMEASSISTANT_PAYLOAD_ON); + config["payload_not_available"] = String(HOMEASSISTANT_PAYLOAD_OFF); } #if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE