Skip to content

Commit

Permalink
Merge pull request #114 from melkati/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
melkati authored Jan 12, 2024
2 parents fd84fdd + 30cd603 commit d836e3a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ Bootlogo
extra_envs.ini
credentials.h

auto_firmware_version.py
platformio_extra_configs.ini
18 changes: 5 additions & 13 deletions CO2_Gadget_MQTT.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ void publishStrMQTT(String topic, String payload) {
void publishStrDiscoveryMQTT(String topic, String payload, int qos) {
#ifdef SUPPORT_MQTT
if (!inMenu) {
Serial.printf("-->[MQTT] Publishing %s to ", payload.c_str());
Serial.println("topic: " + topic);
// Serial.printf("-->[MQTT] Publishing discovery %s to ", payload.c_str());
// Serial.println("topic: " + topic);
mqttClient.publish(topic.c_str(), payload.c_str(), true);
}
#endif
Expand Down Expand Up @@ -191,14 +191,6 @@ bool sendMQTTDiscoveryTopic(String deviceClass, String stateClass, String entity
"}" +
"}";

// Replace the following line with your MQTT publish function
// return MQTTPublish(topicFull, payload, qos, true);
Serial.print("MQTT Publish Topic: ");
Serial.println(topicFull);
Serial.print("MQTT Publish Payload: ");
Serial.println(payload);
// topicFull = "Test";
// payload = "Test";
publishStrDiscoveryMQTT(topicFull, payload, qos);
return true;
}
Expand All @@ -207,7 +199,7 @@ bool publishMQTTDiscovery(int qos) {
bool allSendsSuccessed = false;

if (!mqttClient.connected()) {
Serial.println("Unable to send MQTT Discovery Topics, we are not connected to the MQTT broker!");
Serial.println("-->[MQTT] Unable to send MQTT Discovery Topics, we are not connected to the MQTT broker!");
return false;
}

Expand All @@ -233,7 +225,7 @@ bool publishMQTTDiscovery(int qos) {
// allSendsSuccessed |= sendMQTTDiscoveryTopic("", "", "", "", "problem", "Problem", "alert-outline", "", qos); // Special binary sensor which is based on error topic
// clang-format on

Serial.println("Successfully published all MQTT Discovery topics");
Serial.println("-->[MQTT] Successfully published all MQTT Discovery topics");
return allSendsSuccessed;
}

Expand Down Expand Up @@ -335,7 +327,7 @@ void mqttClientLoop() {
}

if (!mqttDiscoverySent && mqttClient.connected()) {
Serial.printf("-->[MQTT] Connected to broker. Sending discovery...\n");
// Serial.printf("-->[MQTT] Connected to broker. Sending discovery...\n");
publishMQTTDiscovery(0);
mqttDiscoverySent = true;
}
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ build_flags =

-D MQTT_BROKER_SERVER="\"192.168.1.145"\"
-D CO2_GADGET_VERSION="\"0.7."\"
-D CO2_GADGET_REV="\"019"\"
-D CO2_GADGET_REV="\"022"\"
-D CORE_DEBUG_LEVEL=0
-DNEOPIXEL_PIN=26 ; Pinnumber for button for down/next and back / exit actions
-DNEOPIXEL_COUNT=16 ; How many neopixels to control
Expand Down

0 comments on commit d836e3a

Please sign in to comment.