Skip to content

Commit

Permalink
Merge branch 'SmartHome' into original
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Geramb authored Jul 4, 2019
2 parents 4b8a520 + 01f74fb commit 1860326
Show file tree
Hide file tree
Showing 295 changed files with 4,867 additions and 1,259 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.DS_Store
*.iml
npm-debug.log
.build.log

.metadata/
bin/
Expand All @@ -16,3 +17,6 @@ xtend-gen/
bundles/**/src/main/history
features/**/src/main/history
features/**/src/main/feature

.vscode
.factorypath
46 changes: 11 additions & 35 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,18 @@ jdk:
cache:
directories:
- $HOME/.m2
- $HOME/.p2
- $HOME/.bnd/cache/

before_cache:
# remove resolver-status.properties, they change with each run and invalidate the cache
- find $HOME/.m2 -name resolver-status.properties -exec rm {} \;

before_install:
- echo "MAVEN_OPTS='-Xms1g -Xmx2g -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'" > ~/.mavenrc
install:
- |
function prevent_timeout() {
local i=0
while [ -e /proc/$1 ]; do
# print zero width char every 3 minutes while building
if [ "$i" -eq "180" ]; then printf %b '\u200b'; i=0; else i=$((i+1)); fi
sleep 1
done
}
function print_reactor_summary() {
sed -ne '/\[INFO\] Reactor Summary:/,$ p' "$1" | sed 's/\[INFO\] //'
}
function mvnp() {
set -o pipefail # exit build with error when pipes fail
local command=(mvn $@)
exec "${command[@]}" 2>&1 | # execute, redirect stderr to stdout
tee .build.log | # write output to log
stdbuf -oL grep -E '^\[INFO\] Building .+ \[.+\]$' | # filter progress
sed -uE 's/^\[INFO\] Building (.*[^ ])[ ]+\[([0-9]+\/[0-9]+)\]$/\2| \1/' | # prefix project name with progress
sed -e :a -e 's/^.\{1,6\}|/ &/;ta' & # right align progress with padding
local pid=$!
prevent_timeout $pid &
wait $pid
}
after_success:
- print_reactor_summary .build.log
after_failure:
- tail -n 2000 .build.log
script:
- mvnp clean install -B -DskipChecks=true -DskipTests=true

notifications:
webhooks: https://www.travisbuddy.com/

travisBuddy:
insertMode: update
successBuildLog: true

install: true
script: ./buildci.sh "$TRAVIS_COMMIT_RANGE"
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
/bundles/org.openhab.binding.plugwise/ @wborn
/bundles/org.openhab.binding.powermax/ @lolodomo
/bundles/org.openhab.binding.pulseaudio/ @peuter
/bundles/org.openhab.binding.pushbullet/ @hakan42
/bundles/org.openhab.binding.regoheatpump/ @crnjan
/bundles/org.openhab.binding.rfxcom/ @martinvw @paulianttila
/bundles/org.openhab.binding.rme/ @kgoderis
Expand Down
5 changes: 5 additions & 0 deletions bom/openhab-addons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,11 @@
<artifactId>org.openhab.binding.pulseaudio</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.pushbullet</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.regoheatpump</artifactId>
Expand Down
69 changes: 69 additions & 0 deletions buildci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

function prevent_timeout() {
local i=0
while [ -e /proc/$1 ]; do
# print zero width char every 3 minutes while building
if [ "$i" -eq "180" ]; then printf %b '\u200b'; i=0; else i=$((i+1)); fi
sleep 1
done
}

function print_reactor_summary() {
sed -ne '/\[INFO\] Reactor Summary:/,$ p' "$1" | sed 's/\[INFO\] //'
}

function mvnp() {
set -o pipefail # exit build with error when pipes fail
local command=(mvn $@)
exec "${command[@]}" 2>&1 | # execute, redirect stderr to stdout
stdbuf -o0 grep -vE "Download(ed|ing) from [a-z.]+: https:" | # filter out downloads
tee .build.log | # write output to log
stdbuf -oL grep -E '^\[INFO\] Building .+ \[.+\]$' | # filter progress
stdbuf -o0 sed -uE 's/^\[INFO\] Building (.*[^ ])[ ]+\[([0-9]+\/[0-9]+)\]$/\2| \1/' | # prefix project name with progress
stdbuf -o0 sed -e :a -e 's/^.\{1,6\}|/ &/;ta' & # right align progress with padding
local pid=$!
prevent_timeout $pid &
wait $pid
}

