Browse Source

Separate device name for alexa integration (#1727)

Allow defining custom device name for alexa integration, other than hostname.
Still uses hostname as a fallback.
master
m-kozlowski 5 years ago
committed by Max Prokhorov
parent
commit
471a6387fb
3 changed files with 22 additions and 3 deletions
  1. +6
    -3
      code/espurna/alexa.ino
  2. +5
    -0
      code/espurna/config/general.h
  3. +11
    -0
      code/html/index.html

+ 6
- 3
code/espurna/alexa.ino View File

@ -30,6 +30,7 @@ bool _alexaWebSocketOnReceive(const char * key, JsonVariant& value) {
void _alexaWebSocketOnSend(JsonObject& root) { void _alexaWebSocketOnSend(JsonObject& root) {
root["alexaVisible"] = 1; root["alexaVisible"] = 1;
root["alexaEnabled"] = alexaEnabled(); root["alexaEnabled"] = alexaEnabled();
root["alexaName"] = getSetting("alexaName");
} }
void _alexaConfigure() { void _alexaConfigure() {
@ -84,9 +85,11 @@ void alexaSetup() {
alexa.createServer(!WEB_SUPPORT); alexa.createServer(!WEB_SUPPORT);
alexa.setPort(80); alexa.setPort(80);
// Uses hostname as base name for all devices
// TODO: use custom switch name when available
String hostname = getSetting("hostname");
// Use custom alexa hostname if defined, device hostname otherwise
String hostname = getSetting("alexaName", ALEXA_HOSTNAME);
if (hostname.length() == 0) {
hostname = getSetting("hostname");
}
// Lights // Lights
#if RELAY_PROVIDER == RELAY_PROVIDER_LIGHT #if RELAY_PROVIDER == RELAY_PROVIDER_LIGHT


+ 5
- 0
code/espurna/config/general.h View File

@ -1227,6 +1227,11 @@
#define ALEXA_ENABLED 1 #define ALEXA_ENABLED 1
#endif #endif
#ifndef ALEXA_HOSTNAME
#define ALEXA_HOSTNAME ""
#endif
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// MQTT RF BRIDGE // MQTT RF BRIDGE
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------


+ 11
- 0
code/html/index.html View File

@ -388,6 +388,17 @@
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="alexaEnabled" /></div> <div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="alexaEnabled" /></div>
</div> </div>
<div class="pure-g module module-alexa">
<label class="pure-u-1 pure-u-lg-1-4">Alexa device name</label>
<input name="alexaName" class="pure-u-1 pure-u-lg-1-4" maxlength="31" type="text" action="reboot" tabindex="7" />
<div class="pure-u-0 pure-u-lg-1-2"></div>
<div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint">
This name will be used in Alexa integration.<br />
</div>
</div>
</fieldset> </fieldset>
</div> </div>


Loading…
Cancel
Save