From c679548bbd0c9e343a454583e9c1fba7fd336ed2 Mon Sep 17 00:00:00 2001
From: Admin
Date: Thu, 2 Feb 2017 11:00:50 -0600
Subject: [PATCH] Beta impl of LIFX complete
---
pom.xml | 2 +-
.../devicemanagmeent/DeviceResource.java | 6 +
.../HABridge/plugins/lifx/LifxDevice.java | 2 +
.../HABridge/plugins/lifx/LifxEntry.java | 7 +
src/main/resources/public/scripts/app.js | 11 +-
.../resources/public/views/configuration.html | 1 +
.../public/views/domoticzdevice.html | 5 +-
.../resources/public/views/editdevice.html | 3 +-
.../resources/public/views/haldevice.html | 5 +-
.../public/views/harmonyactivity.html | 1 +
.../resources/public/views/harmonydevice.html | 1 +
.../resources/public/views/hassdevice.html | 5 +-
.../resources/public/views/huedevice.html | 5 +-
.../resources/public/views/lifxdevice.html | 122 ++++++++++++++++++
src/main/resources/public/views/logs.html | 1 +
.../resources/public/views/mqttpublish.html | 1 +
.../resources/public/views/nestactions.html | 1 +
src/main/resources/public/views/system.html | 1 +
.../resources/public/views/veradevice.html | 5 +-
.../resources/public/views/verascene.html | 1 +
20 files changed, 169 insertions(+), 17 deletions(-)
create mode 100644 src/main/resources/public/views/lifxdevice.html
diff --git a/pom.xml b/pom.xml
index 077a0c8..4e1ff3f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
com.bwssystems.HABridge
ha-bridge
- 4.1.2a
+ 4.1.2b
jar
HA Bridge
diff --git a/src/main/java/com/bwssystems/HABridge/devicemanagmeent/DeviceResource.java b/src/main/java/com/bwssystems/HABridge/devicemanagmeent/DeviceResource.java
index e4b861b..98aaa63 100644
--- a/src/main/java/com/bwssystems/HABridge/devicemanagmeent/DeviceResource.java
+++ b/src/main/java/com/bwssystems/HABridge/devicemanagmeent/DeviceResource.java
@@ -219,6 +219,12 @@ public class DeviceResource {
return homeManager.findResource(DeviceMapTypes.DOMOTICZ_DEVICE[DeviceMapTypes.typeIndex]).getItems(DeviceMapTypes.DOMOTICZ_DEVICE[DeviceMapTypes.typeIndex]);
}, new JsonTransformer());
+ get (API_CONTEXT + "/lifx/devices", "application/json", (request, response) -> {
+ log.debug("Get LIFX devices");
+ response.status(HttpStatus.SC_OK);
+ return homeManager.findResource(DeviceMapTypes.LIFX_DEVICE[DeviceMapTypes.typeIndex]).getItems(DeviceMapTypes.LIFX_DEVICE[DeviceMapTypes.typeIndex]);
+ }, new JsonTransformer());
+
get (API_CONTEXT + "/map/types", "application/json", (request, response) -> {
log.debug("Get map types");
return new DeviceMapTypes().getDeviceMapTypes();
diff --git a/src/main/java/com/bwssystems/HABridge/plugins/lifx/LifxDevice.java b/src/main/java/com/bwssystems/HABridge/plugins/lifx/LifxDevice.java
index 8ca81f9..ea99d9d 100644
--- a/src/main/java/com/bwssystems/HABridge/plugins/lifx/LifxDevice.java
+++ b/src/main/java/com/bwssystems/HABridge/plugins/lifx/LifxDevice.java
@@ -21,11 +21,13 @@ public class LifxDevice {
anEntry = new LifxEntry();
anEntry.setId(((LFXLight)lifxObject).getID());
anEntry.setName(((LFXLight)lifxObject).getLabel());
+ anEntry.setType(LIGHT_TYPE);
}
if(type.equals(GROUP_TYPE)) {
anEntry = new LifxEntry();
anEntry.setId("na");
anEntry.setName(((LFXGroup)lifxObject).getLabel());
+ anEntry.setType(GROUP_TYPE);
}
return anEntry;
}
diff --git a/src/main/java/com/bwssystems/HABridge/plugins/lifx/LifxEntry.java b/src/main/java/com/bwssystems/HABridge/plugins/lifx/LifxEntry.java
index 44574d5..831095d 100644
--- a/src/main/java/com/bwssystems/HABridge/plugins/lifx/LifxEntry.java
+++ b/src/main/java/com/bwssystems/HABridge/plugins/lifx/LifxEntry.java
@@ -3,6 +3,7 @@ package com.bwssystems.HABridge.plugins.lifx;
public class LifxEntry {
private String name;
private String id;
+ private String type;
public String getName() {
return name;
}
@@ -15,4 +16,10 @@ public class LifxEntry {
public void setId(String id) {
this.id = id;
}
+ public String getType() {
+ return type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
}
diff --git a/src/main/resources/public/scripts/app.js b/src/main/resources/public/scripts/app.js
index e6ae6d4..5226dac 100644
--- a/src/main/resources/public/scripts/app.js
+++ b/src/main/resources/public/scripts/app.js
@@ -261,7 +261,7 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
}
this.updateShowLifx = function () {
- this.state.showDomoticz = self.state.settings.lifxconfigured;
+ this.state.showLifx = self.state.settings.lifxconfigured;
return;
}
@@ -277,6 +277,7 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
self.updateShowMqtt();
self.updateShowHass();
self.updateShowDomoticz();
+ self.updateShowLifx();
},
function (error) {
self.displayWarn("Load Bridge Settings Error: ", error);
@@ -2332,10 +2333,10 @@ app.controller('LifxController', function ($scope, $location, $http, bridgeServi
};
$scope.buildDeviceUrls = function (lifxdevice, dim_control) {
- dimpayload = "{\"name\":\"" + lifxdevice.name + "\"}";
- onpayload = "{\"name\":\"" + lifxdevice.name + "\"}";
- offpayload = "{\"name\":\"" + lifxdevice.name + "\"}";
- bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, lifxdevice.name, lifxdevice.name, lifxdevice.name, aDeviceType, "lifxDevice", null, null);
+ dimpayload = angular.toJson(lifxdevice);
+ onpayload = angular.toJson(lifxdevice);
+ offpayload = angular.toJson(lifxdevice);
+ bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, lifxdevice.name, lifxdevice.name, lifxdevice.name, null, "lifxDevice", null, null);
$scope.device = bridgeService.state.device;
bridgeService.editNewDevice($scope.device);
$location.path('/editdevice');
diff --git a/src/main/resources/public/views/configuration.html b/src/main/resources/public/views/configuration.html
index 07a9962..e24e642 100644
--- a/src/main/resources/public/views/configuration.html
+++ b/src/main/resources/public/views/configuration.html
@@ -20,6 +20,7 @@
MQTT Messages
HomeAssistant Devices
Domoticz Devices
+ LIFX Devices
Add/Edit
diff --git a/src/main/resources/public/views/domoticzdevice.html b/src/main/resources/public/views/domoticzdevice.html
index 100c418..2359739 100644
--- a/src/main/resources/public/views/domoticzdevice.html
+++ b/src/main/resources/public/views/domoticzdevice.html
@@ -18,6 +18,7 @@
MQTT Messages
HomeAssistant Devices
Domoticz Devices
+ LIFX Devices
Add/Edit
@@ -35,7 +36,7 @@
done in the edit tab, click the 'Add Bridge Device' to finish that selection
setup. The 'Already Configured Domoticz Devices' list below will show what
is already setup for your Domoticz.
-
+
Also, use this select menu for which type of dim control you would
like to be generated:
@@ -45,7 +46,7 @@
Custom Math
- Use the check boxes by the names to use the bulk addition
+
Use the check boxes by the names to use the bulk addition
feature. Select your items and dim control type if wanted, then click
bulk add below. Your items will be added with on and off or dim and
off if selected with the name of the device from the Domoticz.
diff --git a/src/main/resources/public/views/editdevice.html b/src/main/resources/public/views/editdevice.html
index 625a147..9a33a1c 100644
--- a/src/main/resources/public/views/editdevice.html
+++ b/src/main/resources/public/views/editdevice.html
@@ -20,6 +20,7 @@
HomeAssistant Devices
Domoticz Devices
+ LIFX Devices
Add/Edit
@@ -43,7 +44,7 @@
(${intensity..byte},${intensity.percent},${intensity.math(X*1)}) will
also work. Also, you can go back to any helper tab and click a build
action button to add another item for a multi-command.
- When copying, update the name and select the "Add Bridge
+
When copying, update the name and select the "Add Bridge
Device" Button.