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:
9
mqtt.h
9
mqtt.h
@ -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();
|
||||
|
Reference in New Issue
Block a user