COMMITS=${1:-"master...HEAD"}

# Determine if this is a new addon -> Perform tests + integration tests and all SAT checks with increased warning level
CHANGED_DIR=`git diff --dirstat=files,0 $COMMITS bundles/ | sed 's/^[ 0-9.]\+% bundles\///g' | grep -o -P "^([^/]*)" | uniq`
CDIR=`pwd`

if [ ! -z "$CHANGED_DIR" ] && [ -e "bundles/$CHANGED_DIR" ]; then
echo "Single addon pull request: Building $CHANGED_DIR"
echo "MAVEN_OPTS='-Xms1g -Xmx2g -Dorg.slf4j.simpleLogger.log.org.openhab.tools.analysis.report.ReportUtility=DEBUG -Dorg.slf4j.simpleLogger.defaultLogLevel=WARN'" > ~/.mavenrc
cd "bundles/$CHANGED_DIR"
mvn clean install -B 2>&1 |
stdbuf -o0 grep -vE "Download(ed|ing) from [a-z.]+: https:" | # Filter out Download(s)
stdbuf -o0 grep -v "target/code-analysis" | # filter out some debug code from reporting utility
tee $CDIR/.build.log
if [ $? -ne 0 ]; then
exit 1
fi

if [ -e "../itests/$CHANGED_DIR" ]; then
echo "Single addon pull request: Building itest $CHANGED_DIR"
cd "../itests/$CHANGED_DIR"
mvn clean install -B 2>&1 |
stdbuf -o0 grep -vE "Download(ed|ing) from [a-z.]+: https:" | # Filter out Download(s)
stdbuf -o0 grep -v "target/code-analysis" | # filter out some debug code from reporting utility
tee -a $CDIR/.build.log
if [ $? -ne 0 ]; then
exit 1
fi
fi
else
echo "Build all"
echo "MAVEN_OPTS='-Xms1g -Xmx2g -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'" > ~/.mavenrc
mvnp clean install -B -DskipChecks=true -DskipTests=true
if [ $? -eq 0 ]; then
print_reactor_summary .build.log
else
tail -n 1000 .build.log
exit 1
fi
fi
Binary file not shown.
Binary file not shown.
11 changes: 8 additions & 3 deletions bundles/org.openhab.binding.allplay/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@

<name>openHAB Add-ons :: Bundles :: AllPlay Binding</name>

<properties>
<bnd.importpackage>org.slf4j.impl.*;resolution:=optional,de.kaizencode.tchaikovsky.*</bnd.importpackage>
</properties>
<dependencies>
<dependency>
<groupId>org.openhab.osgiify</groupId>
<artifactId>de.kaizencode.tchaikovsky</artifactId>
<version>0.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<feature name="openhab-binding-allplay" description="AllPlay Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle dependency="true">mvn:org.openhab.osgiify/de.kaizencode.tchaikovsky/0.0.1</bundle>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.allplay/${project.version}</bundle>
</feature>
</features>
8 changes: 4 additions & 4 deletions bundles/org.openhab.binding.amazondashbutton/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.pcap4j</groupId>
<artifactId>pcap4j-core</artifactId>
<groupId>org.openhab.osgiify</groupId>
<artifactId>org.pcap4j.pcap4j-core</artifactId>
<version>1.6.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.pcap4j</groupId>
<artifactId>pcap4j-packetfactory-static</artifactId>
<groupId>org.openhab.osgiify</groupId>
<artifactId>org.pcap4j.pcap4j-packetfactory-static</artifactId>
<version>1.6.6</version>
<scope>provided</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

