|
|
@ -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
|