Skip to content

Commit dcf232c

Browse files
committed
MySensors corrected ID/Battery level for TempHumBaro sensor
1 parent e4d9391 commit dcf232c

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

hardware/MQTT.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,18 @@ void MQTT::OnConnect()
182182
void MQTT::OnMQTTMessage(char *topicName, int topicLen, void *pMessage)
183183
{
184184
MQTTAsync_message *message = (MQTTAsync_message*)pMessage;
185-
185+
if (message->payloadlen < 1)
186+
return;
187+
std::string topic = std::string(topicName, topicName + topicLen);
186188
std::string qMessage = std::string((char*)message->payload, (char*)message->payload + message->payloadlen);
187189

188-
_log.Log(LOG_STATUS, "MQTT: Message: %s", qMessage.c_str());
190+
_log.Log(LOG_STATUS, "MQTT: Topic: %s, Message: %s", topic.c_str(), qMessage.c_str());
191+
192+
if (topic.find("MyMQTT/") != std::string::npos)
193+
{
194+
//MySensors message
195+
_log.Log(LOG_STATUS, "MQTT: MySensors message received!");
196+
}
189197

190198
MQTTAsync_freeMessage(&message);
191199
MQTTAsync_free(topicName);

hardware/MySensorsBase.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ void MySensorsBase::SendSensor2Domoticz(const _tMySensorNode *pNode, const _tMyS
193193
if (pSensorBaro->floatValue < 1010)
194194
forecast = bmpbaroforecast_rain;
195195
}
196-
SendTempHumBaroSensor(pSensor->nodeID, pSensor->childID, pSensor->floatValue, pSensorHum->intvalue, pSensorBaro->floatValue, forecast);
196+
SendTempHumBaroSensor(cNode, pSensor->batValue, pSensor->floatValue, pSensorHum->intvalue, pSensorBaro->floatValue, forecast);
197197
}
198198
}
199199
else if (pSensorHum) {
@@ -225,7 +225,8 @@ void MySensorsBase::SendSensor2Domoticz(const _tMySensorNode *pNode, const _tMyS
225225
{
226226
if (pSensorTemp->bValidValue && pSensorBaro->bValidValue)
227227
{
228-
SendTempHumBaroSensor(pSensorTemp->nodeID, pSensorTemp->childID, pSensorTemp->floatValue, pSensor->intvalue, pSensorBaro->floatValue, forecast);
228+
cNode = (pSensorTemp->nodeID << 8) | pSensorTemp->childID;
229+
SendTempHumBaroSensor(cNode, pSensorTemp->batValue, pSensorTemp->floatValue, pSensor->intvalue, pSensorBaro->floatValue, forecast);
229230
}
230231
}
231232
else if (pSensorTemp) {
@@ -258,7 +259,8 @@ void MySensorsBase::SendSensor2Domoticz(const _tMySensorNode *pNode, const _tMyS
258259
{
259260
if (pSensorTemp->bValidValue && pSensorHum->bValidValue)
260261
{
261-
SendTempHumBaroSensor(pSensorTemp->nodeID, pSensorTemp->childID, pSensorTemp->floatValue, pSensorHum->intvalue, pSensor->floatValue, forecast);
262+
cNode = (pSensorTemp->nodeID << 8) | pSensorTemp->childID;
263+
SendTempHumBaroSensor(cNode, pSensorTemp->batValue, pSensorTemp->floatValue, pSensorHum->intvalue, pSensor->floatValue, forecast);
262264
}
263265
}
264266
else

0 commit comments

Comments
 (0)