diff --git a/README.md b/README.md index ca73c982..8809cfa0 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ 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) +[![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=dev)](https://travis-ci.org/xoseperez/espurna) 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/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/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 diff --git a/code/espurna/debug.ino b/code/espurna/debug.ino index 3c6671c2..ebe7a0a0 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..178fe6c3 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 */ @@ -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(); @@ -636,7 +642,7 @@ void _relayWebSocketSendRelays() { #if MQTT_SUPPORT JsonArray& group = relays.createNestedArray("group"); - JsonArray& group_inverse = relays.createNestedArray("group_inv"); + JsonArray& group_sync = relays.createNestedArray("group_sync"); JsonArray& on_disconnect = relays.createNestedArray("on_disc"); #endif @@ -652,7 +658,7 @@ void _relayWebSocketSendRelays() { #if MQTT_SUPPORT group.add(getSetting("mqttGroup", i, "")); - group_inverse.add(getSetting("mqttGroupInv", i, 0).toInt() == 1); + group_sync.add(getSetting("mqttGroupSync", i, 0).toInt() == 1); on_disconnect.add(getSetting("relayOnDisc", i, 0).toInt()); #endif } @@ -807,6 +813,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; @@ -820,12 +838,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 @@ -952,7 +965,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/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/custom.js b/code/html/custom.js index c3699e69..642916f0 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", @@ -958,8 +958,8 @@ function initRelayConfig(data) { if ("group" in data) { $("input[name='mqttGroup']", line).val(data.group[i]); } - if ("group_inv" in data) { - $("input[name='mqttGroupInv']", line).val(data.group_inv[i]); + if ("group_sync" in data) { + $("input[name='mqttGroupSync']", line).val(data.group_sync[i]); } if ("on_disc" in data) { $("input[name='relayOnDisc']", line).val(data.on_disc[i]); diff --git a/code/html/index.html b/code/html/index.html index a91b8a38..4676d2f2 100644 --- a/code/html/index.html +++ b/code/html/index.html @@ -181,7 +181,7 @@
- +