Browse Source

Merge branch 'dev' into webupgrade

Conflicts:
	code/espurna/data/index.html.gz
	code/espurna/static/index.html.gz.h
fastled
Xose Pérez 7 years ago
parent
commit
3683011239
14 changed files with 454 additions and 92 deletions
  1. +2
    -0
      code/espurna/config/arduino.h
  2. +16
    -16
      code/espurna/config/general.h
  3. +21
    -4
      code/espurna/config/hardware.h
  4. +2
    -0
      code/espurna/config/prototypes.h
  5. BIN
      code/espurna/data/index.html.gz
  6. +16
    -4
      code/espurna/debug.ino
  7. +3
    -0
      code/espurna/espurna.ino
  8. +269
    -0
      code/espurna/hardware.ino
  9. +21
    -0
      code/espurna/light.ino
  10. +1
    -0
      code/espurna/mqtt.ino
  11. +26
    -0
      code/espurna/settings.ino
  12. +61
    -61
      code/espurna/static/index.html.gz.h
  13. +7
    -7
      code/html/index.html
  14. +9
    -0
      code/platformio.ini

+ 2
- 0
code/espurna/config/arduino.h View File

@ -32,6 +32,8 @@
//#define SONOFF_SV //#define SONOFF_SV
//#define SONOFF_POW //#define SONOFF_POW
//#define SONOFF_DUAL //#define SONOFF_DUAL
//#define ITEAD_1CH_INCHING
//#define ITEAD_MOTOR
//#define SONOFF_4CH //#define SONOFF_4CH
//#define ESP_RELAY_BOARD //#define ESP_RELAY_BOARD
//#define ECOPLUG //#define ECOPLUG


+ 16
- 16
code/espurna/config/general.h View File

@ -146,22 +146,22 @@
#define MQTT_SKIP_RETAINED 1 #define MQTT_SKIP_RETAINED 1
#define MQTT_SKIP_TIME 1000 #define MQTT_SKIP_TIME 1000
#define MQTT_TOPIC_ACTION "/action"
#define MQTT_TOPIC_RELAY "/relay"
#define MQTT_TOPIC_LED "/led"
#define MQTT_TOPIC_COLOR "/color"
#define MQTT_TOPIC_BUTTON "/button"
#define MQTT_TOPIC_IP "/ip"
#define MQTT_TOPIC_VERSION "/version"
#define MQTT_TOPIC_UPTIME "/uptime"
#define MQTT_TOPIC_FREEHEAP "/freeheap"
#define MQTT_TOPIC_VCC "/vcc"
#define MQTT_TOPIC_STATUS "/status"
#define MQTT_TOPIC_MAC "/mac"
#define MQTT_TOPIC_RSSI "/rssi"
#define MQTT_TOPIC_APP "/app"
#define MQTT_TOPIC_INTERVAL "/interval"
#define MQTT_TOPIC_HOSTNAME "/hostname"
#define MQTT_TOPIC_ACTION "action"
#define MQTT_TOPIC_RELAY "relay"
#define MQTT_TOPIC_LED "led"
#define MQTT_TOPIC_COLOR "color"
#define MQTT_TOPIC_BUTTON "button"
#define MQTT_TOPIC_IP "ip"
#define MQTT_TOPIC_VERSION "version"
#define MQTT_TOPIC_UPTIME "uptime"
#define MQTT_TOPIC_FREEHEAP "freeheap"
#define MQTT_TOPIC_VCC "vcc"
#define MQTT_TOPIC_STATUS "status"
#define MQTT_TOPIC_MAC "mac"
#define MQTT_TOPIC_RSSI "rssi"
#define MQTT_TOPIC_APP "app"
#define MQTT_TOPIC_INTERVAL "interval"
#define MQTT_TOPIC_HOSTNAME "hostname"
// Periodic reports // Periodic reports
#define MQTT_REPORT_STATUS 1 #define MQTT_REPORT_STATUS 1


+ 21
- 4
code/espurna/config/hardware.h View File

