From 432755e05dad52d952c46afbae4fc2cba46372f5 Mon Sep 17 00:00:00 2001 From: Caleb Mah Date: Fri, 17 Jul 2020 00:54:52 +0800 Subject: [PATCH] Use MQTT_TOPIC --- usermods/PIR_sensor_mqtt_v1/usermod.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usermods/PIR_sensor_mqtt_v1/usermod.cpp b/usermods/PIR_sensor_mqtt_v1/usermod.cpp index 117b7c71..426a8033 100644 --- a/usermods/PIR_sensor_mqtt_v1/usermod.cpp +++ b/usermods/PIR_sensor_mqtt_v1/usermod.cpp @@ -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()); } }