mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-18 16:17:30 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09787fe08d |
6
pom.xml
6
pom.xml
@@ -5,11 +5,11 @@
|
||||
|
||||
<groupId>com.bwssystems.HABridge</groupId>
|
||||
<artifactId>ha-bridge</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.3.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HA Bridge</name>
|
||||
<description>Emulates a Philips Hue bridge to allow the Amazon Echo to hook up to other HA systems, i.e. Vera or Harmony Hub, using lightweight frameworks</description>
|
||||
<description>Emulates a Philips Hue bridge to allow the Amazon Echo to hook up to other HA systems, i.e. Vera or Harmony Hub or Nest, using lightweight frameworks</description>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
@@ -33,7 +33,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.bwssytems</groupId>
|
||||
<artifactId>nest-controller</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>1.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sparkjava</groupId>
|
||||
|
||||
@@ -321,7 +321,7 @@ public class HueMulator {
|
||||
|
||||
if(device.getDeviceType().toLowerCase().contains("activity") || (device.getMapType() != null && device.getMapType().equalsIgnoreCase("harmonyActivity")))
|
||||
{
|
||||
log.debug("executing activity to Harmony: " + url);
|
||||
log.debug("executing HUE api request to change activity to Harmony: " + url);
|
||||
RunActivity anActivity = new Gson().fromJson(url, RunActivity.class);
|
||||
HarmonyHandler myHarmony = myHarmonyHome.getHarmonyHandler(device.getTargetDevice());
|
||||
if(myHarmony == null)
|
||||
@@ -334,7 +334,7 @@ public class HueMulator {
|
||||
}
|
||||
else if(device.getDeviceType().toLowerCase().contains("button") || (device.getMapType() != null && device.getMapType().equalsIgnoreCase("harmonyButton")))
|
||||
{
|
||||
log.debug("executing button press to Harmony: " + url);
|
||||
log.debug("executing HUE api request to button press to Harmony: " + url);
|
||||
ButtonPress aDeviceButton = new Gson().fromJson(url, ButtonPress.class);
|
||||
HarmonyHandler myHarmony = myHarmonyHome.getHarmonyHandler(device.getTargetDevice());
|
||||
if(myHarmony == null)
|
||||
@@ -347,7 +347,7 @@ public class HueMulator {
|
||||
}
|
||||
else if(device.getDeviceType().toLowerCase().contains("home") || (device.getMapType() != null && device.getMapType().equalsIgnoreCase("nestHomeAway")))
|
||||
{
|
||||
log.debug("executing set away for nest home: " + url);
|
||||
log.debug("executing HUE api request to set away for nest home: " + url);
|
||||
NestInstruction homeAway = new Gson().fromJson(url, NestInstruction.class);
|
||||
if(theNest == null)
|
||||
{
|
||||
@@ -359,7 +359,7 @@ public class HueMulator {
|
||||
}
|
||||
else if(device.getDeviceType().toLowerCase().contains("thermo") || (device.getMapType() != null && device.getMapType().equalsIgnoreCase("nestThermoSet")))
|
||||
{
|
||||
log.debug("executing set thermostat for nest: " + url);
|
||||
log.debug("executing HUE api request to set thermostat for nest: " + url);
|
||||
NestInstruction thermoSetting = new Gson().fromJson(url, NestInstruction.class);
|
||||
if(theNest == null)
|
||||
{
|
||||
@@ -369,17 +369,28 @@ public class HueMulator {
|
||||
else {
|
||||
if(thermoSetting.getControl().equalsIgnoreCase("temp")) {
|
||||
if(request.body().contains("bri")) {
|
||||
thermoSetting.setTemp(replaceIntensityValue(thermoSetting.getTemp(), state.getBri()));
|
||||
thermoSetting.setTemp(String.valueOf(Math.round((Integer.parseInt(replaceIntensityValue(thermoSetting.getTemp(), state.getBri())) - 32)/1.8)));
|
||||
log.debug("Setting thermostat: " + thermoSetting.getName() + " to " + thermoSetting.getTemp() + "C");
|
||||
theNest.getThermostat(thermoSetting.getName()).setTargetTemperature(Float.parseFloat(thermoSetting.getTemp()));
|
||||
}
|
||||
}
|
||||
else if (!thermoSetting.getControl().equalsIgnoreCase("status")) {
|
||||
else if (thermoSetting.getControl().contains("range") ||thermoSetting.getControl().contains("heat") ||thermoSetting.getControl().contains("cool") ||thermoSetting.getControl().contains("off")) {
|
||||
log.debug("Setting thermostat target type: " + thermoSetting.getName() + " to " + thermoSetting.getControl());
|
||||
theNest.getThermostat(thermoSetting.getName()).setTargetType(thermoSetting.getControl());
|
||||
}
|
||||
else if(thermoSetting.getControl().contains("fan")) {
|
||||
log.debug("Setting thermostat fan mode: " + thermoSetting.getName() + " to " + thermoSetting.getControl().substring(4));
|
||||
theNest.getThermostat(thermoSetting.getName()).setFanMode(thermoSetting.getControl().substring(4));
|
||||
}
|
||||
else {
|
||||
log.warn("no valid Nest control info: " + thermoSetting.getControl());
|
||||
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId + ",\"description\": \"no valid Nest control info\", \"parameter\": \"/lights/" + lightId + "state\"}}]";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(url.startsWith("udp://"))
|
||||
{
|
||||
log.debug("executing HUE api request to UDP: " + url);
|
||||
try {
|
||||
String intermediate = url.substring(6);
|
||||
String ipAddr = intermediate.substring(0, intermediate.indexOf(':'));
|
||||
@@ -402,7 +413,7 @@ public class HueMulator {
|
||||
}
|
||||
else
|
||||
{
|
||||
log.debug("executing activity to Http " + (device.getHttpVerb() == null?"GET":device.getHttpVerb()) + ": " + url);
|
||||
log.debug("executing HUE api request to Http " + (device.getHttpVerb() == null?"GET":device.getHttpVerb()) + ": " + url);
|
||||
// quick template
|
||||
String body;
|
||||
url = replaceIntensityValue(url, state.getBri());
|
||||
|
||||
@@ -587,63 +587,63 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer
|
||||
$scope.device.deviceType = "home";
|
||||
$scope.device.name = nestitem.name;
|
||||
$scope.device.mapType = "nestHomeAway";
|
||||
$scope.device.mapId = nestitem.Id;
|
||||
$scope.device.onUrl = "{\"name\":\"" + nestitem.Id + "\",\"away\":false,\"control\":\"status\"}";
|
||||
$scope.device.offUrl = "{\"name\":\"" + nestitem.Id + "\",\"away\":true,\"control\":\"status\"}";
|
||||
$scope.device.mapId = nestitem.id;
|
||||
$scope.device.onUrl = "{\"name\":\"" + nestitem.id + "\",\"away\":false,\"control\":\"status\"}";
|
||||
$scope.device.offUrl = "{\"name\":\"" + nestitem.id + "\",\"away\":true,\"control\":\"status\"}";
|
||||
};
|
||||
|
||||
$scope.buildNestTempUrls = function (nestitem) {
|
||||
$scope.device.deviceType = "thermo";
|
||||
$scope.device.name = nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Temperature";
|
||||
$scope.device.mapType = "nestThermoSet";
|
||||
$scope.device.mapId = nestitem.Id + "-SetTemp";
|
||||
$scope.device.onUrl = "{\"name\":\"" + nestitem.Id + "\",\"control\":\"temp\",\"temp\":\"${intensity.percent}\"}";
|
||||
$scope.device.offUrl = "{\"name\":\"" + nestitem.Id + "\",\"control\":\"temp\",\"temp\":\"${intensity.percent}\"}";
|
||||
$scope.device.mapId = nestitem.id + "-SetTemp";
|
||||
$scope.device.onUrl = "{\"name\":\"" + nestitem.id + "\",\"control\":\"temp\",\"temp\":\"${intensity.percent}\"}";
|
||||
$scope.device.offUrl = "{\"name\":\"" + nestitem.id + "\",\"control\":\"temp\",\"temp\":\"${intensity.percent}\"}";
|
||||
};
|
||||
|
||||
$scope.buildNestHeatUrls = function (nestitem) {
|
||||
$scope.device.deviceType = "thermo";
|
||||
$scope.device.name = nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Heat";
|
||||
$scope.device.mapType = "nestThermoSet";
|
||||
$scope.device.mapId = nestitem.Id + "-SetHeat";
|
||||
$scope.device.onUrl = "{\"name\":\"" + nestitem.Id + "\",\"control\":\"heat\"}";
|
||||
$scope.device.offUrl = "{\"name\":\"" + nestitem.Id + "\",\"control\":\"off\"}";
|
||||
$scope.device.mapId = nestitem.id + "-SetHeat";
|
||||
$scope.device.onUrl = "{\"name\":\"" + nestitem.id + "\",\"control\":\"heat\"}";
|
||||
$scope.device.offUrl = "{\"name\":\"" + nestitem.id + "\",\"control\":\"off\"}";
|
||||
};
|
||||
|
||||
$scope.buildNestCoolUrls = function (nestitem) {
|
||||
$scope.device.deviceType = "thermo";
|
||||
$scope.device.name = nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Cool";
|
||||
$scope.device.mapType = "nestThermoSet";
|
||||
$scope.device.mapId = nestitem.Id + "-SetCool";
|
||||
$scope.device.onUrl = "{\"name\":\"" + nestitem.Id + "\",\"control\":\"cool\"}";
|
||||
$scope.device.offUrl = "{\"name\":\"" + nestitem.Id + "\",\"control\":\"off\"}";
|
||||
$scope.device.mapId = nestitem.id + "-SetCool";
|
||||
$scope.device.onUrl = "{\"name\":\"" + nestitem.id + "\",\"control\":\"cool\"}";
|
||||
$scope.device.offUrl = "{\"name\":\"" + nestitem.id + "\",\"control\":\"off\"}";
|
||||
};
|
||||
|
||||
$scope.buildNestRangeUrls = function (nestitem) {
|
||||
$scope.device.deviceType = "thermo";
|
||||
$scope.device.name = nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Range";
|
||||
$scope.device.mapType = "nestThermoSet";
|
||||
$scope.device.mapId = nestitem.Id + "-SetRange";
|
||||
$scope.device.onUrl = "{\"name\":\"" + nestitem.Id + "\",\"control\":\"range\"}";
|
||||
$scope.device.offUrl = "{\"name\":\"" + nestitem.Id + "\",\"control\":\"off\"}";
|
||||
$scope.device.mapId = nestitem.id + "-SetRange";
|
||||
$scope.device.onUrl = "{\"name\":\"" + nestitem.id + "\",\"control\":\"range\"}";
|
||||
$scope.device.offUrl = "{\"name\":\"" + nestitem.id + "\",\"control\":\"off\"}";
|
||||
};
|
||||
|
||||
$scope.buildNestOffUrls = function (nestitem) {
|
||||
$scope.device.deviceType = "thermo";
|
||||
$scope.device.name = nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Thermostat";
|
||||
$scope.device.mapType = "nestThermoSet";
|
||||
$scope.device.mapId = nestitem.Id + "-TurnOff";
|
||||
$scope.device.onUrl = "{\"name\":\"" + nestitem.Id + "\",\"control\":\"range\"}";
|
||||
$scope.device.offUrl = "{\"name\":\"" + nestitem.Id + "\",\"control\":\"off\"}";
|
||||
$scope.device.mapId = nestitem.id + "-TurnOff";
|
||||
$scope.device.onUrl = "{\"name\":\"" + nestitem.id + "\",\"control\":\"range\"}";
|
||||
$scope.device.offUrl = "{\"name\":\"" + nestitem.id + "\",\"control\":\"off\"}";
|
||||
};
|
||||
|
||||
$scope.buildNestFanUrls = function (nestitem) {
|
||||
$scope.device.deviceType = "thermo";
|
||||
$scope.device.name = nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Fan";
|
||||
$scope.device.mapType = "nestThermoSet";
|
||||
$scope.device.mapId = nestitem.Id + "-SetFan";
|
||||
$scope.device.onUrl = "{\"name\":\"" + nestitem.Id + "\",\"control\":\"fan-on\"}";
|
||||
$scope.device.offUrl = "{\"name\":\"" + nestitem.Id + "\",\"control\":\"fan-auto\"}";
|
||||
$scope.device.mapId = nestitem.id + "-SetFan";
|
||||
$scope.device.onUrl = "{\"name\":\"" + nestitem.id + "\",\"control\":\"fan-on\"}";
|
||||
$scope.device.offUrl = "{\"name\":\"" + nestitem.id + "\",\"control\":\"fan-auto\"}";
|
||||
};
|
||||
|
||||
$scope.testUrl = function (device, type) {
|
||||
|
||||
Reference in New Issue
Block a user