@ -44,6 +44,23 @@
#define LED1_PIN 2 #define LED1_PIN 2
#define LED1_PIN_INVERSE 1 #define LED1_PIN_INVERSE 1
// -----------------------------------------------------------------------------
// ESPurna
// -----------------------------------------------------------------------------
#elif defined(ESPURNA_H)
#define MANUFACTURER "TINKERMAN"
#define DEVICE "ESPURNA_H"
#define RELAY1_PIN 12
#define RELAY1_PIN_INVERSE 1
#define LED1_PIN 5
#define LED1_PIN_INVERSE 0
#define BUTTON1_PIN 4
#define BUTTON1_RELAY 1
#define BUTTON1_MODE BUTTON_SWITCH
#define ENABLE_POW 1
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Itead Studio boards // Itead Studio boards
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -248,8 +265,8 @@
#elif defined(AI_LIGHT) #elif defined(AI_LIGHT)
#define MANUFACTURER "AI THINKER"
#define DEVICE "AI LIGHT"
#define MANUFACTURER "AI_THINKER"
#define DEVICE "AI_LIGHT"
#define RELAY_PROVIDER RELAY_PROVIDER_LIGHT #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT
#define LIGHT_PROVIDER LIGHT_PROVIDER_MY9192 #define LIGHT_PROVIDER LIGHT_PROVIDER_MY9192
@ -259,8 +276,8 @@
#elif defined(LED_CONTROLLER) #elif defined(LED_CONTROLLER)
#define MANUFACTURER "MAGIC HOME"
#define DEVICE "LED CONTROLLER"
#define MANUFACTURER "MAGIC_HOME"
#define DEVICE "LED_CONTROLLER"
#define LED1_PIN 2 #define LED1_PIN 2
#define LED1_PIN_INVERSE 1 #define LED1_PIN_INVERSE 1
#define RELAY_PROVIDER RELAY_PROVIDER_LIGHT #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT


+ 2
- 0
code/espurna/config/prototypes.h View File

