diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index 3d06436b..2d0d90f9 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -106,4 +106,4 @@ // FAUXO // ----------------------------------------------------------------------------- -#define FAUXMO_ENABLED 0 +#define FAUXMO_ENABLED 1 diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index 15af90a6..a3024a28 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -22,9 +22,13 @@ //#define ENABLE_EMON 1 //#define ENABLE_HLW8018 1 //#define ENABLE_RF 1 -//#define ENABLE_FAUXMO 1 +//#define ENABLE_FAUXMO 0 //#define ENABLE_NOFUSS 1 +#ifndef ENABLE_FAUXMO + #define ENABLE_FAUXMO 1 +#endif + // ----------------------------------------------------------------------------- // Development boards // ----------------------------------------------------------------------------- diff --git a/code/espurna/espurna.ino b/code/espurna/espurna.ino index 874b6744..e91a6d30 100644 --- a/code/espurna/espurna.ino +++ b/code/espurna/espurna.ino @@ -150,6 +150,9 @@ void loop() { mqttLoop(); ntpLoop(); + #if ENABLE_FAUXMO + fauxmoLoop(); + #endif #ifndef SONOFF_DUAL settingsLoop(); #endif diff --git a/code/espurna/fauxmo.ino b/code/espurna/fauxmo.ino index 1d131892..939f1e94 100644 --- a/code/espurna/fauxmo.ino +++ b/code/espurna/fauxmo.ino @@ -32,15 +32,14 @@ void fauxmoSetup() { fauxmo.addDevice((hostname + "_" + i).c_str()); } } - fauxmo.onMessage([relays](const char * name, bool state) { + fauxmo.onMessage([relays](unsigned char device_id, const char * name, bool state) { DEBUG_MSG("[FAUXMO] %s state: %s\n", name, state ? "ON" : "OFF"); - unsigned int id = 0; - if (relays > 1) { - id = name[strlen(name)-1] - '0'; - if (id >= relays) id = 0; - } - relayStatus(id, state); + relayStatus(device_id, state); }); } +void fauxmoLoop() { + fauxmo.handle(); +} + #endif diff --git a/code/platformio.ini b/code/platformio.ini index 3f36291a..94bfd8b2 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -12,19 +12,18 @@ lib_deps = ESPAsyncTCP ESPAsyncWebServer https://github.com/marvinroger/async-mqtt-client - ESPAsyncUDP Embedis NtpClientLib OneWire DallasTemperature JustWifi HLW8012 - FauxmoESP + https://bitbucket.org/xoseperez/fauxmoesp.git https://bitbucket.org/xoseperez/nofuss.git https://bitbucket.org/xoseperez/emonliteesp.git https://bitbucket.org/xoseperez/debounceevent.git https://github.com/xoseperez/RemoteSwitch-arduino-library.git -lib_ignore = FauxmoESP, ESPAsyncUDP +lib_ignore = # ------------------------------------------------------------------------------ @@ -35,7 +34,7 @@ board = d1_mini lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} extra_script = pio_hooks.py -build_flags = -g -DD1_RELAYSHIELD -DDEBUG_PORT=Serial -DNOWSAUTH +build_flags = -g -DD1_RELAYSHIELD -DDEBUG_PORT=Serial -DDEBUG_FAUXMO=Serial -DNOWSAUTH [env:d1-debug-ota] platform = espressif8266 @@ -44,7 +43,7 @@ board = d1_mini lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} extra_script = pio_hooks.py -build_flags = -g -DD1_RELAYSHIELD -DDEBUG_PORT=Serial -DNOWSAUTH +build_flags = -g -DD1_RELAYSHIELD -DDEBUG_PORT=Serial -DDEBUG_FAUXMO=Serial -DNOWSAUTH upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 @@ -56,7 +55,7 @@ board = nodemcuv2 lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} extra_script = pio_hooks.py -build_flags = -g -DNODEMCUV2 -DDEBUG_PORT=Serial -DNOWSAUTH +build_flags = -g -DNODEMCUV2 -DDEBUG_PORT=Serial -DDEBUG_FAUXMO=Serial -DNOWSAUTH [env:node-debug-ota] platform = espressif8266 @@ -65,7 +64,7 @@ board = nodemcuv2 lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} extra_script = pio_hooks.py -build_flags = -g -DNODEMCUV2 -DDEBUG_PORT=Serial -DNOWSAUTH +build_flags = -g -DNODEMCUV2 -DDEBUG_PORT=Serial -DDEBUG_FAUXMO=Serial -DNOWSAUTH upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266