Added support for MQTT topics "pitrix/cycle_time" (sets the delay between effect changes in 'cycle' mode) and "pitrix/reboot" (send anywthing there to have pitrix reboot).

This commit is contained in:
2019-05-25 23:38:41 +02:00
parent 10098f56fb
commit 7a7c17ede5
2 changed files with 12 additions and 0 deletions

9
mqtt.h
View File

@ -19,6 +19,13 @@ void mqtt_callback(char* topic, byte* payload, unsigned int length) {
config_brightness = new_value;
FastLED.setBrightness(config_brightness);
}
} else if (strcmp(topic, MQTT_TOPIC_EFFECT_CYCLE_TIME)==0) {
long new_value = atol((char *) payload);
if (new_value > 0) {
config_effect_cycle_time = new_value;
}
} else if (strcmp(topic, MQTT_TOPIC_REBOOT)==0) {
ESP.restart();
}
}
@ -30,6 +37,8 @@ boolean mqtt_connect() {
LOGln("MQTT * Connected.");
mqtt_client.subscribe(MQTT_TOPIC_MODE);
mqtt_client.subscribe(MQTT_TOPIC_BRIGHTNESS);
mqtt_client.subscribe(MQTT_TOPIC_EFFECT_CYCLE_TIME);
mqtt_client.subscribe(MQTT_TOPIC_REBOOT);
mqtt_client.publish(MQTT_TOPIC_STATUS, "ONLINE");
}
return mqtt_client.connected();