From 7fc8cda783aa6239bc156e690d9e27ff8a8d8d9a Mon Sep 17 00:00:00 2001 From: Nis Wechselberg Date: Sun, 17 Sep 2017 17:44:18 +0200 Subject: [PATCH] Added OTA methods, fixed subwwoofer template --- ESP8266-MQTT-BenQ/ESP8266-MQTT-BenQ.ino | 8 ++++++++ .../ESP8266-MQTT-Teufel-Subwoofer.h.template | 6 +++--- .../ESP8266-MQTT-Teufel-Subwoofer.ino | 8 ++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ESP8266-MQTT-BenQ/ESP8266-MQTT-BenQ.ino b/ESP8266-MQTT-BenQ/ESP8266-MQTT-BenQ.ino index 17dd64b..540bacb 100644 --- a/ESP8266-MQTT-BenQ/ESP8266-MQTT-BenQ.ino +++ b/ESP8266-MQTT-BenQ/ESP8266-MQTT-BenQ.ino @@ -34,6 +34,9 @@ **********************************************************************/ #include +#include +#include +#include #include #include "ESP8266-MQTT-BenQ.h" @@ -91,6 +94,8 @@ void setup_wifi() { Serial.print("My IP address: "); Serial.println(WiFi.localIP()); } + ArduinoOTA.setHostname("esp8266-BenQ"); + ArduinoOTA.begin(); } /* @@ -177,6 +182,9 @@ void updateLamptime() { } void loop() { + // Check OTA update + ArduinoOTA.handle(); + // Ensure MQTT connection if (!client.connected()) { reconnect(); diff --git a/ESP8266-MQTT-Teufel-Subwoofer/ESP8266-MQTT-Teufel-Subwoofer.h.template b/ESP8266-MQTT-Teufel-Subwoofer/ESP8266-MQTT-Teufel-Subwoofer.h.template index 41d0062..c5177ff 100644 --- a/ESP8266-MQTT-Teufel-Subwoofer/ESP8266-MQTT-Teufel-Subwoofer.h.template +++ b/ESP8266-MQTT-Teufel-Subwoofer/ESP8266-MQTT-Teufel-Subwoofer.h.template @@ -6,8 +6,8 @@ const char* password = ""; const char* mqtt_server = "broker.mqtt-dashboard.com"; // Device identification -const char* mqtt_device_name = "esp8266benq" +const char* mqtt_device_name = "livingroom/teufelSub"; // MQTT topics -const char* mqtt_topic_power = "benq/power"; -const char* mqtt_topic_lamptime = "benq/lamptime"; +const char* mqtt_topic_power = "livingroom/teufelSub/power"; +const char* mqtt_topic_powerState = "livingroom/teufelSub/powerState"; diff --git a/ESP8266-MQTT-Teufel-Subwoofer/ESP8266-MQTT-Teufel-Subwoofer.ino b/ESP8266-MQTT-Teufel-Subwoofer/ESP8266-MQTT-Teufel-Subwoofer.ino index 9424f7e..c6f4da4 100644 --- a/ESP8266-MQTT-Teufel-Subwoofer/ESP8266-MQTT-Teufel-Subwoofer.ino +++ b/ESP8266-MQTT-Teufel-Subwoofer/ESP8266-MQTT-Teufel-Subwoofer.ino @@ -34,6 +34,9 @@ **********************************************************************/ #include +#include +#include +#include #include #include "ESP8266-MQTT-Teufel-Subwoofer.h" @@ -105,6 +108,8 @@ void setup_wifi() { Serial.print("My IP address: "); Serial.println(WiFi.localIP()); } + ArduinoOTA.setHostname("esp8266-TeufelSub"); + ArduinoOTA.begin(); } /* @@ -189,6 +194,9 @@ void updatePowerState() { } void loop() { + // Check OTA update + ArduinoOTA.handle(); + // Ensure MQTT connection if (!client.connected()) { reconnect();