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:
parent
10098f56fb
commit
7a7c17ede5
@ -22,6 +22,9 @@ uint8_t config_brightness = 20; // Can be overwritten via MQTT_TOPIC_BRIGHTNESS
|
|||||||
#define MQTT_TOPIC_MODE "pitrix/mode"
|
#define MQTT_TOPIC_MODE "pitrix/mode"
|
||||||
#define MQTT_TOPIC_STATUS "pitrix/status"
|
#define MQTT_TOPIC_STATUS "pitrix/status"
|
||||||
#define MQTT_TOPIC_LOG "pitrix/log"
|
#define MQTT_TOPIC_LOG "pitrix/log"
|
||||||
|
#define MQTT_TOPIC_BRIGHTNESS "pitrix/brightness"
|
||||||
|
#define MQTT_TOPIC_EFFECT_CYCLE_TIME "pitrix/cycle_time"
|
||||||
|
#define MQTT_TOPIC_REBOOT "pitrix/reboot"
|
||||||
|
|
||||||
#define HOSTNAME "pitrix-%08X"
|
#define HOSTNAME "pitrix-%08X"
|
||||||
#define OTA_STARTUP_DELAY 5 // How many seconds to wait at startup. Set to 0 to disable.
|
#define OTA_STARTUP_DELAY 5 // How many seconds to wait at startup. Set to 0 to disable.
|
||||||
|
9
mqtt.h
9
mqtt.h
@ -19,6 +19,13 @@ void mqtt_callback(char* topic, byte* payload, unsigned int length) {
|
|||||||
config_brightness = new_value;
|
config_brightness = new_value;
|
||||||
FastLED.setBrightness(config_brightness);
|
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.");
|
LOGln("MQTT * Connected.");
|
||||||
mqtt_client.subscribe(MQTT_TOPIC_MODE);
|
mqtt_client.subscribe(MQTT_TOPIC_MODE);
|
||||||
mqtt_client.subscribe(MQTT_TOPIC_BRIGHTNESS);
|
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");
|
mqtt_client.publish(MQTT_TOPIC_STATUS, "ONLINE");
|
||||||
}
|
}
|
||||||
return mqtt_client.connected();
|
return mqtt_client.connected();
|
||||||
|
Loading…
Reference in New Issue
Block a user