@ -11,6 +11,8 @@ void apiRegister(const char * url, const char * key, apiGetCallbackFunction getF
void mqttRegister(void (*callback)(unsigned int, const char *, const char *)); void mqttRegister(void (*callback)(unsigned int, const char *, const char *));
String mqttSubtopic(char * topic); String mqttSubtopic(char * topic);
template<typename T> bool setSetting(const String& key, T value); template<typename T> bool setSetting(const String& key, T value);
template<typename T> bool setSetting(const String& key, unsigned int index, T value);
template<typename T> String getSetting(const String& key, T defaultValue); template<typename T> String getSetting(const String& key, T defaultValue);
template<typename T> String getSetting(const String& key, unsigned int index, T defaultValue);
template<typename T> void domoticzSend(const char * key, T value); template<typename T> void domoticzSend(const char * key, T value);
template<typename T> void domoticzSend(const char * key, T nvalue, const char * svalue); template<typename T> void domoticzSend(const char * key, T nvalue, const char * svalue);

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


+ 16
- 4
code/espurna/debug.ino View File

@ -20,16 +20,22 @@ void debugSend(const char * format, ...) {
va_list args; va_list args;
va_start(args, format); va_start(args, format);
ets_vsnprintf(buffer, DEBUG_MESSAGE_MAX_LENGTH, format, args);
int len = ets_vsnprintf(buffer, DEBUG_MESSAGE_MAX_LENGTH, format, args);
va_end(args); va_end(args);
#ifdef DEBUG_PORT #ifdef DEBUG_PORT
DEBUG_PORT.printf(buffer); DEBUG_PORT.printf(buffer);
if (len > DEBUG_MESSAGE_MAX_LENGTH) {
DEBUG_PORT.printf(" (...)\n");
}
#endif #endif
#ifdef DEBUG_UDP_IP #ifdef DEBUG_UDP_IP
udpDebug.beginPacket(DEBUG_UDP_IP, DEBUG_UDP_PORT); udpDebug.beginPacket(DEBUG_UDP_IP, DEBUG_UDP_PORT);
udpDebug.write(buffer); udpDebug.write(buffer);
if (len > DEBUG_MESSAGE_MAX_LENGTH) {
udpDebug.write(" (...)\n");
}
udpDebug.endPacket(); udpDebug.endPacket();
#endif #endif
@ -37,23 +43,29 @@ void debugSend(const char * format, ...) {
void debugSend_P(PGM_P format, ...) { void debugSend_P(PGM_P format, ...) {
char buffer[DEBUG_MESSAGE_MAX_LENGTH+1];
char f[DEBUG_MESSAGE_MAX_LENGTH+1]; char f[DEBUG_MESSAGE_MAX_LENGTH+1];
memcpy_P(f, format, DEBUG_MESSAGE_MAX_LENGTH); memcpy_P(f, format, DEBUG_MESSAGE_MAX_LENGTH);
char buffer[DEBUG_MESSAGE_MAX_LENGTH+1];
va_list args; va_list args;
va_start(args, format); va_start(args, format);
ets_vsnprintf(buffer, DEBUG_MESSAGE_MAX_LENGTH, f, args);
int len = ets_vsnprintf(buffer, DEBUG_MESSAGE_MAX_LENGTH, f, args);
va_end(args); va_end(args);
#ifdef DEBUG_PORT #ifdef DEBUG_PORT
DEBUG_PORT.printf(buffer); DEBUG_PORT.printf(buffer);
if (len > DEBUG_MESSAGE_MAX_LENGTH) {
DEBUG_PORT.printf(" (...)\n");
}
#endif #endif
#ifdef DEBUG_UDP_IP #ifdef DEBUG_UDP_IP
udpDebug.beginPacket(DEBUG_UDP_IP, DEBUG_UDP_PORT); udpDebug.beginPacket(DEBUG_UDP_IP, DEBUG_UDP_PORT);
udpDebug.write(buffer); udpDebug.write(buffer);
if (len > DEBUG_MESSAGE_MAX_LENGTH) {
udpDebug.write(" (...)\n");
}
udpDebug.endPacket(); udpDebug.endPacket();
#endif #endif


+ 3
- 0
code/espurna/espurna.ino View File

@ -197,6 +197,9 @@ void setup() {
powerMonitorSetup(); powerMonitorSetup();
#endif #endif
// Prepare configuration for version 2.0
hwUpwardsCompatibility();
} }
void loop() { void loop() {


+ 269
- 0
code/espurna/hardware.ino View File

@ -0,0 +1,269 @@
/*
HARDWARE MODULE
Copyright (C) 2016-2017 by Xose Pérez <xose dot perez at gmail dot com>
*/
/*
The goal of this file is to store board configuration values in EEPROM so
the migration to future version 2 will be straigh forward.
*/
#define RELAY_PROVIDER_RELAY 0
#define RELAY_PROVIDER_DUAL 1
#define RELAY_PROVIDER_LIGHT 2
#define LIGHT_PROVIDER_NONE 0
#define LIGHT_PROVIDER_WS2812 1
#define LIGHT_PROVIDER_RGB 2
#define LIGHT_PROVIDER_RGBW 3
#define LIGHT_PROVIDER_MY9192 4
void hwUpwardsCompatibility() {
unsigned int board = getSetting("board", 0).toInt();
if (board > 0) return;
#if NODEMCUV2
setSetting("board", 2);
setSetting("ledGPIO", 1, 2);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
#endif
#if D1_RELAYSHIELD
setSetting("board", 3);
setSetting("ledGPIO", 1, 2);
setSetting("ledLogic", 1, 1);
setSetting("relayGPIO", 1, 5);
setSetting("relayLogic", 1, 0);
#endif
#if SONOFF
setSetting("board", 4);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
#endif
#if SONOFF_TH
setSetting("board", 5);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
#endif
#if SONOFF_SV
setSetting("board", 6);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
#endif
#if SONOFF_TOUCH
setSetting("board", 7);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
#endif
#if SONOFF_POW
setSetting("board", 8);
setSetting("ledGPIO", 1, 15);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
#endif
#if SONOFF_DUAL
setSetting("board", 9);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnRelay", 3, 1);
setSetting("relayProvider", RELAY_PROVIDER_DUAL);
#endif
#if ITEAD_1CH_INCHING
setSetting("board", 10);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
#endif
#if SONOFF_4CH
setSetting("board", 11);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnGPIO", 2, 9);
setSetting("btnGPIO", 3, 10);
setSetting("btnGPIO", 4, 14);
setSetting("btnRelay", 1, 2);
setSetting("btnRelay", 2, 3);
setSetting("btnRelay", 3, 4);
setSetting("btnRelay", 4, 0);
setSetting("relayGPIO", 1, 12);
setSetting("relayGPIO", 2, 5);
setSetting("relayGPIO", 3, 4);
setSetting("relayGPIO", 4, 15);
setSetting("relayLogic", 1, 0);
setSetting("relayLogic", 2, 0);
setSetting("relayLogic", 3, 0);
setSetting("relayLogic", 4, 0);
#endif
#if SLAMPHER
setSetting("board", 12);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
#endif
#if S20
setSetting("board", 13);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
#endif
#if ESP_RELAY_BOARD
setSetting("board", 14);
setSetting("ledGPIO", 1, 16);
setSetting("ledLogic", 1, 0);
setSetting("btnGPIO", 1, 0);
setSetting("btnGPIO", 2, 2);
setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 2);
setSetting("relayGPIO", 1, 12);
setSetting("relayGPIO", 2, 13);
setSetting("relayLogic", 1, 0);
setSetting("relayLogic", 2, 0);
#endif
#if ECOPLUG
setSetting("board", 15);
setSetting("ledGPIO", 1, 2);
setSetting("ledLogic", 1, 0);
setSetting("btnGPIO", 1, 13);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 15);
setSetting("relayLogic", 1, 0);
#endif
#if WIFI_RELAY_NC
setSetting("board", 16);
setSetting("btnGPIO", 1, 12);
setSetting("btnGPIO", 2, 13);
setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 2);
setSetting("relayGPIO", 1, 2);
setSetting("relayGPIO", 2, 14);
setSetting("relayLogic", 1, 1);
setSetting("relayLogic", 2, 1);
#endif
#if WIFI_RELAY_NO
setSetting("board", 17);
setSetting("btnGPIO", 1, 12);
setSetting("btnGPIO", 2, 13);
setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 2);
setSetting("relayGPIO", 1, 2);
setSetting("relayGPIO", 2, 14);
setSetting("relayLogic", 1, 0);
setSetting("relayLogic", 2, 0);
#endif
#if MQTT_RELAY
setSetting("board", 18);
setSetting("ledGPIO", 1, 16);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
#endif
#if WIFI_RELAYS_BOARD_KIT
setSetting("board", 19);
setSetting("relayGPIO", 1, 0);
setSetting("relayLogic", 1, 1);
setSetting("relayGPIO", 2, 2);
setSetting("relayLogic", 2, 1);
#endif
#if AI_LIGHT
setSetting("board", 20);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_MY9192);
setSetting("myDIGPIO", 13);
setSetting("myDCKIGPIO", 15);
#endif
#if LED_CONTROLLER
setSetting("board", 21);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_RGB);
setSetting("ledGPIO", 1, 2);
setSetting("ledLogic", 1, 1);
setSetting("redGPIO", 14);
setSetting("greenGPIO", 5);
setSetting("blueGPIO", 12);
setSetting("whiteGPIO", 13);
setSetting("lightLogic", 1);
#endif
#if ITEAD_MOTOR
setSetting("board", 22);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
#endif
#if ESPURNA_H
setSetting("board", 23);
setSetting("ledGPIO", 1, 5);
setSetting("ledLogic", 1, 0);
setSetting("btnGPIO", 1, 4);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 1);
#endif
saveSettings();
}

