From 75302719fae06cdca6772d73f8bddcfb0e02dddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Fri, 1 Sep 2017 16:07:38 +0200 Subject: [PATCH] Testing fauxmoESP 2.2.0 in beta --- code/espurna/alexa.ino | 17 +++++++++++++++-- code/platformio.ini | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/code/espurna/alexa.ino b/code/espurna/alexa.ino index a001dadd..35bf6c8b 100644 --- a/code/espurna/alexa.ino +++ b/code/espurna/alexa.ino @@ -16,6 +16,10 @@ fauxmoESP alexa; // ALEXA // ----------------------------------------------------------------------------- +bool _alexa_change = false; +unsigned int _alexa_device_id = 0; +bool _alexa_state = false; + void alexaConfigure() { alexa.enable(getSetting("alexaEnabled", ALEXA_ENABLED).toInt() == 1); } @@ -36,13 +40,22 @@ void alexaSetup() { } } alexa.onMessage([relays](unsigned char device_id, const char * name, bool state) { - DEBUG_MSG_P(PSTR("[ALEXA] %s state: %s\n"), name, state ? "ON" : "OFF"); - relayStatus(device_id, state); + _alexa_change = true; + _alexa_device_id = device_id; + _alexa_state = state; }); } void alexaLoop() { + alexa.handle(); + + if (_alexa_change) { + DEBUG_MSG_P(PSTR("[ALEXA] Device #%d state: %s\n"), _alexa_device_id, _alexa_state ? "ON" : "OFF"); + _alexa_change = false; + relayStatus(_alexa_device_id, _alexa_state); + } + } #endif diff --git a/code/platformio.ini b/code/platformio.ini index 2d21728e..b74a0381 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -24,7 +24,7 @@ lib_deps = Brzo I2C https://bitbucket.org/xoseperez/justwifi.git#1.1.4 https://bitbucket.org/xoseperez/hlw8012.git#1.0.1 - https://bitbucket.org/xoseperez/fauxmoesp.git#2.1.1 + https://bitbucket.org/xoseperez/fauxmoesp.git#dev https://bitbucket.org/xoseperez/nofuss.git#0.2.5 https://bitbucket.org/xoseperez/emonliteesp.git#0.2.0 https://bitbucket.org/xoseperez/debounceevent.git#2.0.1