Browse Source

don't add discovery info on generated yaml

rules-rpn
abmantis 5 years ago
parent
commit
0424610b87
1 changed files with 14 additions and 11 deletions
  1. +14
    -11
      code/espurna/homeassistant.ino

+ 14
- 11
code/espurna/homeassistant.ino View File

@ -38,9 +38,11 @@ void _haSendMagnitude(unsigned char i, const JsonObject& deviceConfig, JsonObjec
config.set("platform", "mqtt"); config.set("platform", "mqtt");
config["state_topic"] = mqttTopic(magnitudeTopicIndex(i).c_str(), false); config["state_topic"] = mqttTopic(magnitudeTopicIndex(i).c_str(), false);
config["unit_of_measurement"] = magnitudeUnits(type); config["unit_of_measurement"] = magnitudeUnits(type);
config["uniq_id"] = getIdentifier() + "_" + type + "_" + String(i);
config["device"] = deviceConfig;
if (deviceConfig.size() > 0) {
config["uniq_id"] = getIdentifier() + "_" + type + "_" + String(i);
config["device"] = deviceConfig;
}
} }
void _haSendMagnitudes(const JsonObject& deviceConfig) { void _haSendMagnitudes(const JsonObject& deviceConfig) {
@ -84,8 +86,10 @@ void _haSendSwitch(unsigned char i, const JsonObject& deviceConfig, JsonObject&
config.set("name", _haFixName(name)); config.set("name", _haFixName(name));
config.set("platform", "mqtt"); config.set("platform", "mqtt");
config["uniq_id"] = getIdentifier() + "_switch_" + String(i);
config["device"] = deviceConfig;
if (deviceConfig.size() > 0) {
config["uniq_id"] = getIdentifier() + "_switch_" + String(i);
config["device"] = deviceConfig;
}
if (relayCount()) { if (relayCount()) {
config["state_topic"] = mqttTopic(MQTT_TOPIC_RELAY, i, false); config["state_topic"] = mqttTopic(MQTT_TOPIC_RELAY, i, false);
@ -156,8 +160,7 @@ void _haSendSwitches(const JsonObject& deviceConfig) {
void _haDumpConfig(std::function<void(String&)> printer, bool wrapJson = false) { void _haDumpConfig(std::function<void(String&)> printer, bool wrapJson = false) {
DynamicJsonBuffer deviceConfigJsonBuffer; DynamicJsonBuffer deviceConfigJsonBuffer;
JsonObject& deviceConfig = deviceConfigJsonBuffer.createObject();
_haGetDeviceConfig(deviceConfig);
JsonObject& emptyDeviceConfig = deviceConfigJsonBuffer.createObject();
#if (LIGHT_PROVIDER != LIGHT_PROVIDER_NONE) || (defined(ITEAD_SLAMPHER)) #if (LIGHT_PROVIDER != LIGHT_PROVIDER_NONE) || (defined(ITEAD_SLAMPHER))
String type = String("light"); String type = String("light");
@ -169,7 +172,7 @@ void _haDumpConfig(std::function<void(String&)> printer, bool wrapJson = false)
DynamicJsonBuffer jsonBuffer; DynamicJsonBuffer jsonBuffer;
JsonObject& config = jsonBuffer.createObject(); JsonObject& config = jsonBuffer.createObject();
_haSendSwitch(i, deviceConfig, config);
_haSendSwitch(i, emptyDeviceConfig, config);
String output; String output;
output.reserve(config.measureLength() + 32); output.reserve(config.measureLength() + 32);
@ -211,7 +214,7 @@ void _haDumpConfig(std::function<void(String&)> printer, bool wrapJson = false)
DynamicJsonBuffer jsonBuffer; DynamicJsonBuffer jsonBuffer;
JsonObject& config = jsonBuffer.createObject(); JsonObject& config = jsonBuffer.createObject();
_haSendMagnitude(i, deviceConfig, config);
_haSendMagnitude(i, emptyDeviceConfig, config);
String output; String output;
output.reserve(config.measureLength() + 32); output.reserve(config.measureLength() + 32);
@ -259,9 +262,9 @@ void _haGetDeviceConfig(JsonObject& config) {
config.createNestedArray("identifiers").add(identifier); config.createNestedArray("identifiers").add(identifier);
config["name"] = _haFixName(getSetting("hostname")); config["name"] = _haFixName(getSetting("hostname"));
config["manufacturer"] = String("Espurna");
config["model"] = getBoardName();
config["sw_version"] = String(APP_VERSION) + " (" + getCoreVersion() + ")";
config["manufacturer"] = String(MANUFACTURER);
config["model"] = String(DEVICE);
config["sw_version"] = String(APP_NAME) + " " + String(APP_VERSION) + " (" + getCoreVersion() + ")";
} }
void _haSend() { void _haSend() {


Loading…
Cancel
Save