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

[amazonechocontrol] add support for smarthome devices #7969

Merged
merged 124 commits into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
7c839a7
[amazonechocontrol]
May 11, 2019
35154c1
[amazonechocontrol]
May 12, 2019
94494da
[amazonechocontrol]
May 12, 2019
d75261f
Merge branch 'master' of https://github.com/openhab/openhab2-addons
May 15, 2019
eef3b2e
Merge branch 'master' of https://github.com/openhab/openhab2-addons
May 20, 2019
43e8144
Changes for new build system
lkn94 Jun 8, 2019
611b9fd
Original
lkn94 Jun 9, 2019
bbdcbf8
Bugfixed for new version and merge request
lkn94 Jun 9, 2019
987d8eb
Added license information and author
lkn94 Jun 9, 2019
b2d9d0f
Added contributor and readme information
lkn94 Jun 10, 2019
286eb47
Uncommented test comment for production use
lkn94 Jun 22, 2019
336a7e1
Removed the waitForUpdate variable - not used
lkn94 Jun 22, 2019
4b8a520
Added two configurations params for pulling interval and activating t…
lkn94 Jun 30, 2019
01f74fb
Merge branch 'master' of https://github.com/openhab/openhab2-addons
Jul 4, 2019
1860326
Merge branch 'SmartHome' into original
Jul 4, 2019
59c9d18
Merge pull request #2 from lkn94/original
Jul 4, 2019
7e234da
[amazonechocontrol]
Jul 4, 2019
08d8636
[amazonechocontrol]
Jul 14, 2019
35434d9
[amazonechocontrol]
Jul 14, 2019
717cded
[amazonechocontrol]
Jul 14, 2019
1f352a4
[amazonechocontrol]
Jul 14, 2019
0b9b438
[amazonechocontrol]
Jul 14, 2019
3dd6b57
Merge pull request #1 from mgeramb/SmartHome
lkn94 Jul 17, 2019
208d6f5
Bugfixed discovery
lkn94 Jul 17, 2019
5def872
Merge branch 'original' of https://github.com/lkn94/openhab2-addons i…
lkn94 Jul 17, 2019
0ea5cde
Bugfixed wrong entries of the amazon echo devices as lights
lkn94 Jul 17, 2019
4d44bda
Merge pull request #2 from lkn94/original
lkn94 Jul 17, 2019
a0f751b
Merge pull request #3 from lkn94/SmartHome
Jul 18, 2019
73796fb
[amazonechocontrol]
Jul 18, 2019
340e4f6
Merge pull request #3 from mgeramb/TestSmartHomeDeviceList
lkn94 Jul 18, 2019
4990118
Implemented recursive searching for devices, filtered smart plugs
lkn94 Jul 25, 2019
0eb5d49
Added smart plugs
lkn94 Jul 26, 2019
7683a3e
Removed unused code, renamed new function and it's references
lkn94 Jul 26, 2019
7fdb24c
Added translation
lkn94 Jul 27, 2019
e9586a4
Added documentation
lkn94 Jul 27, 2019
9f22076
Added capabilities to smart home device
lkn94 Jul 28, 2019
a679e71
Added dynamic channel adding
lkn94 Jul 31, 2019
a5210e6
Merge pull request #4 from lkn94/TestSmartHomeDeviceList
lkn94 Jul 31, 2019
e85bea8
Merge pull request #4 from lkn94/SmartHome
Aug 5, 2019
58e54cd
[amazonechocontrol]
Aug 5, 2019
bc79211
Merge branch 'master' of https://github.com/openhab/openhab2-addons
Aug 15, 2019
6cd3a7c
Merge pull request #5 from mgeramb/SmartHome
lkn94 Aug 18, 2019
4879687
[amazonechocontrol]
Sep 1, 2019
a87ca63
[amazonechocontrol]
Sep 1, 2019
018b7d1
[amazonechocontrol]
Sep 2, 2019
37e8387
[amazonechocontrol]
Sep 3, 2019
981c903
[amazonechocontrol]
Sep 3, 2019
ce86f74
[amazonechocontrol]
Sep 4, 2019
a39a251
[amazonechocontrol]
Sep 4, 2019
4c4dd85
[amazonechocontrol]
Sep 5, 2019
32c9cd0
[amazonechocontrol]
Sep 5, 2019
47c8a5e
[amazonechocontrol]
Sep 6, 2019
e757bde
Merge branch 'master' of https://github.com/openhab/openhab2-addons
Sep 6, 2019
be69b72
[amazonechocontrol] Bugfix for login in Australia (#6034)
Sep 6, 2019
529dcf3
[amazonechocontrol]
Sep 7, 2019
842bf2f
[amazonechocontrol]
Sep 7, 2019
de011da
[amazonechocontrol]
Sep 7, 2019
e6469bd
[amazonechocontrol]
Sep 7, 2019
8751a78
[amazonechocontrol]
Sep 7, 2019
06e817d
[amazonechocontrol]
Sep 7, 2019
9511d97
[amazonechocontrol]
Sep 7, 2019
f190c7e
[amazonechocontrol]
Sep 8, 2019
7f14476
[amazonechocontrol]
Sep 8, 2019
af25daf
[amazonechocontrol]
Sep 8, 2019
60d884a
[amazonechocontrol]
Sep 8, 2019
7263e92
[amazonechocontrol]
Sep 8, 2019
32f943f
[amazonechocontrol]
Sep 9, 2019
8a5b69a
[amazonechocontrol]
Sep 9, 2019
6addb58
[amazonechocontrol]
Sep 9, 2019
b46f8ec
[amazonechocontrol]
Sep 9, 2019
e33ba28
[amazonechocontrol]
Sep 9, 2019
083c532
[amazonechocontrol]
Sep 9, 2019
cf83c0e
[amazonechocontrol]
Sep 10, 2019
cc13a4a
[amazonechocontrol]
Sep 10, 2019
7d296bf
[amazonechocontrol]
Sep 10, 2019
da6e2e5
[amazonechocontrol]
Sep 10, 2019
ece83d3
Merge branch 'master' of https://github.com/openhab/openhab2-addons
Sep 10, 2019
abfe190
Update ___Do_To's___.md
Sep 11, 2019
184a6dc
Update ___Do_To's___.md
Sep 11, 2019
4775940
Update README.md
lkn94 Sep 11, 2019
33e5412
Update README.md
lkn94 Sep 11, 2019
47a190d
[amazonechocontrol]
Sep 11, 2019
6669eed
Merge branch 'SmartHomeDeviceHandling' of https://github.com/mgeramb/…
Sep 11, 2019
c4cf560
[amazonechocontrol]
Sep 11, 2019
62be95d
Update README.md
lkn94 Sep 11, 2019
6cb3702
[amazonechocontrol]
Sep 11, 2019
53573c6
[amazonechocontrol]
Sep 11, 2019
0b505fc
Merge branch 'SmartHomeDeviceHandling' of https://github.com/mgeramb/…
Sep 11, 2019
a967c65
Update ___Release_Notes___.md
lkn94 Sep 11, 2019
abfdba8
[amazonechocontrol]
Sep 11, 2019
ef3e63a
Merge branch 'SmartHomeDeviceHandling' of https://github.com/mgeramb/…
Sep 11, 2019
b74ac50
[amazonechocontrol]
Sep 11, 2019
05f1c84
[amazonechocontrol]
Sep 11, 2019
3aff30c
[amazonechocontrol]
Sep 11, 2019
7922e7d
[amazonechocontrol]
Sep 11, 2019
9ad4a7a
[amazonechocontrol]
Sep 11, 2019
b45f51e
[amazonechocontrol]
Sep 11, 2019
f569693
[amazonechocontrol]
Sep 11, 2019
a5dffba
[amazonechocontrol]
Sep 11, 2019
b799b13
[amazonechocontrol]
Sep 11, 2019
d35c69b
[amazonechocontrol]
Sep 12, 2019
58984fd
[amazonechocontrol]
Sep 12, 2019
61a37f3
[amazonechocontrol]
Sep 12, 2019
e908d22
[amazonechocontrol]
Sep 13, 2019
6783587
[amazonechocontrol]
Sep 21, 2019
da9e8cc
Merge branch 'master' of https://github.com/openhab/openhab2-addons
Sep 24, 2019
a2ccc5c
[amazonechocontrol]
Sep 25, 2019
1d28a55
Merge pull request #6 from mgeramb/HandleOnOffInPercentageChannel
lkn94 Sep 27, 2019
bb711ee
Conflicts resolved
lkn94 Sep 27, 2019
f3ac308
[amazonechocontrol]
Oct 2, 2019
8365a5b
[amazonechocontrol]
Oct 2, 2019
1dd4e20
Merge branch 'master' of https://github.com/openhab/openhab2-addons
Oct 16, 2019
f4dfe2d
[amazonechocontrol]
Oct 16, 2019
e12ba9c
[amazonechocontrol]
Oct 16, 2019
417f3f8
Merge branch 'master' of https://github.com/openhab/openhab2-addons
Nov 17, 2019
b42de5d
[amazonechocontrol]
Nov 17, 2019
f2ae580
Merge pull request #11 from mgeramb/SmartHomeDeviceHandling
lkn94 Nov 18, 2019
892b51b
Removed unused file
lkn94 Nov 20, 2019
11ce859
Removed unused file
lkn94 Nov 20, 2019
306f57b
Error fixes
lkn94 Nov 20, 2019
f37c709
codestyle
J-N-K Jun 20, 2020
fc99c6e
Merge branch '2.5.x' into lkn94_SmartHome
J-N-K Jun 20, 2020
0fea431
Fix issues, codestyle and refactoring
J-N-K Jun 20, 2020
c84020e
address review comment
J-N-K Jul 5, 2020
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
305 changes: 269 additions & 36 deletions bundles/org.openhab.binding.amazonechocontrol/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.amazonechocontrol.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.amazonechocontrol.internal.handler.AccountHandler;

/**
* The {@link AccountHandlerConfig} holds the configuration for the {@link AccountHandler}
*
* @author Jan N. Klug - Initial contribution
*/
@NonNullByDefault
public class AccountHandlerConfig {
public int discoverSmartHome = 0;
public int pollingIntervalSmartHomeAlexa = 60;
public int pollingIntervalSmartSkills = 120;
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.smarthome.core.thing.Thing;
Expand All @@ -55,7 +54,6 @@
import com.google.gson.JsonSyntaxException;

/**
*
* Provides the following functions
* --- Login ---
* Simple http proxy to forward the login dialog from amazon to the user through the binding
Expand All @@ -76,33 +74,27 @@ public class AccountServlet extends HttpServlet {

private final Logger logger = LoggerFactory.getLogger(AccountServlet.class);

final HttpService httpService;
String servletUrlWithoutRoot;
final String servletUrl;
AccountHandler account;
String id;
@Nullable
Connection connectionToInitialize;
final Gson gson;
private final HttpService httpService;
private final String servletUrlWithoutRoot;
private final String servletUrl;
private final AccountHandler account;
private final String id;
private @Nullable Connection connectionToInitialize;
private final Gson gson;

public AccountServlet(HttpService httpService, String id, AccountHandler account, Gson gson) {
this.httpService = httpService;
this.account = account;
this.id = id;
this.gson = gson;

try {
servletUrlWithoutRoot = "amazonechocontrol/" + URLEncoder.encode(id, "UTF8");
} catch (UnsupportedEncodingException e) {
servletUrlWithoutRoot = "";
servletUrl = "";
logger.warn("Register servlet fails", e);
return;
}
servletUrl = "/" + servletUrlWithoutRoot;
try {
servletUrl = "/" + servletUrlWithoutRoot;

httpService.registerServlet(servletUrl, this, null, httpService.createDefaultHttpContext());
} catch (NamespaceException | ServletException e) {
logger.warn("Register servlet fails", e);
} catch (UnsupportedEncodingException | NamespaceException | ServletException e) {
throw new IllegalStateException(e.getMessage());
}
}

Expand Down Expand Up @@ -565,15 +557,15 @@ private void renderAmazonMusicPlaylistIdChannel(Connection connection, Device de
}

if (playLists != null) {
Map<@NonNull String, @Nullable PlayList @Nullable []> playlistMap = playLists.playlists;
Map<String, @Nullable PlayList @Nullable []> playlistMap = playLists.playlists;
if (playlistMap != null && !playlistMap.isEmpty()) {
html.append("<table><tr><th align='left'>Name</th><th align='left'>Value</th></tr>");

for (PlayList[] innerLists : playlistMap.values()) {
{
if (innerLists != null && innerLists.length > 0) {
PlayList playList = innerLists[0];
if (playList.playlistId != null && playList.title != null) {
if (playList != null && playList.playlistId != null && playList.title != null) {
html.append("<tr><td>");
html.append(StringEscapeUtils.escapeHtml(nullReplacement(playList.title)));
html.append("</td><td>");
Expand All @@ -593,24 +585,32 @@ private void renderAmazonMusicPlaylistIdChannel(Connection connection, Device de
private void renderBluetoothMacChannel(Connection connection, Device device, StringBuilder html) {
html.append("<h2>" + StringEscapeUtils.escapeHtml("Channel " + CHANNEL_BLUETOOTH_MAC) + "</h2>");
JsonBluetoothStates bluetoothStates = connection.getBluetoothConnectionStates();
if (bluetoothStates == null) {
return;
}
BluetoothState[] innerStates = bluetoothStates.bluetoothStates;
if (innerStates != null) {
for (BluetoothState state : innerStates) {
if (StringUtils.equals(state.deviceSerialNumber, device.serialNumber)) {
PairedDevice[] pairedDeviceList = state.pairedDeviceList;
if (pairedDeviceList != null && pairedDeviceList.length > 0) {
html.append("<table><tr><th align='left'>Name</th><th align='left'>Value</th></tr>");
for (PairedDevice pairedDevice : pairedDeviceList) {
html.append("<tr><td>");
html.append(StringEscapeUtils.escapeHtml(nullReplacement(pairedDevice.friendlyName)));
html.append("</td><td>");
html.append(StringEscapeUtils.escapeHtml(nullReplacement(pairedDevice.address)));
html.append("</td></tr>");
}
html.append("</table>");
} else {
html.append(StringEscapeUtils.escapeHtml("No bluetooth devices paired"));
if (innerStates == null) {
return;
}
for (BluetoothState state : innerStates) {
if (state == null) {
continue;
}
if ((state.deviceSerialNumber == null && device.serialNumber == null)
|| (state.deviceSerialNumber != null && state.deviceSerialNumber.equals(device.serialNumber))) {
PairedDevice[] pairedDeviceList = state.pairedDeviceList;
if (pairedDeviceList != null && pairedDeviceList.length > 0) {
html.append("<table><tr><th align='left'>Name</th><th align='left'>Value</th></tr>");
for (PairedDevice pairedDevice : pairedDeviceList) {
html.append("<tr><td>");
html.append(StringEscapeUtils.escapeHtml(nullReplacement(pairedDevice.friendlyName)));
html.append("</td><td>");
html.append(StringEscapeUtils.escapeHtml(nullReplacement(pairedDevice.address)));
html.append("</td></tr>");
}
html.append("</table>");
} else {
html.append(StringEscapeUtils.escapeHtml("No bluetooth devices paired"));
}
}
}
Expand Down
Loading