Use MQTT_TOPIC
This commit is contained in:
parent
51a7c2adc5
commit
432755e05d
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
// PIR sensor pin
|
// PIR sensor pin
|
||||||
const int MOTION_PIN = 16;
|
const int MOTION_PIN = 16;
|
||||||
|
// MQTT topic for sensor values
|
||||||
|
const char MQTT_TOPIC[] = "/motion";
|
||||||
|
|
||||||
int prevState = LOW;
|
int prevState = LOW;
|
||||||
|
|
||||||
@ -33,7 +35,7 @@ void publishMqtt(String state)
|
|||||||
if (mqtt != nullptr){
|
if (mqtt != nullptr){
|
||||||
char subuf[38];
|
char subuf[38];
|
||||||
strcpy(subuf, mqttDeviceTopic);
|
strcpy(subuf, mqttDeviceTopic);
|
||||||
strcat(subuf, "/kitchen_motion");
|
strcat(subuf, MQTT_TOPIC);
|
||||||
mqtt->publish(subuf, 0, true, state.c_str());
|
mqtt->publish(subuf, 0, true, state.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user