Browse Source

Merge branch 'ResetRelay' of https://github.com/a-tom-s/espurna into a-tom-s-ResetRelay

Conflicts:
	code/espurna/data/index.html.gz
	code/espurna/static/index.html.gz.h
	code/html/custom.js
rfm69
Xose Pérez 6 years ago
parent
commit
94c57698e0
6 changed files with 2292 additions and 2267 deletions
  1. +3
    -3
      README.md
  2. BIN
      code/espurna/data/index.html.gz
  3. +15
    -1
      code/espurna/relay.ino
  4. +2264
    -2262
      code/espurna/static/index.html.gz.h
  5. +2
    -1
      code/html/custom.js
  6. +8
    -0
      code/html/index.html

+ 3
- 3
README.md View File

@ -4,9 +4,9 @@ ESPurna ("spark" in Catalan) is a custom firmware for ESP8285/ESP8266 based smar
It uses the Arduino Core for ESP8266 framework and a number of 3rd party libraries. It uses the Arduino Core for ESP8266 framework and a number of 3rd party libraries.
[![version](https://img.shields.io/badge/version-1.12.5a-brightgreen.svg)](CHANGELOG.md) [![version](https://img.shields.io/badge/version-1.12.5a-brightgreen.svg)](CHANGELOG.md)
![branch](https://img.shields.io/badge/branch-dev-orange.svg)
[![travis](https://travis-ci.org/xoseperez/espurna.svg?branch=dev)](https://travis-ci.org/xoseperez/espurna)
[![codacy](https://img.shields.io/codacy/grade/c9496e25cf07434cba786b462cb15f49/dev.svg)](https://www.codacy.com/app/xoseperez/espurna/dashboard)
![branch](https://img.shields.io/badge/branch-a-tom-s-ResetRelay-orange.svg)
[![travis](https://travis-ci.org/xoseperez/espurna.svg?branch=a-tom-s-ResetRelay)](https://travis-ci.org/xoseperez/espurna)
[![codacy](https://img.shields.io/codacy/grade/c9496e25cf07434cba786b462cb15f49/a-tom-s-ResetRelay.svg)](https://www.codacy.com/app/xoseperez/espurna/dashboard)
[![donate](https://img.shields.io/badge/donate-PayPal-blue.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=xose%2eperez%40gmail%2ecom&lc=US&no_note=0&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHostedGuest) [![donate](https://img.shields.io/badge/donate-PayPal-blue.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=xose%2eperez%40gmail%2ecom&lc=US&no_note=0&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHostedGuest)
[![twitter](https://img.shields.io/twitter/follow/xoseperez.svg?style=social)](https://twitter.com/intent/follow?screen_name=xoseperez) [![twitter](https://img.shields.io/twitter/follow/xoseperez.svg?style=social)](https://twitter.com/intent/follow?screen_name=xoseperez)


BIN
code/espurna/data/index.html.gz View File


+ 15
- 1
code/espurna/relay.ino View File

@ -525,6 +525,7 @@ void _relayWebSocketOnStart(JsonObject& root) {
#if MQTT_SUPPORT #if MQTT_SUPPORT
line["group"] = getSetting("mqttGroup", i, ""); line["group"] = getSetting("mqttGroup", i, "");
line["group_inv"] = getSetting("mqttGroupInv", i, 0).toInt(); line["group_inv"] = getSetting("mqttGroupInv", i, 0).toInt();
line["on_disc"] = getSetting("relayOnDisc", i, 0).toInt();
#endif #endif
} }
@ -650,7 +651,6 @@ void relayMQTT(unsigned char id) {
mqttSendRaw(t.c_str(), status ? "1" : "0"); mqttSendRaw(t.c_str(), status ? "1" : "0");
} }
} }
} }
void relayMQTT() { void relayMQTT() {
@ -745,6 +745,20 @@ void relayMQTTCallback(unsigned int type, const char * topic, const char * paylo
} }
if (type == MQTT_DISCONNECT_EVENT) {
for (unsigned int i=0; i < _relays.size(); i++){
int reaction = getSetting("relayOnDisc", i, 0).toInt();
if (1 == reaction) { // switch relay OFF
DEBUG_MSG_P(PSTR("[RELAY] Reset relay (%d) due to MQTT disconnection\n"), i);
relayStatusWrap(i, false, false);
} else if(2 == reaction) { // switch relay ON
DEBUG_MSG_P(PSTR("[RELAY] Set relay (%d) due to MQTT disconnection\n"), i);
relayStatusWrap(i, true, false);
}
}
}
} }
void relaySetupMQTT() { void relaySetupMQTT() {


+ 2264
- 2262
code/espurna/static/index.html.gz.h
File diff suppressed because it is too large
View File


+ 2
- 1
code/html/custom.js View File

@ -179,7 +179,7 @@ function addValue(data, name, value) {
"ssid", "pass", "gw", "mask", "ip", "dns", "ssid", "pass", "gw", "mask", "ip", "dns",
"schEnabled", "schSwitch","schAction","schHour","schMinute","schWDs", "schEnabled", "schSwitch","schAction","schHour","schMinute","schWDs",
"relayBoot", "relayPulse", "relayTime", "relayBoot", "relayPulse", "relayTime",
"mqttGroup", "mqttGroupInv",
"mqttGroup", "mqttGroupInv", "relayOnDisc",
"dczRelayIdx", "dczMagnitude", "dczRelayIdx", "dczMagnitude",
"tspkRelay", "tspkMagnitude", "tspkRelay", "tspkMagnitude",
"ledMode", "ledMode",
@ -716,6 +716,7 @@ function initRelayConfig(data) {
$("input[name='relayTime']", line).val(relay.pulse_ms); $("input[name='relayTime']", line).val(relay.pulse_ms);
$("input[name='mqttGroup']", line).val(relay.group); $("input[name='mqttGroup']", line).val(relay.group);
$("select[name='mqttGroupInv']", line).val(relay.group_inv); $("select[name='mqttGroupInv']", line).val(relay.group_inv);
$("select[name='relayOnDisc']", line).val(relay.on_disc);
line.appendTo("#relayConfig"); line.appendTo("#relayConfig");
} }


+ 8
- 0
code/html/index.html View File

@ -1284,6 +1284,14 @@
<option value="1">Inverse</option> <option value="1">Inverse</option>
</select> </select>
</div> </div>
<div class="pure-g module module-mqtt">
<div class="pure-u-1 pure-u-lg-1-4"><label>On MQTT disconnect</label></div>
<select class="pure-u-1 pure-u-lg-3-4" name="mqttOnDisc">
<option value="0">Don't change</option>
<option value="1">Turn the switch OFF</option>
<option value="2">Turn the switch ON</option>
</select>
</div>
</div> </div>
<div id="dczRelayTemplate" class="template"> <div id="dczRelayTemplate" class="template">


Loading…
Cancel
Save