/* ALEXA MODULE Copyright (C) 2016-2018 by Xose PĂ©rez */ #if ALEXA_SUPPORT #include #include fauxmoESP alexa; // ----------------------------------------------------------------------------- // ALEXA // ----------------------------------------------------------------------------- struct AlexaDevChange { AlexaDevChange(unsigned char device_id, bool state) : device_id(device_id), state(state) {}; unsigned char device_id = 0; bool state = false; }; static std::queue _alexa_dev_changes; void _alexaWebSocketOnSend(JsonObject& root) { root["alexaVisible"] = 1; root["alexaEnabled"] = getSetting("alexaEnabled", ALEXA_ENABLED).toInt() == 1; } void _alexaConfigure() { alexa.enable(getSetting("alexaEnabled", ALEXA_ENABLED).toInt() == 1); } // ----------------------------------------------------------------------------- void alexaSetup() { // Backwards compatibility moveSetting("fauxmoEnabled", "alexaEnabled"); // Load & cache settings _alexaConfigure(); #if WEB_SUPPORT // Websockets wsOnSendRegister(_alexaWebSocketOnSend); wsOnAfterParseRegister(_alexaConfigure); #endif unsigned int relays = relayCount(); String hostname = getSetting("hostname"); if (relays == 1) { alexa.addDevice(hostname.c_str()); } else { for (unsigned int i=0; i