Skip to content

Commit cf8da5d

Browse files
author
xlyric
committed
correction enregistrement HA
1 parent f423469 commit cf8da5d

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

src/config/enums.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -668,9 +668,9 @@ struct HA {
668668
"ids": ")" + String(node_id) + R"(",
669669
"name": ")" + String(node_id) + R"(",
670670
"sw": "PvRouter )" + String(VERSION) + R"(",
671-
"mdl": "ESP32 TTGO )" + IPaddress + R"(",
671+
"mdl": "ESP32 TTGO )" + IPaddress.toString() + R"(",
672672
"mf": "Cyril Poissonnier",
673-
"cu": "http://)" + IPaddress + R"("
673+
"cu": "http://)" + IPaddress.toString() + R"("
674674
})";
675675
return info;
676676
}
@@ -715,14 +715,14 @@ struct HA {
715715
if (dev_cla =="" ) {
716716
dev_cla = name;
717717
}
718-
char final_topic[100];
718+
char final_topic[150];
719719
if (strlen(name.c_str()) != 0 ) {
720-
snprintf(final_topic, sizeof(final_topic), "%s%s/config", topic, name.c_str());
721-
client.publish(final_topic , device.c_str() , true); // déclaration autoconf dimmer
720+
snprintf(final_topic, sizeof(final_topic), "%s%s/config", topic.c_str(), name.c_str());
721+
client.publish(final_topic , device.c_str() , true); // déclaration autoconf routeur
722722
}
723723
else {
724-
snprintf(final_topic, sizeof(final_topic), "%sconfig", topic);
725-
client.publish(final_topic, device.c_str() , true); // déclaration autoconf dimmer
724+
snprintf(final_topic, sizeof(final_topic), "%sconfig", topic.c_str());
725+
client.publish(final_topic, device.c_str() , true); // déclaration autoconf routeur
726726
}
727727
} // discovery
728728

src/functions/Mqtt_http_Functions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ extern HA power_apparent;
4343
extern HA switch_relay1;
4444
extern HA switch_relay2;
4545
extern HA device_dimmer_boost;
46+
extern HA device_dimmer_alarm_temp;
4647
extern xSemaphoreHandle mutex;
4748

4849
//***********************************

src/functions/homeassistant.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
extern HA switch_relay2;
2929
extern HA device_dimmer_boost;
3030
extern HA power_apparent;
31+
extern HA device_dimmer_alarm_temp;
3132
#endif
3233

3334
#ifndef LIGHT_FIRMWARE
@@ -96,6 +97,10 @@
9697
power_apparent.Set_stat_cla("measurement");
9798
power_apparent.Set_dev_cla("apparent_power");
9899

100+
// création des binary_sensor
101+
device_dimmer_alarm_temp.Set_name("Surchauffe");
102+
device_dimmer_alarm_temp.Set_dev_cla("problem");
103+
99104
switch_relay1.Set_name("Relay1");
100105
switch_relay1.Set_dev_cla("switch");
101106

@@ -117,6 +122,9 @@
117122
switch_relay1.discovery();
118123
switch_relay2.discovery();
119124
device_dimmer_boost.discovery();
125+
device_dimmer_alarm_temp.discovery();
126+
device_dimmer_alarm_temp.send("RAS"); // Initialisation de l'état de l'alarme à RAS
127+
120128
}
121129
#endif // not LIGHT_FIRMWARE
122130

src/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ unsigned short measurements[LOCAL_MEASUREMENTS]; // NOSONAR
193193
HA switch_relay1;
194194
HA switch_relay2;
195195
HA device_dimmer_boost;
196+
HA device_dimmer_alarm_temp;
196197
#endif
197198

198199
//***********************************
@@ -752,7 +753,8 @@ void setup()
752753
}
753754
// HA autoconf
754755
if (configmqtt.HA)
755-
init_HA_sensor();
756+
init_HA_sensor();
757+
//Serial.println(F("Home Assistant enabled"));
756758
}
757759
}
758760
#endif // not LIGHT_FIRMWARE

src/tasks/send-mqtt.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,15 @@ void send_to_mqtt(void * parameter) { // NOSONAR
102102
device_dimmer.sendInt(unified_dimmer.get_power()); // Modif RV - pour être plus en accord avec le nommage sur les dimmers
103103
switch_relay1.sendInt(digitalRead(RELAY1));
104104
switch_relay2.sendInt(digitalRead(RELAY2));
105-
device_dimmer_boost.send(stringBool(programme_marche_forcee.run));
105+
device_dimmer_boost.send(stringBool(programme_marche_forcee.run));
106+
// si dallas.security actif alors on envoie l'alarme
107+
if (dallas.security) {
108+
device_dimmer_alarm_temp.send("Ballon Chaud");
109+
}
110+
else {
111+
device_dimmer_alarm_temp.send("RAS");
112+
}
113+
106114
}
107115

108116
// remonté énergie domoticz et jeedom

0 commit comments

Comments
 (0)