+ 21
- 0
code/espurna/light.ino View File

@ -158,6 +158,24 @@ void lightMQTTCallback(unsigned int type, const char * topic, const char * paylo
} }
//------------------------------------------------------------------------------
// REST API
//------------------------------------------------------------------------------
void lightSetupAPI() {
// API entry points (protected with apikey)
apiRegister("/api/color", "color",
[](char * buffer, size_t len) {
snprintf(buffer, len, "%s", lightColor().c_str());
},
[](const char * payload) {
lightColor(payload, true, mqttForward());
}
);
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// SETUP // SETUP
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -169,6 +187,8 @@ void lightSetup() {
#endif #endif
#if (LIGHT_PROVIDER == LIGHT_PROVIDER_RGB) || (LIGHT_PROVIDER == LIGHT_PROVIDER_RGBW) #if (LIGHT_PROVIDER == LIGHT_PROVIDER_RGB) || (LIGHT_PROVIDER == LIGHT_PROVIDER_RGBW)
analogWriteRange(255);
analogWriteFreq(1000);
pinMode(RGBW_RED_PIN, OUTPUT); pinMode(RGBW_RED_PIN, OUTPUT);
pinMode(RGBW_GREEN_PIN, OUTPUT); pinMode(RGBW_GREEN_PIN, OUTPUT);
pinMode(RGBW_BLUE_PIN, OUTPUT); pinMode(RGBW_BLUE_PIN, OUTPUT);
@ -181,6 +201,7 @@ void lightSetup() {
lightColorRetrieve(); lightColorRetrieve();
mqttRegister(lightMQTTCallback); mqttRegister(lightMQTTCallback);
lightSetupAPI();
} }


+ 1
- 0
code/espurna/mqtt.ino View File

@ -47,6 +47,7 @@ void buildTopics() {
// Replace identifier // Replace identifier
mqttTopic = getSetting("mqttTopic", MQTT_TOPIC); mqttTopic = getSetting("mqttTopic", MQTT_TOPIC);
mqttTopic.replace("{identifier}", getSetting("hostname")); mqttTopic.replace("{identifier}", getSetting("hostname"));
if (!mqttTopic.endsWith("/")) mqttTopic = mqttTopic + "/";
} }
bool mqttForward() { bool mqttForward() {


+ 26
- 0
code/espurna/settings.ino View File

@ -172,12 +172,22 @@ void settingsLoop() {
embedis.process(); embedis.process();
} }
void moveSetting(const char * from, const char * to) {
String value = getSetting(from);
if (value.length() > 0) setSetting(to, value);
delSetting(from);
}
template<typename T> String getSetting(const String& key, T defaultValue) { template<typename T> String getSetting(const String& key, T defaultValue) {
String value; String value;
if (!Embedis::get(key, value)) value = String(defaultValue); if (!Embedis::get(key, value)) value = String(defaultValue);
return value; return value;
} }
template<typename T> String getSetting(const String& key, unsigned int index, T defaultValue) {
return getSetting(key + String(index), defaultValue);
}
String getSetting(const String& key) { String getSetting(const String& key) {
return getSetting(key, ""); return getSetting(key, "");
} }
@ -186,10 +196,26 @@ template<typename T> bool setSetting(const String& key, T value) {
return Embedis::set(key, String(value)); return Embedis::set(key, String(value));
} }
template<typename T> bool setSetting(const String& key, unsigned int index, T value) {
return setSetting(key + String(index), value);
}
bool delSetting(const String& key) { bool delSetting(const String& key) {
return Embedis::del(key); return Embedis::del(key);
} }
bool delSetting(const String& key, unsigned int index) {
return delSetting(key + String(index));
}
bool hasSetting(const String& key) {
return getSetting(key).length() != 0;
}
bool hasSetting(const String& key, unsigned int index) {
return getSetting(key, index, "").length() != 0;
}
void saveSettings() { void saveSettings() {
DEBUG_MSG_P(PSTR("[SETTINGS] Saving\n")); DEBUG_MSG_P(PSTR("[SETTINGS] Saving\n"));
#if not AUTO_SAVE #if not AUTO_SAVE


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


+ 7
- 7
code/html/index.html View File

@ -455,13 +455,13 @@
<input class="pure-u-1 pure-u-md-3-4" name="mqttTopic" type="text" size="20" tabindex="25" /> <input class="pure-u-1 pure-u-md-3-4" name="mqttTopic" type="text" size="20" tabindex="25" />
<div class="pure-u-0 pure-u-md-1-4">&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"> <div class="pure-u-1 pure-u-md-3-4 hint">
This is the root topic for this device. The {identifier} placeholder will be replaces by the device hostname.<br />
- <strong>&lt;root&gt;/relay/#</strong> Send a 0 or a 1 as a payload to this topic to switch it on or off. You can also send a 2 to toggle its current state. Replace # with the switch ID (starting from 0). If the board has only one switch it will be 0.<br />
- <strong>&lt;root&gt;/led/#</strong> Send a 0 or a 1 as a payload to this topic to set the onboard LED to the given state, send a 3 to turn it back to WIFI indicator. Replace # with the LED ID (starting from 0). If the board has only one LED it will be 0.<br />
- <strong>&lt;root&gt;/button/#</strong> For each button in the board subscribe to this topic to know when it is pressed (payload 1) or released (payload 0).<br />
- <strong>&lt;root&gt;/ip</strong> The device will report to this topic its IP.<br />
- <strong>&lt;root&gt;/version</strong> The device will report to this topic its firmware version on boot.<br />
- <strong>&lt;root&gt;/status</strong> The device will report a 1 to this topic every few minutes. Upon MQTT disconnecting this will be set to 0.
This is the root topic for this device. A trailing slash will be added if not preset. The {identifier} placeholder will be replaces by the device hostname.<br />
- <strong>&lt;root/&gt;relay/#</strong> Send a 0 or a 1 as a payload to this topic to switch it on or off. You can also send a 2 to toggle its current state. Replace # with the switch ID (starting from 0). If the board has only one switch it will be 0.<br />
<span class="module module-color">- <strong>&lt;root&gt;color</strong> The device will report the current color in #RRGGBB format to this topic. You can also set the color using this same topic.<br /></span>
- <strong>&lt;root/&gt;led/#</strong> Send a 0 or a 1 as a payload to this topic to set the onboard LED to the given state, send a 3 to turn it back to WIFI indicator. Replace # with the LED ID (starting from 0). If the board has only one LED it will be 0.<br />
- <strong>&lt;root/&gt;button/#</strong> For each button in the board subscribe to this topic to know when it is pressed (payload 1) or released (payload 0).<br />
- <strong>&lt;root/&gt;status</strong> The device will report a 1 to this topic every few minutes. Upon MQTT disconnecting this will be set to 0.<br />
- Other values reported (depending on the build) are: <strong>firmware</strong> and <strong>version</strong>, <strong>hostname</strong>, <strong>IP</strong>, <strong>MAC</strong>, signal strenth (<strong>RSSI</strong>), <strong>uptime</strong> (in seconds), <strong>free heap</strong> and <strong>power supply</strong>.
</div> </div>
</div> </div>


+ 9
- 0
code/platformio.ini View File

@ -82,6 +82,15 @@ upload_speed = 115200
upload_port = "192.168.4.1" upload_port = "192.168.4.1"
upload_flags = --auth=fibonacci --port 8266 upload_flags = --auth=fibonacci --port 8266
[env:espurna-debug]
platform = espressif8266
framework = arduino
board = esp12e
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
extra_script = pio_hooks.py
build_flags = ${common.build_flags} -DESPURNA_H
[env:sonoff-debug] [env:sonoff-debug]
platform = espressif8266 platform = espressif8266
framework = arduino framework = arduino


Loading…
Cancel
Save