Skip to content

Commit 8af3b17

Browse files
committed
Gateway restart through MQTT
1 parent 290528a commit 8af3b17

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

docs/mqtt.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ Main settings:
4848

4949
`<base-topic>/divertmode/set [1 | 2]` : enable (1)/ disable (2) divert mode
5050
`<base-topic>/shaper/set [0 | 1]` : temporary enable (1)/ disable (0) current shaper ( doesn't survive reboot )
51+
`<base-topic>/restart` : restarts the gateway
52+
5153

5254

5355
MQTT setup is pre-populated with OpenEnergyMonitor [emonPi default MQTT server credentials](https://guide.openenergymonitor.org/technical/credentials/#mqtt).

src/mqtt.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ void mqttmsg_callback(MongooseString topic, MongooseString payload) {
183183
mqtt_clear_schedule(payload_str.toInt());
184184
}
185185

186+
// Restart
187+
else if (topic_string == mqtt_topic + "/restart") {
188+
restart_system();
189+
}
190+
186191
else
187192
{
188193
// If MQTT message is RAPI command
@@ -360,6 +365,12 @@ mqtt_connect()
360365
mqtt_sub_topic = mqtt_topic + "/schedule/clear";
361366
mqttclient.subscribe(mqtt_sub_topic);
362367
yield();
368+
369+
// ask for a system restart
370+
mqtt_sub_topic = mqtt_topic + "/restart";
371+
mqttclient.subscribe(mqtt_sub_topic);
372+
yield();
373+
363374
connecting = false;
364375
});
365376

0 commit comments

Comments
 (0)