diff --git a/.gitmodules b/.gitmodules index b380c9d1..e89abbbe 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "code/lib/HLW8012"] path = code/lib/HLW8012 url = https://bitbucket.org/xoseperez/hlw8012.git +[submodule "code/lib/fauxmoESP"] + path = code/lib/fauxmoESP + url = https://bitbucket.org/xoseperez/fauxmoesp.git diff --git a/code/lib/Embedis b/code/lib/Embedis deleted file mode 120000 index 284c28c0..00000000 --- a/code/lib/Embedis +++ /dev/null @@ -1 +0,0 @@ -../vendor/embedis/src \ No newline at end of file diff --git a/code/lib/fauxmoESP b/code/lib/fauxmoESP new file mode 160000 index 00000000..a04b0f77 --- /dev/null +++ b/code/lib/fauxmoESP @@ -0,0 +1 @@ +Subproject commit a04b0f77b59e19698fdeb087aeb60e18a5adf858 diff --git a/code/platformio.custom.ini b/code/platformio.custom.ini index dc59f9b3..6250d0e6 100644 --- a/code/platformio.custom.ini +++ b/code/platformio.custom.ini @@ -12,7 +12,7 @@ env_default = node-debug [common] platform = espressif8266 framework = arduino -lib_install = 19,31,44,64,305,306,346,408,727 +lib_install = 19,31,44,64,305,306,346,359,408,727 extra_script = pio_hooks.py [ota] diff --git a/code/platformio.ini b/code/platformio.ini index 818bd510..8accde12 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -2,7 +2,7 @@ env_default = node-debug [common] -lib_install = 19,31,44,64,305,306,346,408,727 +lib_install = 19,31,44,64,305,306,346,359,408,727 [env:sonoff-debug] platform = espressif8266 @@ -81,12 +81,12 @@ upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 [env:node-debug] -platform = espressif8266 +platform = espressif8266_stage framework = arduino lib_install = ${common.lib_install} extra_script = pio_hooks.py board = nodemcuv2 -build_flags = -DNODEMCUV2 -DDEBUG_PORT=Serial +build_flags = -DNODEMCUV2 -DDEBUG_PORT=Serial -DDEBUG_FAUXMO=Serial [env:node-debug-ota] platform = espressif8266 diff --git a/code/platformio.official.ini b/code/platformio.official.ini index 818bd510..1e9a3405 100644 --- a/code/platformio.official.ini +++ b/code/platformio.official.ini @@ -2,7 +2,7 @@ env_default = node-debug [common] -lib_install = 19,31,44,64,305,306,346,408,727 +lib_install = 19,31,44,64,305,306,346,359,408,727 [env:sonoff-debug] platform = espressif8266 diff --git a/code/src/defaults.h b/code/src/defaults.h index 60be3d66..a0dd835c 100644 --- a/code/src/defaults.h +++ b/code/src/defaults.h @@ -151,3 +151,5 @@ #define POW_POWER_TOPIC "/power" #define POW_UPDATE_INTERVAL 10000 #define POW_REPORT_EVERY 6 + +#define FAUXMO_ENABLED 1 diff --git a/code/src/fauxmo.ino b/code/src/fauxmo.ino new file mode 100644 index 00000000..f1459c0f --- /dev/null +++ b/code/src/fauxmo.ino @@ -0,0 +1,29 @@ +/* + +ESPurna +DHT MODULE + +Copyright (C) 2016 by Xose PĂ©rez + +*/ + +#include + +fauxmoESP fauxmo; + +// ----------------------------------------------------------------------------- +// FAUXMO +// ----------------------------------------------------------------------------- + +void fauxmoConfigure() { + fauxmo.setDeviceName(getSetting("hostname", HOSTNAME).c_str()); + fauxmo.enable(getSetting('fauxmoEnabled', String(FAUXMO_ENABLED)).toInt() == 1); +} + +void fauxmoSetup() { + fauxmoConfigure(); + fauxmo.onMessage([](const char * state) { + DEBUG_MSG("[FAUXMO] State: %s\n", state); + (state[0] == '1') ? switchRelayOn() : switchRelayOff(); + }); +} diff --git a/code/src/main.ino b/code/src/main.ino index 7b8e90ba..ff98a592 100644 --- a/code/src/main.ino +++ b/code/src/main.ino @@ -147,6 +147,7 @@ void setup() { mqttSetup(); webSetup(); ntpSetup(); + fauxmoSetup(); #if ENABLE_NOFUSS nofussSetup();