From a53b66d55aba1cd1e5d63ab2a1ba7a52f640df3e Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Wed, 20 Feb 2019 08:36:26 +0300 Subject: [PATCH 1/4] Relay MQTT group sync mode setting --- code/espurna/config/types.h | 4 ++++ code/espurna/relay.ino | 23 +++++++++++++++-------- code/html/custom.js | 4 ++-- code/html/index.html | 3 ++- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/code/espurna/config/types.h b/code/espurna/config/types.h index fc611740..d9f0f832 100644 --- a/code/espurna/config/types.h +++ b/code/espurna/config/types.h @@ -96,6 +96,10 @@ #define RELAY_PROVIDER_RFBRIDGE 3 #define RELAY_PROVIDER_STM 4 +#define RELAY_GROUP_SYNC_NORMAL 0 +#define RELAY_GROUP_SYNC_INVERSE 1 +#define RELAY_GROUP_SYNC_RECEIVEONLY 2 + //------------------------------------------------------------------------------ // UDP SYSLOG //------------------------------------------------------------------------------ diff --git a/code/espurna/relay.ino b/code/espurna/relay.ino index fa9fe407..0c42c05a 100644 --- a/code/espurna/relay.ino +++ b/code/espurna/relay.ino @@ -630,7 +630,7 @@ void _relayWebSocketSendRelay(unsigned char i) { line["pulse_ms"] = _relays[i].pulse_ms / 1000.0; #if MQTT_SUPPORT line["group"] = getSetting("mqttGroup", i, ""); - line["group_inv"] = getSetting("mqttGroupInv", i, 0).toInt(); + line["group_sync"] = getSetting("mqttGroupSync", i, RELAY_GROUP_SYNC_NORMAL).toInt(); line["on_disc"] = getSetting("relayOnDisc", i, 0).toInt(); #endif @@ -794,6 +794,18 @@ void relaySetupAPI() { #if MQTT_SUPPORT +void _relayMQTTGroup(unsigned char id) { + String topic = getSetting("mqttGroup", id, ""); + if (!topic.length()) return; + + unsigned char mode = getSetting("mqttGroupSync", id, RELAY_GROUP_SYNC_NORMAL).toInt(); + if (mode == RELAY_GROUP_SYNC_RECEIVEONLY) return; + + bool status = relayStatus(id); + if (mode == RELAY_GROUP_SYNC_INVERSE) status = !status; + mqttSendRaw(topic.c_str(), status ? RELAY_MQTT_ON : RELAY_MQTT_OFF); +} + void relayMQTT(unsigned char id) { if (id >= _relays.size()) return; @@ -807,12 +819,7 @@ void relayMQTT(unsigned char id) { // Check group topic if (_relays[id].group_report) { _relays[id].group_report = false; - String t = getSetting("mqttGroup", id, ""); - if (t.length() > 0) { - bool status = relayStatus(id); - if (getSetting("mqttGroupInv", id, 0).toInt() == 1) status = !status; - mqttSendRaw(t.c_str(), status ? RELAY_MQTT_ON : RELAY_MQTT_OFF); - } + _relayMQTTGroup(id); } // Send speed for IFAN02 @@ -939,7 +946,7 @@ void relayMQTTCallback(unsigned int type, const char * topic, const char * paylo if (value == 0xFF) return; if (value < 2) { - if (getSetting("mqttGroupInv", i, 0).toInt() == 1) { + if (getSetting("mqttGroupSync", i, RELAY_GROUP_SYNC_NORMAL).toInt() == RELAY_GROUP_SYNC_INVERSE) { value = 1 - value; } } diff --git a/code/html/custom.js b/code/html/custom.js index 0c79d78a..fe0b4a9d 100644 --- a/code/html/custom.js +++ b/code/html/custom.js @@ -246,7 +246,7 @@ function addValue(data, name, value) { "ssid", "pass", "gw", "mask", "ip", "dns", "schEnabled", "schSwitch","schAction","schType","schHour","schMinute","schWDs","schUTC", "relayBoot", "relayPulse", "relayTime", - "mqttGroup", "mqttGroupInv", "relayOnDisc", + "mqttGroup", "mqttGroupSync", "relayOnDisc", "dczRelayIdx", "dczMagnitude", "tspkRelay", "tspkMagnitude", "ledMode", @@ -951,7 +951,7 @@ function initRelayConfig(data) { $("select[name='relayPulse']", line).val(relay.pulse); $("input[name='relayTime']", line).val(relay.pulse_ms); $("input[name='mqttGroup']", line).val(relay.group); - $("select[name='mqttGroupInv']", line).val(relay.group_inv); + $("select[name='mqttGroupSync']", line).val(relay.group_sync); $("select[name='relayOnDisc']", line).val(relay.on_disc); line.appendTo("#relayConfig"); diff --git a/code/html/index.html b/code/html/index.html index a0555d23..09c0a6de 100644 --- a/code/html/index.html +++ b/code/html/index.html @@ -1631,9 +1631,10 @@
- +
From d47859f2ae59fddaf7baa3b0e07f58f6707a4462 Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Wed, 20 Feb 2019 08:39:10 +0300 Subject: [PATCH 2/4] replace mqttGroupInv with mqttGroupSync --- code/espurna/relay.ino | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/espurna/relay.ino b/code/espurna/relay.ino index 0c42c05a..0652a82f 100644 --- a/code/espurna/relay.ino +++ b/code/espurna/relay.ino @@ -478,6 +478,12 @@ unsigned char relayParsePayload(const char * payload) { // BACKWARDS COMPATIBILITY void _relayBackwards() { + for (unsigned int i=0; i<_relays.size(); i++) { + if (!hasSetting("mqttGroupInv", i)) continue; + setSetting("mqttGroupSync", i, getSetting("mqttGroupInv", i)); + delSetting("mqttGroupInv", i); + } + byte relayMode = getSetting("relayMode", RELAY_BOOT_MODE).toInt(); byte relayPulseMode = getSetting("relayPulseMode", RELAY_PULSE_MODE).toInt(); float relayPulseTime = getSetting("relayPulseTime", RELAY_PULSE_TIME).toFloat(); From 5d9db5e939210040d664fda9fde420d4a1ac9824 Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Sat, 23 Feb 2019 08:02:32 +0300 Subject: [PATCH 3/4] Version 1.13.5-dev --- README.md | 6 +++--- code/espurna/config/version.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c30534c4..8809cfa0 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,10 @@ ESPurna ("spark" in Catalan) is a custom firmware for ESP8285/ESP8266 based smart switches, lights and sensors. It uses the Arduino Core for ESP8266 framework and a number of 3rd party libraries. -[![version](https://img.shields.io/badge/version-1.13.4-brightgreen.svg)](CHANGELOG.md) -[![branch](https://img.shields.io/badge/branch-master-orange.svg)](https://github.com/xoseperez/espurna/tree/master/) +[![version](https://img.shields.io/badge/version-1.13.5--dev-brightgreen.svg)](CHANGELOG.md) +[![branch](https://img.shields.io/badge/branch-dev-orange.svg)](https://github.com/xoseperez/espurna/tree/dev/) [![license](https://img.shields.io/github/license/xoseperez/espurna.svg)](LICENSE) -[![travis](https://travis-ci.org/xoseperez/espurna.svg?branch=master)](https://travis-ci.org/xoseperez/espurna) +[![travis](https://travis-ci.org/xoseperez/espurna.svg?branch=dev)](https://travis-ci.org/xoseperez/espurna) [![codacy](https://api.codacy.com/project/badge/Grade/c9496e25cf07434cba786b462cb15f49)](https://www.codacy.com/app/xoseperez/espurna/dashboard) [![downloads](https://img.shields.io/github/downloads/xoseperez/espurna/total.svg)](https://github.com/xoseperez/espurna/releases)
diff --git a/code/espurna/config/version.h b/code/espurna/config/version.h index 7f3c064f..774b0f18 100644 --- a/code/espurna/config/version.h +++ b/code/espurna/config/version.h @@ -1,5 +1,5 @@ #define APP_NAME "ESPURNA" -#define APP_VERSION "1.13.4" +#define APP_VERSION "1.13.5-dev" #define APP_AUTHOR "xose.perez@gmail.com" #define APP_WEBSITE "http://tinkerman.cat" #define CFG_VERSION 3 From c8231860ac8e2dd3901f127813ef5e4f88b3304b Mon Sep 17 00:00:00 2001 From: Malachi Soord Date: Sat, 23 Feb 2019 22:35:49 +0100 Subject: [PATCH 4/4] [copyright-update] Update for 2019 --- code/espurna/alexa.ino | 2 +- code/espurna/api.ino | 2 +- code/espurna/button.ino | 2 +- code/espurna/debug.ino | 2 +- code/espurna/domoticz.ino | 2 +- code/espurna/espurna.ino | 2 +- code/espurna/ir.ino | 2 +- code/espurna/led.ino | 2 +- code/espurna/libs/RFM69Wrap.h | 2 +- code/espurna/libs/StreamInjector.h | 2 +- code/espurna/light.ino | 2 +- code/espurna/migrate.ino | 2 +- code/espurna/mqtt.ino | 2 +- code/espurna/nofuss.ino | 2 +- code/espurna/ntp.ino | 2 +- code/espurna/ota.ino | 2 +- code/espurna/relay.ino | 2 +- code/espurna/rfbridge.ino | 2 +- code/espurna/sensor.ino | 2 +- code/espurna/web.ino | 2 +- code/espurna/wifi.ino | 2 +- code/espurna/ws.ino | 2 +- code/gulpfile.js | 2 +- code/html/index.html | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/code/espurna/alexa.ino b/code/espurna/alexa.ino index 6da42fe0..c1cced8a 100644 --- a/code/espurna/alexa.ino +++ b/code/espurna/alexa.ino @@ -2,7 +2,7 @@ ALEXA MODULE -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez */ diff --git a/code/espurna/api.ino b/code/espurna/api.ino index 5345def6..fac60d85 100644 --- a/code/espurna/api.ino +++ b/code/espurna/api.ino @@ -2,7 +2,7 @@ API MODULE -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez */ diff --git a/code/espurna/button.ino b/code/espurna/button.ino index 0766fca9..1d27c679 100644 --- a/code/espurna/button.ino +++ b/code/espurna/button.ino @@ -2,7 +2,7 @@ BUTTON MODULE -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez */ diff --git a/code/espurna/debug.ino b/code/espurna/debug.ino index 2969d0ee..8ab58c21 100644 --- a/code/espurna/debug.ino +++ b/code/espurna/debug.ino @@ -2,7 +2,7 @@ DEBUG MODULE -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez */ diff --git a/code/espurna/domoticz.ino b/code/espurna/domoticz.ino index 6482f4c5..cd8ca46b 100644 --- a/code/espurna/domoticz.ino +++ b/code/espurna/domoticz.ino @@ -2,7 +2,7 @@ DOMOTICZ MODULE -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez */ diff --git a/code/espurna/espurna.ino b/code/espurna/espurna.ino index d8ad3052..0da20639 100644 --- a/code/espurna/espurna.ino +++ b/code/espurna/espurna.ino @@ -2,7 +2,7 @@ ESPurna -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/code/espurna/ir.ino b/code/espurna/ir.ino index 22f17bfa..6978f4db 100644 --- a/code/espurna/ir.ino +++ b/code/espurna/ir.ino @@ -4,7 +4,7 @@ IR MODULE Copyright (C) 2018 by Alexander Kolesnikov (raw and MQTT implementation) Copyright (C) 2017-2018 by François Déchery -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez ----------------------------------------------------------------------------- Configuration diff --git a/code/espurna/led.ino b/code/espurna/led.ino index 01999aad..d44eec15 100644 --- a/code/espurna/led.ino +++ b/code/espurna/led.ino @@ -2,7 +2,7 @@ LED MODULE -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez */ diff --git a/code/espurna/libs/RFM69Wrap.h b/code/espurna/libs/RFM69Wrap.h index 33e954c5..33322bef 100644 --- a/code/espurna/libs/RFM69Wrap.h +++ b/code/espurna/libs/RFM69Wrap.h @@ -3,7 +3,7 @@ RFM69Wrap RFM69 by Felix Ruso (http://LowPowerLab.com/contact) wrapper for ESP8266 -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/code/espurna/libs/StreamInjector.h b/code/espurna/libs/StreamInjector.h index 03dbd51b..fd98077b 100644 --- a/code/espurna/libs/StreamInjector.h +++ b/code/espurna/libs/StreamInjector.h @@ -2,7 +2,7 @@ StreamInjector -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/code/espurna/light.ino b/code/espurna/light.ino index 16b72d33..141e366d 100644 --- a/code/espurna/light.ino +++ b/code/espurna/light.ino @@ -2,7 +2,7 @@ LIGHT MODULE -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez */ diff --git a/code/espurna/migrate.ino b/code/espurna/migrate.ino index 9da0b10e..40f93995 100644 --- a/code/espurna/migrate.ino +++ b/code/espurna/migrate.ino @@ -2,7 +2,7 @@ MIGRATE MODULE -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez */ diff --git a/code/espurna/mqtt.ino b/code/espurna/mqtt.ino index fd99a333..3c1f155a 100644 --- a/code/espurna/mqtt.ino +++ b/code/espurna/mqtt.ino @@ -2,7 +2,7 @@ MQTT MODULE -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez */ diff --git a/code/espurna/nofuss.ino b/code/espurna/nofuss.ino index c6a33ad1..4ec35c36 100644 --- a/code/espurna/nofuss.ino +++ b/code/espurna/nofuss.ino @@ -2,7 +2,7 @@ NOFUSS MODULE -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez */ diff --git a/code/espurna/ntp.ino b/code/espurna/ntp.ino index 2ffd41d9..ea3ddc74 100644 --- a/code/espurna/ntp.ino +++ b/code/espurna/ntp.ino @@ -2,7 +2,7 @@ NTP MODULE -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez */ diff --git a/code/espurna/ota.ino b/code/espurna/ota.ino index 42ca5b67..0f504adb 100644 --- a/code/espurna/ota.ino +++ b/code/espurna/ota.ino @@ -2,7 +2,7 @@ OTA MODULE -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez */ diff --git a/code/espurna/relay.ino b/code/espurna/relay.ino index b8b985f6..06925c0a 100644 --- a/code/espurna/relay.ino +++ b/code/espurna/relay.ino @@ -2,7 +2,7 @@ RELAY MODULE -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez */ diff --git a/code/espurna/rfbridge.ino b/code/espurna/rfbridge.ino index fa8ff560..eccc5dca 100644 --- a/code/espurna/rfbridge.ino +++ b/code/espurna/rfbridge.ino @@ -2,7 +2,7 @@ RF MODULE -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez */ diff --git a/code/espurna/sensor.ino b/code/espurna/sensor.ino index a67d9c62..362d5e6c 100644 --- a/code/espurna/sensor.ino +++ b/code/espurna/sensor.ino @@ -2,7 +2,7 @@ SENSOR MODULE -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez */ diff --git a/code/espurna/web.ino b/code/espurna/web.ino index 30c10a78..680db834 100644 --- a/code/espurna/web.ino +++ b/code/espurna/web.ino @@ -2,7 +2,7 @@ WEBSERVER MODULE -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez */ diff --git a/code/espurna/wifi.ino b/code/espurna/wifi.ino index 272b0151..ca30d45c 100644 --- a/code/espurna/wifi.ino +++ b/code/espurna/wifi.ino @@ -2,7 +2,7 @@ WIFI MODULE -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez */ diff --git a/code/espurna/ws.ino b/code/espurna/ws.ino index f5ff11e4..b0731b4d 100644 --- a/code/espurna/ws.ino +++ b/code/espurna/ws.ino @@ -2,7 +2,7 @@ WEBSOCKET MODULE -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez */ diff --git a/code/gulpfile.js b/code/gulpfile.js index 4e9ead42..bf2fada4 100644 --- a/code/gulpfile.js +++ b/code/gulpfile.js @@ -2,7 +2,7 @@ ESP8266 file system builder -Copyright (C) 2016-2018 by Xose Pérez +Copyright (C) 2016-2019 by Xose Pérez This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/code/html/index.html b/code/html/index.html index a91b8a38..22a46326 100644 --- a/code/html/index.html +++ b/code/html/index.html @@ -181,7 +181,7 @@