From 2348bc684ed6142b896cfbc79eff8069f50da4dc Mon Sep 17 00:00:00 2001 From: wysiwyng <4764286+wysiwyng@users.noreply.github.com> Date: Tue, 20 Mar 2018 22:34:49 +0100 Subject: [PATCH 1/4] switch schedules work again --- code/html/custom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/html/custom.js b/code/html/custom.js index b2e90172..85bde849 100644 --- a/code/html/custom.js +++ b/code/html/custom.js @@ -662,7 +662,7 @@ function addSchedule(event) { var template = $("#scheduleTemplate").children(); var line = $(template).clone(); - var type = (1 === event.data.schType) ? "switch" : "light"; + var type = ("1" === event.data.schType) ? "switch" : "light"; template = $("#" + type + "ActionTemplate").children(); var actionLine = template.clone(); From 1bab8e01424d92049c0795a637a4693a22ee9fa8 Mon Sep 17 00:00:00 2001 From: wysiwyng Date: Wed, 21 Mar 2018 18:35:38 +0100 Subject: [PATCH 2/4] schedules properly fixed --- code/espurna/scheduler.ino | 2 +- code/html/custom.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code/espurna/scheduler.ino b/code/espurna/scheduler.ino index faa89e68..b78f3fc7 100644 --- a/code/espurna/scheduler.ino +++ b/code/espurna/scheduler.ino @@ -26,7 +26,7 @@ void _schWebSocketOnSend(JsonObject &root){ scheduler["schEnabled"] = getSetting("schEnabled", i, 1).toInt() == 1; scheduler["schSwitch"] = getSetting("schSwitch", i, 0).toInt(); scheduler["schAction"] = getSetting("schAction", i, 0).toInt(); - scheduler["schType"] = getSetting("schType", i, 0); + scheduler["schType"] = getSetting("schType", i, 0).toInt(); scheduler["schHour"] = getSetting("schHour", i, 0).toInt(); scheduler["schMinute"] = getSetting("schMinute", i, 0).toInt(); scheduler["schWDs"] = getSetting("schWDs", i, ""); diff --git a/code/html/custom.js b/code/html/custom.js index 85bde849..70181a10 100644 --- a/code/html/custom.js +++ b/code/html/custom.js @@ -662,7 +662,7 @@ function addSchedule(event) { var template = $("#scheduleTemplate").children(); var line = $(template).clone(); - var type = ("1" === event.data.schType) ? "switch" : "light"; + var type = (1 === event.data.schType) ? "switch" : "light"; template = $("#" + type + "ActionTemplate").children(); var actionLine = template.clone(); @@ -1349,8 +1349,8 @@ $(function() { $(".button-add-network").on("click", function() { $(".more", addNetwork()).toggle(); }); - $(".button-add-switch-schedule").on("click", { schType: "1" }, addSchedule); - $(".button-add-light-schedule").on("click", { schType: "2" }, addSchedule); + $(".button-add-switch-schedule").on("click", { schType: 1 }, addSchedule); + $(".button-add-light-schedule").on("click", { schType: 2 }, addSchedule); $(document).on("change", "input", hasChanged); $(document).on("change", "select", hasChanged); From d99a58676ae281da955f16a2971d23f1487a2c5e Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Thu, 22 Mar 2018 01:25:18 +0300 Subject: [PATCH 3/4] Add 'board' to the MQTT heartbeat --- code/espurna/config/general.h | 2 ++ code/espurna/utils.ino | 3 +++ 2 files changed, 5 insertions(+) diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index 1fbe933d..d631234c 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -181,6 +181,7 @@ #define HEARTBEAT_REPORT_HOSTNAME 1 #define HEARTBEAT_REPORT_APP 1 #define HEARTBEAT_REPORT_VERSION 1 +#define HEARTBEAT_REPORT_BOARD 1 #define HEARTBEAT_REPORT_INTERVAL 0 //------------------------------------------------------------------------------ @@ -617,6 +618,7 @@ PROGMEM const char* const custom_reset_string[] = { #define MQTT_TOPIC_UARTIN "uartin" #define MQTT_TOPIC_UARTOUT "uartout" #define MQTT_TOPIC_LOADAVG "loadavg" +#define MQTT_TOPIC_BOARD "board" // Light module #define MQTT_TOPIC_CHANNEL "channel" diff --git a/code/espurna/utils.ino b/code/espurna/utils.ino index 9f0e8e0f..bef49c81 100644 --- a/code/espurna/utils.ino +++ b/code/espurna/utils.ino @@ -137,6 +137,9 @@ void heartbeat() { #if (HEARTBEAT_REPORT_VERSION) mqttSend(MQTT_TOPIC_VERSION, APP_VERSION); #endif + #if (HEARTBEAT_REPORT_BOARD) + mqttSend(MQTT_TOPIC_BOARD, getBoardName().c_str()); + #endif #if (HEARTBEAT_REPORT_HOSTNAME) mqttSend(MQTT_TOPIC_HOSTNAME, getSetting("hostname").c_str()); #endif From 755b075e5d03b913a01dbfcee645e1fdc00b45f8 Mon Sep 17 00:00:00 2001 From: gn0st1c Date: Thu, 22 Mar 2018 11:02:41 +0300 Subject: [PATCH 4/4] Update hardware.h just hy02, wus002s, xssa05 definitions. rest of the code will be in a seperate PR. --- code/espurna/config/hardware.h | 96 ++++++++++++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 4 deletions(-) diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index 68722f99..61deabcc 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -772,7 +772,6 @@ #define LED1_PIN 13 #define LED1_PIN_INVERSE 1 - // ----------------------------------------------------------------------------- // YJZK // ----------------------------------------------------------------------------- @@ -1258,7 +1257,6 @@ #define LIGHT_CH3_INVERSE 0 #define LIGHT_CH4_INVERSE 0 - #elif defined(ARILUX_AL_LC02) // Info @@ -1301,7 +1299,6 @@ #define LIGHT_CH4_INVERSE 0 #define LIGHT_CH5_INVERSE 0 - #elif defined(ARILUX_AL_LC11) // Info @@ -1324,7 +1321,6 @@ #define LIGHT_CH4_INVERSE 0 #define LIGHT_CH5_INVERSE 0 - #elif defined(ARILUX_E27) // Info @@ -1590,6 +1586,98 @@ #define LED1_PIN 4 #define LED1_PIN_INVERSE 1 +// ----------------------------------------------------------------------------- +// HEYGO HY02 +// ----------------------------------------------------------------------------- + +#elif defined(HEYGO_HY02) + + // Info + #define MANUFACTURER "HEYGO" + #define DEVICE "HY02" + + // Buttons + #define BUTTON1_PIN 13 + #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + #define BUTTON1_RELAY 1 + + // Relays + #define RELAY1_PIN 12 + #define RELAY1_TYPE RELAY_TYPE_NORMAL + + // LEDs + #define LED1_PIN 0 + #define LED1_PIN_INVERSE 0 + #define LED2_PIN 15 + #define LED2_PIN_INVERSE 0 + + // HLW8012 + #ifndef HLW8012_SUPPORT + #define HLW8012_SUPPORT 1 + #endif + #define HLW8012_SEL_PIN 3 + #define HLW8012_CF1_PIN 14 + #define HLW8012_CF_PIN 5 + + #define HLW8012_VOLTAGE_R_UP ( 2 * 1200000 ) // Upstream voltage resistor + +// ----------------------------------------------------------------------------- +// Maxcio W-US002S +// ----------------------------------------------------------------------------- + +#elif defined(MAXCIO_WUS002S) + + // Info + #define MANUFACTURER "MAXCIO" + #define DEVICE "WUS002S" + + // Buttons + #define BUTTON1_PIN 2 + #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + #define BUTTON1_RELAY 1 + + // Relays + #define RELAY1_PIN 13 + #define RELAY1_TYPE RELAY_TYPE_NORMAL + + // LEDs + #define LED1_PIN 3 + #define LED1_PIN_INVERSE 0 + + // HLW8012 + #ifndef HLW8012_SUPPORT + #define HLW8012_SUPPORT 1 + #endif + #define HLW8012_SEL_PIN 12 + #define HLW8012_CF1_PIN 5 + #define HLW8012_CF_PIN 4 + + #define HLW8012_CURRENT_R 0.002 // Current resistor + #define HLW8012_VOLTAGE_R_UP ( 2 * 1000000 ) // Upstream voltage resistor + +// ----------------------------------------------------------------------------- +// YiDian XS-SSA05 +// ----------------------------------------------------------------------------- + +#elif defined(YIDIAN_XSSSA05) + + // Info + #define MANUFACTURER "YIDIAN" + #define DEVICE "XSSSA05" + + // Buttons + #define BUTTON1_PIN 13 + #define BUTTON1_MODE BUTTON_PUSHBUTTON + #define BUTTON1_RELAY 1 + + // Relays + #define RELAY1_PIN 12 + #define RELAY1_TYPE RELAY_TYPE_NORMAL + + // LEDs + #define LED1_PIN 4 + #define LED1_PIN_INVERSE 0 + // ----------------------------------------------------------------------------- // TEST boards (do not use!!) // -----------------------------------------------------------------------------