<feature name="openhab-binding-amazondashbutton" description="Amazon Dash Button Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<feature prerequisite="true">wrap</feature>
<bundle dependency="true">mvn:net.java.dev.jna/jna/4.2.1</bundle>
<bundle dependency="true">wrap:mvn:org.pcap4j/pcap4j-core/1.6.6$Bundle-Name=Pcap4J%20Core&amp;Bundle-SymbolicName=org.pcap4j.pcap4j-core&amp;Bundle-Version=1.6.6</bundle>
<bundle dependency="true">wrap:mvn:org.pcap4j/pcap4j-packetfactory-static/1.6.6$Bundle-Name=Pcap4J%20Static%20Packet%20Factory&amp;Bundle-SymbolicName=org.pcap4j.pcap4j-packetfactory-static&amp;Bundle-Version=1.6.6</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.pcap4j.pcap4j-core/1.6.6</bundle>
<bundle>mvn:org.openhab.osgiify/org.pcap4j.pcap4j-packetfactory-static/1.6.6</bundle>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.amazondashbutton/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,20 @@ public class AccountServlet extends HttpServlet {

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

HttpService httpService;
final HttpService httpService;
String servletUrlWithoutRoot;
String servletUrl;
final String servletUrl;
AccountHandler account;
String id;
@Nullable
Connection connectionToInitialize;
Gson gson = new Gson();
final Gson gson;

public AccountServlet(HttpService httpService, String id, AccountHandler account) {
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) {
Expand All @@ -112,7 +113,7 @@ private Connection reCreateConnection() {
if (oldConnection == null) {
oldConnection = account.findConnection();
}
return new Connection(oldConnection);
return new Connection(oldConnection, this.gson);
}

public void dispose() {
Expand Down Expand Up @@ -157,7 +158,7 @@ void doVerb(String verb, @Nullable HttpServletRequest req, @Nullable HttpServlet
Map<String, String[]> map = req.getParameterMap();
String domain = map.get("domain")[0];
String loginData = connection.serializeLoginData();
Connection newConnection = new Connection(null);
Connection newConnection = new Connection(null, this.gson);
if (newConnection.tryRestoreLogin(loginData, domain)) {
account.setConnection(newConnection);
}
Expand Down Expand Up @@ -282,7 +283,7 @@ protected void doGet(@Nullable HttpServletRequest req, @Nullable HttpServletResp
}
// handle commands
if (baseUrl.equals("/newdevice") || baseUrl.equals("/newdevice/")) {
this.connectionToInitialize = new Connection(null);
this.connectionToInitialize = new Connection(null, this.gson);
this.account.setConnection(null);
resp.sendRedirect(this.servletUrl);
return;
Expand All @@ -301,9 +302,7 @@ protected void doGet(@Nullable HttpServletRequest req, @Nullable HttpServletResp
Device device = account.findDeviceJson(serialNumber);
if (device != null) {
Thing thing = account.findThingBySerialNumber(device.serialNumber);
if (thing != null) {
handleIds(resp, connection, device, thing);
}
handleIds(resp, connection, device, thing);
return;
}
}
Expand Down Expand Up @@ -331,7 +330,7 @@ protected void doGet(@Nullable HttpServletRequest req, @Nullable HttpServletResp
}

public Map<String, String> getQueryMap(@Nullable String query) {
Map<String, String> map = new HashMap<String, String>();
Map<String, String> map = new HashMap<>();
if (query != null) {
String[] params = query.split("&");
for (String param : params) {
Expand Down Expand Up @@ -374,6 +373,12 @@ private void handleDefaultPageResult(HttpServletResponse resp, String message, C
html.append(" | <a href='" + servletUrl + "/newdevice' >");
html.append(StringEscapeUtils.escapeHtml("Logout and create new device id"));
html.append("</a>");
// customer id
html.append("<br>Customer Id: ");
html.append(StringEscapeUtils.escapeHtml(connection.getCustomerId()));
// customer name
html.append("<br>Customer Name: ");
html.append(StringEscapeUtils.escapeHtml(connection.getCustomerName()));
// device name
html.append("<br>App name: ");
html.append(StringEscapeUtils.escapeHtml(connection.getDeviceName()));
Expand All @@ -393,7 +398,7 @@ private void handleDefaultPageResult(HttpServletResponse resp, String message, C

// device list
html.append(
"<table><tr><th align='left'>Device</th><th align='left'>Serial Number</th><th align='left'>State</th><th align='left'>Thing</th><th align='left'>Family</th><th align='left'>Type</th></tr>");
"<table><tr><th align='left'>Device</th><th align='left'>Serial Number</th><th align='left'>State</th><th align='left'>Thing</th><th align='left'>Family</th><th align='left'>Type</th><th align='left'>Customer Id</th></tr>");
for (Device device : this.account.getLastKnownDevices()) {

html.append("<tr><td>");
Expand All @@ -409,14 +414,18 @@ private void handleDefaultPageResult(HttpServletResponse resp, String message, C
+ URLEncoder.encode(device.serialNumber, "UTF8") + "'>"
+ StringEscapeUtils.escapeHtml(accountHandler.getLabel()) + "</a>");
} else {
html.append("Not defined");
html.append("<a href='" + servletUrl + "/ids/?serialNumber="
+ URLEncoder.encode(device.serialNumber, "UTF8") + "'>"
+ StringEscapeUtils.escapeHtml("Not defined") + "</a>");
}
html.append("</td><td>");
html.append(StringEscapeUtils.escapeHtml(nullReplacement(device.deviceFamily)));
html.append("</td><td>");
html.append(StringEscapeUtils.escapeHtml(nullReplacement(device.deviceType)));
html.append("</td><td>");
html.append("</td></tr>");
html.append(StringEscapeUtils.escapeHtml(nullReplacement(device.deviceOwnerCustomerId)));
html.append("</td>");
html.append("</tr>");
}
html.append("</table>");
createPageEndAndSent(resp, html);
Expand Down Expand Up @@ -467,18 +476,36 @@ private void createPageEndAndSent(HttpServletResponse resp, StringBuilder html)
}
}

private void handleIds(HttpServletResponse resp, Connection connection, Device device, Thing thing)
private void handleIds(HttpServletResponse resp, Connection connection, Device device, @Nullable Thing thing)
throws IOException, URISyntaxException {
StringBuilder html = createPageStart("Channel Options - " + thing.getLabel());

StringBuilder html;
if (thing != null) {
html = createPageStart("Channel Options - " + thing.getLabel());
} else {
html = createPageStart("Device Information - No thing defined");
}
renderBluetoothMacChannel(connection, device, html);
renderAmazonMusicPlaylistIdChannel(connection, device, html);
renderPlayAlarmSoundChannel(connection, device, html);
renderMusicProviderIdChannel(connection, html);

renderCapabilities(connection, device, html);
createPageEndAndSent(resp, html);
}

private void renderCapabilities(Connection connection, Device device, StringBuilder html) {
html.append("<h2>Capabilities</h2>");
html.append("<table><tr><th align='left'>Name</th></tr>");
String[] capabilities = device.capabilities;
if (capabilities != null) {
for (String capability : capabilities) {
html.append("<tr><td>");
html.append(StringEscapeUtils.escapeHtml(capability));
html.append("</td></tr>");
}
}
html.append("</table>");
}

private void renderMusicProviderIdChannel(Connection connection, StringBuilder html) {
html.append("<h2>" + StringEscapeUtils.escapeHtml("Channel " + CHANNEL_MUSIC_PROVIDER_ID) + "</h2>");
html.append("<table><tr><th align='left'>Name</th><th align='left'>Value</th></tr>");
Expand Down Expand Up @@ -599,11 +626,11 @@ void handleProxyRequest(Connection connection, HttpServletResponse resp, String
try {
Map<String, String> headers = null;
if (referer != null) {
headers = new HashMap<String, String>();
headers = new HashMap<>();
headers.put("Referer", referer);
}

urlConnection = connection.makeRequest(verb, url, postData, json, false, headers);
urlConnection = connection.makeRequest(verb, url, postData, json, false, headers, 0);
if (urlConnection.getResponseCode() == 302) {
{
String location = urlConnection.getHeaderField("location");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class AmazonEchoControlBindingConstants {
public static final ThingTypeUID THING_TYPE_LIGHT = new ThingTypeUID(BINDING_ID, "light");
public static final ThingTypeUID THING_TYPE_LIGHT_GROUP = new ThingTypeUID(BINDING_ID, "lightGroup");

public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = new HashSet<ThingTypeUID>(
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = new HashSet<>(
Arrays.asList(THING_TYPE_ACCOUNT, THING_TYPE_ECHO, THING_TYPE_ECHO_SPOT, THING_TYPE_ECHO_SHOW,
THING_TYPE_ECHO_WHA, THING_TYPE_FLASH_BRIEFING_PROFILE, THING_TYPE_LIGHT, THING_TYPE_LIGHT_GROUP));

Expand Down
Loading

0 comments on commit 1860326

Please sign in to comment.