Browse Source

Option to change default payload for HA (#1085)

ech1560
Xose Pérez 6 years ago
parent
commit
13b0279ecc
2 changed files with 12 additions and 4 deletions
  1. +8
    -0
      code/espurna/config/general.h
  2. +4
    -4
      code/espurna/homeassistant.ino

+ 8
- 0
code/espurna/config/general.h View File

@ -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
// -----------------------------------------------------------------------------


+ 4
- 4
code/espurna/homeassistant.ino View File

@ -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


Loading…
Cancel
Save