Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate device name for alexa integration #1727

Merged
merged 2 commits into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions code/espurna/alexa.ino
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ bool _alexaWebSocketOnReceive(const char * key, JsonVariant& value) {
void _alexaWebSocketOnSend(JsonObject& root) {
root["alexaVisible"] = 1;
root["alexaEnabled"] = alexaEnabled();
root["alexaName"] = getSetting("alexaName");
}

void _alexaConfigure() {
Expand Down Expand Up @@ -84,9 +85,11 @@ void alexaSetup() {
alexa.createServer(!WEB_SUPPORT);
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
#if RELAY_PROVIDER == RELAY_PROVIDER_LIGHT
Expand Down
5 changes: 5 additions & 0 deletions code/espurna/config/general.h
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,11 @@
#define ALEXA_ENABLED 1
#endif

#ifndef ALEXA_HOSTNAME
#define ALEXA_HOSTNAME ""
#endif


// -----------------------------------------------------------------------------
// MQTT RF BRIDGE
// -----------------------------------------------------------------------------
Expand Down
11 changes: 11 additions & 0 deletions code/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,17 @@ <h2>General configuration values</h2>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="alexaEnabled" /></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>

</div>
Expand Down