Use MQTT_TOPIC

This commit is contained in:
Caleb Mah 2020-07-17 00:54:52 +08:00
parent 51a7c2adc5
commit 432755e05d

View File

@ -12,6 +12,8 @@
// PIR sensor pin
const int MOTION_PIN = 16;
// MQTT topic for sensor values
const char MQTT_TOPIC[] = "/motion";
int prevState = LOW;
@ -33,7 +35,7 @@ void publishMqtt(String state)
if (mqtt != nullptr){
char subuf[38];
strcpy(subuf, mqttDeviceTopic);
strcat(subuf, "/kitchen_motion");
strcat(subuf, MQTT_TOPIC);
mqtt->publish(subuf, 0, true, state.c_str());
}
}