Browse Source

Added group topics (#300). Refactor relay module

fastled
Xose Pérez 6 years ago
parent
commit
2f750df44e
8 changed files with 3464 additions and 3279 deletions
  1. +0
    -6
      code/espurna/config/hardware.h
  2. BIN
      code/espurna/data/index.html.gz
  3. +205
    -142
      code/espurna/relay.ino
  4. +3063
    -3053
      code/espurna/static/index.html.gz.h
  5. +70
    -34
      code/espurna/ws.ino
  6. +2
    -1
      code/html/custom.css
  7. +39
    -0
      code/html/custom.js
  8. +85
    -43
      code/html/index.html

+ 0
- 6
code/espurna/config/hardware.h View File

@ -480,7 +480,6 @@
#endif
#define TERMINAL_SUPPORT 0
#define DEBUG_SERIAL_SUPPORT 0
#define TRACK_RELAY_STATUS 0
// Buttons
#define BUTTON1_PIN 0
@ -1306,11 +1305,6 @@
#define BUTTON_SET_PULLUP 4
#endif
// Does the board track the relay status?
#ifndef TRACK_RELAY_STATUS
#define TRACK_RELAY_STATUS 1
#endif
// Serial baudrate
#ifndef SERIAL_BAUDRATE
#define SERIAL_BAUDRATE 115200


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


+ 205
- 142
code/espurna/relay.ino View File

@ -13,48 +13,72 @@ Copyright (C) 2016-2017 by Xose Pérez <xose dot perez at gmail dot com>
#include <functional>
typedef struct {
unsigned char pin;
// Configuration variables
unsigned char pin; // GPIO pin for the relay
unsigned char type;
unsigned char reset_pin;
unsigned char led;
unsigned long delay_on;
unsigned long delay_off;
unsigned int floodWindowStart;
unsigned char floodWindowChanges;
bool scheduled;
unsigned int scheduledStatusTime;
bool scheduledStatus;
bool scheduledReport;
// Status variables
bool current_status;
bool target_status;
unsigned int fw_start;
unsigned char fw_count;
unsigned int change_time;
bool report;
bool group_report;
// Helping objects
Ticker pulseTicker;
} relay_t;
std::vector<relay_t> _relays;
bool recursive = false;
Ticker _relaySaveTicker;
#if RELAY_PROVIDER == RELAY_PROVIDER_DUAL
unsigned char _dual_status = 0;
#endif
// -----------------------------------------------------------------------------
// RELAY PROVIDERS
// -----------------------------------------------------------------------------
#if RELAY_PROVIDER == RELAY_PROVIDER_DUAL
#endif
void relayProviderStatus(unsigned char id, bool status) {
// Check relay ID
if (id >= _relays.size()) return;
// Store new current status
_relays[id].current_status = status;
#if RELAY_PROVIDER == RELAY_PROVIDER_RFBRIDGE
rfbStatus(id, status);
#endif
#if RELAY_PROVIDER == RELAY_PROVIDER_DUAL
_dual_status ^= (1 << id);
// Calculate mask
unsigned char mask = 0;
for (unsigned char i=_relays.size()-1; i>=0; i-- ) {
mask <<= 1;
if (_relays[i].current_status) mask++;
}
// Send it to EFM88
Serial.flush();
Serial.write(0xA0);
Serial.write(0x04);
Serial.write(_dual_status);
Serial.write(mask);
Serial.write(0xA1);
Serial.flush();
#endif
#if RELAY_PROVIDER == RELAY_PROVIDER_LIGHT
@ -83,34 +107,6 @@ void relayProviderStatus(unsigned char id, bool status) {
}
bool relayProviderStatus(unsigned char id) {
if (id >= _relays.size()) return false;
#if RELAY_PROVIDER == RELAY_PROVIDER_RFBRIDGE
return _relays[id].scheduledStatus;
#endif
#if RELAY_PROVIDER == RELAY_PROVIDER_DUAL
return ((_dual_status & (1 << id)) > 0);
#endif
#if RELAY_PROVIDER == RELAY_PROVIDER_LIGHT
return lightState();
#endif
#if RELAY_PROVIDER == RELAY_PROVIDER_RELAY
if (_relays[id].type == RELAY_TYPE_NORMAL) {
return (digitalRead(_relays[id].pin) == HIGH);
} else if (_relays[id].type == RELAY_TYPE_INVERSE) {
return (digitalRead(_relays[id].pin) == LOW);
} else if (_relays[id].type == RELAY_TYPE_LATCHED) {
return _relays[id].scheduledStatus;
}
#endif
}
// -----------------------------------------------------------------------------
// RELAY
// -----------------------------------------------------------------------------
@ -138,22 +134,10 @@ unsigned int relayPulseMode() {
return value;
}
void relayPulseMode(unsigned int value, bool report) {
void relayPulseMode(unsigned int value) {
setSetting("relayPulseMode", value);
/*
#if MQTT_SUPPORT
if (report) {
char topic[strlen(MQTT_TOPIC_RELAY) + 10];
snprintf_P(topic, sizeof(topic), PSTR("%s/pulse"), MQTT_TOPIC_RELAY);
char value[2];
snprintf_P(value, sizeof(value), PSTR("%d"), value);
mqttSend(topic, value);
}
#endif
*/
#if WEB_SUPPORT
char message[20];
snprintf_P(message, sizeof(message), PSTR("{\"relayPulseMode\": %d}"), value);
@ -162,82 +146,83 @@ void relayPulseMode(unsigned int value, bool report) {
}
void relayPulseMode(unsigned int value) {
relayPulseMode(value, true);
}
void relayPulseToggle() {
unsigned int value = relayPulseMode();
value = (value == RELAY_PULSE_NONE) ? RELAY_PULSE_OFF : RELAY_PULSE_NONE;
relayPulseMode(value);
}
bool relayStatus(unsigned char id, bool status, bool report) {
bool relayStatus(unsigned char id, bool status, bool report, bool group_report) {
if (id >= _relays.size()) return false;
bool changed = false;
#if TRACK_RELAY_STATUS
if (relayStatus(id) == status) {
if (_relays[id].scheduled) {
if (_relays[id].current_status == status) {
if (_relays[id].target_status != status) {
DEBUG_MSG_P(PSTR("[RELAY] #%d scheduled change cancelled\n"), id);
_relays[id].scheduled = false;
_relays[id].scheduledStatus = status;
_relays[id].scheduledReport = false;
_relays[id].target_status = status;
_relays[id].report = false;
_relays[id].group_report = false;
changed = true;
}
} else {
#endif
unsigned int currentTime = millis();
unsigned int floodWindowEnd = _relays[id].floodWindowStart + 1000 * RELAY_FLOOD_WINDOW;
unsigned int current_time = millis();
unsigned int fw_end = _relays[id].fw_start + 1000 * RELAY_FLOOD_WINDOW;
unsigned long delay = status ? _relays[id].delay_on : _relays[id].delay_off;
_relays[id].floodWindowChanges++;
_relays[id].scheduledStatusTime = currentTime + delay;
_relays[id].fw_count++;
_relays[id].change_time = current_time + delay;
// If currentTime is off-limits the floodWindow...
if (currentTime < _relays[id].floodWindowStart || floodWindowEnd <= currentTime) {
// If current_time is off-limits the floodWindow...
if (current_time < _relays[id].fw_start || fw_end <= current_time) {
// We reset the floodWindow
_relays[id].floodWindowStart = currentTime;
_relays[id].floodWindowChanges = 1;
_relays[id].fw_start = current_time;
_relays[id].fw_count = 1;
// If currentTime is in the floodWindow and there have been too many requests...
} else if (_relays[id].floodWindowChanges >= RELAY_FLOOD_CHANGES) {
// If current_time is in the floodWindow and there have been too many requests...
} else if (_relays[id].fw_count >= RELAY_FLOOD_CHANGES) {
// We schedule the changes to the end of the floodWindow
// unless it's already delayed beyond that point
if (floodWindowEnd - delay > currentTime) {
_relays[id].scheduledStatusTime = floodWindowEnd;
if (fw_end - delay > current_time) {
_relays[id].change_time = fw_end;
}
}
_relays[id].scheduled = true;
_relays[id].scheduledStatus = status;
if (report) _relays[id].scheduledReport = true;
_relays[id].target_status = status;
if (report) _relays[id].report = true;
if (group_report) _relays[id].group_report = true;
DEBUG_MSG_P(PSTR("[RELAY] #%d scheduled %s in %u ms\n"),
id, status ? "ON" : "OFF",
(_relays[id].scheduledStatusTime - currentTime));
(_relays[id].change_time - current_time));
changed = true;
#if TRACK_RELAY_STATUS
}
#endif
return changed;
}
bool relayStatus(unsigned char id, bool status) {
return relayStatus(id, status, true);
return relayStatus(id, status, true, true);
}
bool relayStatus(unsigned char id) {
return relayProviderStatus(id);
// Check relay ID
if (id >= _relays.size()) return false;
// GEt status from storage
return _relays[id].current_status;
}
void relaySync(unsigned char id) {
@ -295,9 +280,9 @@ void relayRetrieve(bool invert) {
unsigned char mask = invert ? ~EEPROM.read(EEPROM_RELAY_STATUS) : EEPROM.read(EEPROM_RELAY_STATUS);
DEBUG_MSG_P(PSTR("[RELAY] Retrieving mask: %d\n"), mask);
for (unsigned int id=0; id < _relays.size(); id++) {
_relays[id].scheduled = true;
_relays[id].scheduledStatus = ((mask & bit) == bit);
_relays[id].scheduledReport = true;
_relays[id].target_status = ((mask & bit) == bit);
_relays[id].report = true;
_relays[id].group_report = false; // Don't do group report on start
bit += bit;
}
if (invert) {
@ -307,9 +292,13 @@ void relayRetrieve(bool invert) {
recursive = false;
}
void relayToggle(unsigned char id) {
void relayToggle(unsigned char id, bool report, bool group_report) {
if (id >= _relays.size()) return;
relayStatus(id, !relayStatus(id));
relayStatus(id, !relayStatus(id), report, group_report);
}
void relayToggle(unsigned char id) {
relayToggle(id, true, true);
}
unsigned char relayCount() {
@ -347,17 +336,39 @@ unsigned char relayParsePayload(const char * payload) {
return 0xFF;
}
//------------------------------------------------------------------------------
// REST API
// WEBSOCKETS
//------------------------------------------------------------------------------
#if WEB_SUPPORT
void _relayWebSocketUpdate() {
DynamicJsonBuffer jsonBuffer;
JsonObject& root = jsonBuffer.createObject();
// Statuses
JsonArray& relay = root.createNestedArray("relayStatus");
for (unsigned char relayID=0; relayID<relayCount(); relayID++) {
relay.add(relayStatus(relayID));
}
String output;
root.printTo(output);
wsSend((char *) output.c_str());
}
void _relayWebSocketOnSend(JsonObject& root) {
// Statuses
JsonArray& relay = root.createNestedArray("relayStatus");
for (unsigned char relayID=0; relayID<relayCount(); relayID++) {
relay.add(relayStatus(relayID));
}
// Configuration
root["relayMode"] = getSetting("relayMode", RELAY_MODE);
root["relayPulseMode"] = getSetting("relayPulseMode", RELAY_PULSE_MODE);
root["relayPulseTime"] = getSetting("relayPulseTime", RELAY_PULSE_TIME).toFloat();
@ -365,6 +376,17 @@ void _relayWebSocketOnSend(JsonObject& root) {
root["multirelayVisible"] = 1;
root["relaySync"] = getSetting("relaySync", RELAY_SYNC);
}
// Group topics
#if MQTT_SUPPORT
JsonArray& groups = root.createNestedArray("relayGroups");
for (unsigned char i=0; i<relayCount(); i++) {
JsonObject& group = groups.createNestedObject();
group["mqttGroup"] = getSetting("mqttGroup", i, "");
group["mqttGroupInv"] = getSetting("mqttGroupInv", i, 0).toInt() == 1;
}
#endif
}
void _relayWebSocketOnAction(const char * action, JsonObject& data) {
@ -377,7 +399,7 @@ void _relayWebSocketOnAction(const char * action, JsonObject& data) {
if (value == 3) {
relayWS();
_relayWebSocketUpdate();
} else if (value < 3) {
@ -402,6 +424,19 @@ void _relayWebSocketOnAction(const char * action, JsonObject& data) {
}
void relaySetupWS() {
wsOnSendRegister(_relayWebSocketOnSend);
wsOnActionRegister(_relayWebSocketOnAction);
}
#endif // WEB_SUPPORT
//------------------------------------------------------------------------------
// REST API
//------------------------------------------------------------------------------
#if WEB_SUPPORT
void relaySetupAPI() {
// API entry points (protected with apikey)
@ -443,26 +478,6 @@ void relaySetupAPI() {
#endif // WEB_SUPPORT
//------------------------------------------------------------------------------
// WebSockets
//------------------------------------------------------------------------------
#if WEB_SUPPORT
void relayWS() {
DynamicJsonBuffer jsonBuffer;
JsonObject& root = jsonBuffer.createObject();
JsonArray& relay = root.createNestedArray("relayStatus");
for (unsigned char i=0; i<relayCount(); i++) {
relay.add(relayStatus(i));
}
String output;
root.printTo(output);
wsSend(output.c_str());
}
#endif
//------------------------------------------------------------------------------
// MQTT
//------------------------------------------------------------------------------
@ -470,13 +485,31 @@ void relayWS() {
#if MQTT_SUPPORT
void relayMQTT(unsigned char id) {
if (id >= _relays.size()) return;
mqttSend(MQTT_TOPIC_RELAY, id, relayStatus(id) ? "1" : "0");
// Send state topic
if (_relays[id].report) {
_relays[id].report = false;
mqttSend(MQTT_TOPIC_RELAY, id, _relays[id].current_status ? "1" : "0");
}
// 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 ? "1" : "0");
}
}
}
void relayMQTT() {
for (unsigned int i=0; i < _relays.size(); i++) {
relayMQTT(i);
for (unsigned int id=0; id < _relays.size(); id++) {
mqttSend(MQTT_TOPIC_RELAY, id, _relays[id].current_status ? "1" : "0");
}
}
@ -484,21 +517,29 @@ void relayMQTTCallback(unsigned int type, const char * topic, const char * paylo
if (type == MQTT_CONNECT_EVENT) {
// Send status on connect
#if not HEARTBEAT_REPORT_RELAY
relayMQTT();
#endif
// Subscribe to own /set topic
char buffer[strlen(MQTT_TOPIC_RELAY) + 3];
snprintf_P(buffer, sizeof(buffer), PSTR("%s/+"), MQTT_TOPIC_RELAY);
mqttSubscribe(buffer);
// Subscribe to group topics
for (unsigned int i=0; i < _relays.size(); i++) {
String t = getSetting("mqttGroup", i, "");
if (t.length() > 0) mqttSubscribeRaw(t.c_str());
}
}
if (type == MQTT_MESSAGE_EVENT) {
// Match topic
String t = mqttSubtopic((char *) topic);
if (!t.startsWith(MQTT_TOPIC_RELAY)) return;
// Get relay
unsigned int relayID;
bool is_group_topic = false;
// Get value
unsigned char value = relayParsePayload(payload);
@ -507,26 +548,49 @@ void relayMQTTCallback(unsigned int type, const char * topic, const char * paylo
return;
}
// Pulse topic
if (t.endsWith("pulse")) {
relayPulseMode(value, mqttForward());
return;
// Check group topics
for (unsigned int i=0; i < _relays.size(); i++) {
String t = getSetting("mqttGroup", i, "");
if (t.equals(topic)) {
is_group_topic = true;
relayID = i;
if (getSetting("mqttGroupInv", relayID, 0).toInt() == 1) {
if (value < 2) value = 1 - value;
}
DEBUG_MSG_P(PSTR("[RELAY] Matched group topic for relayID %d\n"), relayID);
break;
}
}
// Get relay ID
unsigned int relayID = t.substring(strlen(MQTT_TOPIC_RELAY)+1).toInt();
if (relayID >= relayCount()) {
DEBUG_MSG_P(PSTR("[RELAY] Wrong relayID (%d)\n"), relayID);
return;
// Not group topic, look for own topic
if (!is_group_topic) {
// Match topic
String t = mqttSubtopic((char *) topic);
if (!t.startsWith(MQTT_TOPIC_RELAY)) return;
// Pulse topic
if (t.endsWith("pulse")) {
relayPulseMode(value);
return;
}
// Get relay ID
relayID = t.substring(strlen(MQTT_TOPIC_RELAY)+1).toInt();
if (relayID >= relayCount()) {
DEBUG_MSG_P(PSTR("[RELAY] Wrong relayID (%d)\n"), relayID);
return;
}
}
// Action to perform
if (value == 0) {
relayStatus(relayID, false, mqttForward());
relayStatus(relayID, false, mqttForward(), !is_group_topic);
} else if (value == 1) {
relayStatus(relayID, true, mqttForward());
relayStatus(relayID, true, mqttForward(), !is_group_topic);
} else if (value == 2) {
relayToggle(relayID);
relayToggle(relayID, true, true);
}
}
@ -564,7 +628,6 @@ void relaySetup() {
for (unsigned char i=0; i < DUMMY_RELAY_COUNT; i++) {
_relays.push_back((relay_t) {0, RELAY_TYPE_NORMAL});
_relays[i].scheduled = false;
}
#else
@ -596,8 +659,7 @@ void relaySetup() {
#if WEB_SUPPORT
relaySetupAPI();
wsOnSendRegister(_relayWebSocketOnSend);
wsOnActionRegister(_relayWebSocketOnAction);
relaySetupWS();
#endif
#if MQTT_SUPPORT
@ -614,10 +676,11 @@ void relayLoop(void) {
for (id = 0; id < _relays.size(); id++) {
unsigned int currentTime = millis();
bool status = _relays[id].scheduledStatus;
unsigned int current_time = millis();
bool status = _relays[id].target_status;
if (_relays[id].scheduled && currentTime >= _relays[id].scheduledStatusTime) {
if ((_relays[id].current_status != status)
&& (current_time >= _relays[id].change_time)) {
DEBUG_MSG_P(PSTR("[RELAY] #%d set to %s\n"), id, status ? "ON" : "OFF");
@ -629,9 +692,9 @@ void relayLoop(void) {
ledStatus(_relays[id].led - 1, status);
}
// Send MQTT report if requested
// Send MQTT
#if MQTT_SUPPORT
if (_relays[id].scheduledReport) relayMQTT(id);
relayMQTT(id);
#endif
if (!recursive) {
@ -639,7 +702,7 @@ void relayLoop(void) {
relaySync(id);
_relaySaveTicker.once_ms(RELAY_SAVE_DELAY, relaySave);
#if WEB_SUPPORT
relayWS();
_relayWebSocketUpdate();
#endif
}
@ -651,8 +714,8 @@ void relayLoop(void) {
relayInfluxDB(id);
#endif
_relays[id].scheduled = false;
_relays[id].scheduledReport = false;
_relays[id].report = false;
_relays[id].group_report = false;
}


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


+ 70
- 34
code/espurna/ws.ino View File

@ -106,8 +106,9 @@ void _wsParse(AsyncWebSocketClient *client, uint8_t * payload, size_t length) {
bool changedMQTT = false;
#endif
unsigned int network = 0;
unsigned int wifiIdx = 0;
unsigned int dczRelayIdx = 0;
unsigned int mqttGroupIdx = 0;
String adminPass;
for (unsigned int i=0; i<config.size(); i++) {
@ -118,6 +119,44 @@ void _wsParse(AsyncWebSocketClient *client, uint8_t * payload, size_t length) {
// Skip firmware filename
if (key.equals("filename")) continue;
// -----------------------------------------------------------------
// GENERAL
// -----------------------------------------------------------------
// Web mode (normal or password)
if (key == "webMode") {
webMode = value.toInt();
continue;
}
// HTTP port
if (key == "webPort") {
if ((value.toInt() == 0) || (value.toInt() == 80)) {
save = changed = true;
delSetting(key);
continue;
}
}
// Check password
if (key == "adminPass1") {
adminPass = value;
continue;
}
if (key == "adminPass2") {
if (!value.equals(adminPass)) {
wsSend_P(client_id, PSTR("{\"message\": 7}"));
return;
}
if (value.length() == 0) continue;
wsSend_P(client_id, PSTR("{\"action\": \"reload\"}"));
key = String("adminPass");
}
// -----------------------------------------------------------------
// POWER
// -----------------------------------------------------------------
#if POWER_PROVIDER != POWER_PROVIDER_NONE
if (key == "pwrExpectedP") {
@ -154,6 +193,10 @@ void _wsParse(AsyncWebSocketClient *client, uint8_t * payload, size_t length) {
#endif
// -----------------------------------------------------------------
// DOMOTICZ
// -----------------------------------------------------------------
#if DOMOTICZ_SUPPORT
if (key == "dczRelayIdx") {
@ -168,55 +211,48 @@ void _wsParse(AsyncWebSocketClient *client, uint8_t * payload, size_t length) {
#endif
// Web portions
if (key == "webPort") {
if ((value.toInt() == 0) || (value.toInt() == 80)) {
save = changed = true;
delSetting(key);
continue;
}
}
// -----------------------------------------------------------------
// MQTT GROUP TOPICS
// -----------------------------------------------------------------
if (key == "webMode") {
webMode = value.toInt();
continue;
}
#if MQTT_SUPPORT
// Check password
if (key == "adminPass1") {
adminPass = value;
continue;
}
if (key == "adminPass2") {
if (!value.equals(adminPass)) {
wsSend_P(client_id, PSTR("{\"message\": 7}"));
return;
if (key == "mqttGroup") {
key = key + String(mqttGroupIdx);
}
if (key == "mqttGroupInv") {
key = key + String(mqttGroupIdx);
++mqttGroupIdx;
}
if (value.length() == 0) continue;
wsSend_P(client_id, PSTR("{\"action\": \"reload\"}"));
key = String("adminPass");
}
#endif
// -----------------------------------------------------------------
// WIFI
// -----------------------------------------------------------------
if (key == "ssid") {
key = key + String(network);
key = key + String(wifiIdx);
}
if (key == "pass") {
key = key + String(network);
key = key + String(wifiIdx);
}
if (key == "ip") {
key = key + String(network);
key = key + String(wifiIdx);
}
if (key == "gw") {
key = key + String(network);
key = key + String(wifiIdx);
}
if (key == "mask") {
key = key + String(network);
key = key + String(wifiIdx);
}
if (key == "dns") {
key = key + String(network);
++network;
key = key + String(wifiIdx);
++wifiIdx;
}
// -----------------------------------------------------------------
if (value != getSetting(key)) {
setSetting(key, value);
save = changed = true;
@ -228,7 +264,7 @@ void _wsParse(AsyncWebSocketClient *client, uint8_t * payload, size_t length) {
}
if (webMode == WEB_MODE_NORMAL) {
if (wifiClean(network)) save = changed = true;
if (wifiClean(wifiIdx)) save = changed = true;
}
// Save settings


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

@ -79,8 +79,9 @@
.pure-g {
margin-bottom: 20px;
}
legend {
.pure-g legend {
font-weight: bold;
letter-spacing: 0;
}
.l-box {
padding-right: 1px;


+ 39
- 0
code/html/custom.js View File

@ -405,6 +405,23 @@ function addNetwork() {
}
function addRelayGroup() {
var numGroups = $("#relayGroups > div").length;
var tabindex = 200 + numGroups * 2;
var template = $("#relayGroupTemplate").children();
var line = $(template).clone();
var element = $("span.relay_id", line);
if (element.length) element.html(numGroups+1);
$(line).find("input").each(function() {
$(this).attr("tabindex", tabindex++);
});
line.appendTo("#relayGroups");
return line;
}
function initColorRGB() {
// check if already initialized
@ -694,6 +711,28 @@ function processData(data) {
}
// Relay groups
if (key == "relayGroups") {
var groups = data.relayGroups;
for (var i in groups) {
// add a new row
var line = addRelayGroup();
// fill in the blanks
var group = data.relayGroups[i];
Object.keys(group).forEach(function(key) {
var element = $("input[name=" + key + "]", line);
if (element.length) element.val(group[key]);
});
}
return;
}
// Domoticz
if (key == "dczRelayIdx") {
var idxs = data.dczRelayIdx;


+ 85
- 43
code/html/index.html View File

@ -98,6 +98,10 @@
<a href="#" class="pure-menu-link" data="panel-ntp">NTP</a>
</li>
<li class="pure-menu-item">
<a href="#" class="pure-menu-link" data="panel-relay">SWITCHES</a>
</li>
<li class="pure-menu-item module module-color">
<a href="#" class="pure-menu-link" data="panel-color">LIGHTS</a>
</li>
@ -305,6 +309,70 @@
<div class="pure-u-1 pure-u-md-3-4 hint">This name will identify this device in your network (http://&lt;hostname&gt;.local). For this setting to take effect you should restart the wifi interface clicking the "Reconnect" button.</div>
</div>
<div class="pure-g">
<label class="pure-u-1 pure-u-md-1-4" for="btnDelay">Double click delay</label>
<input name="btnDelay" class="pure-u-1 pure-u-md-3-4" type="number" action="reset" min="0" step="100" max="1000" tabindex="6" />
<div class="pure-u-0 pure-u-md-1-4">&nbsp;</div>
<div class="pure-u-1 pure-u-md-3-4 hint">Delay in milliseconds to detect a double click (from 0 to 1000ms).<br />
The lower this number the faster the device will respond to button clicks but the harder it will be to get a double click.
Increase this number if you are having trouble to double click the button.
Set this value to 0 to disable double click. You won't be able to set the device in AP mode manually but your device will respond immediately to button clicks.<br />
You will have to <strong>reset the device</strong> after updating for this setting to apply.
</div>
</div>
<div class="pure-g module module-alexa">
<div class="pure-u-1 pure-u-sm-1-4"><label for="alexaEnabled">Alexa integration</label></div>
<div class="pure-u-1 pure-u-sm-1-4"><input type="checkbox" name="alexaEnabled" tabindex="13" /></div>
</div>
<div class="pure-g module module-ha">
<div class="pure-u-1 pure-u-sm-1-4"><label for="haEnabled">Home Assistant</label></div>
<div class="pure-u-1 pure-u-sm-1-4"><input type="checkbox" name="haEnabled" tabindex="14" /></div>
<div class="pure-u-0 pure-u-md-1-2">&nbsp;</div>
<div class="pure-u-0 pure-u-md-1-4">&nbsp;</div>
<div class="pure-u-1 pure-u-md-3-4 hint">
Home Assistant auto-discovery feature. Enable and save to add the device to your HA console.
When using a colour light you might want to disable CSS style so Home Assistant can parse the color.
</div>
</div>
<div class="pure-g module module-ha">
<label class="pure-u-1 pure-u-md-1-4" for="haPrefix">Home Assistant Prefix</label>
<input class="pure-u-1 pure-u-md-1-4" name="haPrefix" type="text" tabindex="15" />
</div>
<div class="pure-g module module-ds module-dht">
<label class="pure-u-1 pure-u-sm-1-4" for="tmpUnits">Temperature units</label>
<div class="pure-u-1 pure-u-sm-1-4"><input type="radio" name="tmpUnits" tabindex="16" value="0"> Celsius (&deg;C)</input></div>
<div class="pure-u-1 pure-u-sm-1-4"><input type="radio" name="tmpUnits" tabindex="17" value="1"> Fahrenheit (&deg;F)</input></div>
</div>
<div class="pure-g module module-ds module-dht">
<label class="pure-u-1 pure-u-md-1-4" for="tmpCorrection">Temperature correction</label>
<input name="tmpCorrection" class="pure-u-1 pure-u-md-1-4" type="number" action="reset" min="-100" step="0.1" max="100" tabindex="18" />
<div class="pure-u-0 pure-u-md-1-2">&nbsp;</div>
<div class="pure-u-0 pure-u-md-1-4">&nbsp;</div>
<div class="pure-u-1 pure-u-md-3-4 hint">
Temperature correction value is added to the measured value which may be inaccurate due to many factors. The value can be negative.
</div>
</div>
</fieldset>
</div>
</div>
<div class="panel" id="panel-relay">
<div class="header">
<h1>SWITCHES</h1>
<h2>Switch configuration</h2>
</div>
<div class="page">
<fieldset>
<div class="pure-g">
<label class="pure-u-1 pure-u-md-1-4" for="relayMode">Switch boot mode</label>
<div class="pure-u-1 pure-u-md-3-4">
@ -354,55 +422,16 @@
</div>
<div class="pure-g">
<label class="pure-u-1 pure-u-md-1-4" for="btnDelay">Double click delay</label>
<input name="btnDelay" class="pure-u-1 pure-u-md-3-4" type="number" action="reset" min="0" step="100" max="1000" tabindex="6" />
<div class="pure-u-0 pure-u-md-1-4">&nbsp;</div>
<div class="pure-u-1 pure-u-md-3-4 hint">Delay in milliseconds to detect a double click (from 0 to 1000ms).<br />
The lower this number the faster the device will respond to button clicks but the harder it will be to get a double click.
Increase this number if you are having trouble to double click the button.
Set this value to 0 to disable double click. You won't be able to set the device in AP mode manually but your device will respond immediately to button clicks.<br />
You will have to <strong>reset the device</strong> after updating for this setting to apply.
</div>
</div>
<div class="pure-g module module-alexa">
<div class="pure-u-1 pure-u-sm-1-4"><label for="alexaEnabled">Alexa integration</label></div>
<div class="pure-u-1 pure-u-sm-1-4"><input type="checkbox" name="alexaEnabled" tabindex="13" /></div>
</div>
<div class="pure-g module module-ha">
<div class="pure-u-1 pure-u-sm-1-4"><label for="haEnabled">Home Assistant</label></div>
<div class="pure-u-1 pure-u-sm-1-4"><input type="checkbox" name="haEnabled" tabindex="14" /></div>
<div class="pure-u-0 pure-u-md-1-2">&nbsp;</div>
<div class="pure-u-0 pure-u-md-1-4">&nbsp;</div>
<div class="pure-u-1 pure-u-md-3-4 hint">
Home Assistant auto-discovery feature. Enable and save to add the device to your HA console.
When using a colour light you might want to disable CSS style so Home Assistant can parse the color.
</div>
<legend>MQTT group topics</legend>
</div>
<div class="pure-g module module-ha">
<label class="pure-u-1 pure-u-md-1-4" for="haPrefix">Home Assistant Prefix</label>
<input class="pure-u-1 pure-u-md-1-4" name="haPrefix" type="text" tabindex="15" />
</div>
<div id="relayGroups" class="module module-mqtt">
<div class="pure-g module module-ds module-dht">
<label class="pure-u-1 pure-u-sm-1-4" for="tmpUnits">Temperature units</label>
<div class="pure-u-1 pure-u-sm-1-4"><input type="radio" name="tmpUnits" tabindex="16" value="0"> Celsius (&deg;C)</input></div>
<div class="pure-u-1 pure-u-sm-1-4"><input type="radio" name="tmpUnits" tabindex="17" value="1"> Fahrenheit (&deg;F)</input></div>
</div>
<div class="pure-g module module-ds module-dht">
<label class="pure-u-1 pure-u-md-1-4" for="tmpCorrection">Temperature correction</label>
<input name="tmpCorrection" class="pure-u-1 pure-u-md-1-4" type="number" action="reset" min="-100" step="0.1" max="100" tabindex="18" />
<div class="pure-u-0 pure-u-md-1-2">&nbsp;</div>
<div class="pure-u-0 pure-u-md-1-4">&nbsp;</div>
<div class="pure-u-1 pure-u-md-3-4 hint">
Temperature correction value is added to the measured value which may be inaccurate due to many factors. The value can be negative.
</div>
</div>
</fieldset>
</div>
</div>
@ -967,7 +996,9 @@
<fieldset>
<legend>&nbsp;Switch <span></span>&nbsp;</legend>
<div class="pure-g">
<legend>&nbsp;Switch <span></span>&nbsp;</legend>
</div>
<div class="pure-g">
<label class="pure-u-1-2 pure-u-sm-1-4">Switch ON</label>
@ -1042,6 +1073,17 @@
</div>
</div>
<div id="relayGroupTemplate" class="template">
<div class="pure-g">
<div class="pure-u-1 pure-u-sm-1-4"><label>Switch <span class="relay_id"></span></label></div>
<div class="pure-u-1 pure-u-sm-1-2"><input class="pure-u-sm-23-24" name="mqttGroup" tabindex="0" data="0" /></div>
<select class="pure-u-1 pure-u-sm-1-4" name="mqttGroupInv">
<option value=0>Same</option>
<option value=1>Inverse</option>
</select>
</div>
</div>
<div id="idxTemplate" class="template">
<div class="pure-g">
<label class="pure-u-1 pure-u-sm-1-4" for="dczRelayIdx">Switch<span class="id"></span> IDX</label>


Loading…
Cancel
Save