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
  • +
  • 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:

    -

    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
  • @@ -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.

    diff --git a/src/main/resources/public/views/haldevice.html b/src/main/resources/public/views/haldevice.html index 31813ef..a185dbe 100644 --- a/src/main/resources/public/views/haldevice.html +++ b/src/main/resources/public/views/haldevice.html @@ -17,6 +17,7 @@
  • MQTT Messages
  • HomeAssistant Devices
  • Domoticz Devices
  • +
  • LIFX Devices
  • Add/Edit
  • @@ -34,7 +35,7 @@ done in the edit tab, click the 'Add Bridge Device' to finish that selection setup. The 'Already Configured HAL Devices' list below will show what is already setup for your HAL.

    -

    +

    Also, use this select menu for which type of dim control you would like to be generated:

    -

    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 HAL.

    diff --git a/src/main/resources/public/views/harmonyactivity.html b/src/main/resources/public/views/harmonyactivity.html index f933b0b..a82a0c7 100644 --- a/src/main/resources/public/views/harmonyactivity.html +++ b/src/main/resources/public/views/harmonyactivity.html @@ -18,6 +18,7 @@
  • MQTT Messages
  • HomeAssistant Devices
  • Domoticz Devices
  • +
  • LIFX Devices
  • Add/Edit
  • diff --git a/src/main/resources/public/views/harmonydevice.html b/src/main/resources/public/views/harmonydevice.html index 137df4d..6b01a15 100644 --- a/src/main/resources/public/views/harmonydevice.html +++ b/src/main/resources/public/views/harmonydevice.html @@ -18,6 +18,7 @@
  • MQTT Messages
  • HomeAssistant Devices
  • Domoticz Devices
  • +
  • LIFX Devices
  • Add/Edit
  • diff --git a/src/main/resources/public/views/hassdevice.html b/src/main/resources/public/views/hassdevice.html index 5d6284e..71d9b19 100644 --- a/src/main/resources/public/views/hassdevice.html +++ b/src/main/resources/public/views/hassdevice.html @@ -18,6 +18,7 @@
  • MQTT Messages
  • 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 HomeAssistant Devices' list below will show what is already setup for your HomeAssitant.

    -

    +

    Also, use this select menu for which type of dim control you would like to be generated, BUT for Home Assistant, the selection should be Pass-thru:

    -

    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 HomeAssitant.

    diff --git a/src/main/resources/public/views/huedevice.html b/src/main/resources/public/views/huedevice.html index 36fa45d..e3ae20d 100644 --- a/src/main/resources/public/views/huedevice.html +++ b/src/main/resources/public/views/huedevice.html @@ -18,6 +18,7 @@
  • MQTT Messages
  • HomeAssistant Devices
  • Domoticz Devices
  • +
  • LIFX Devices
  • Add/Edit
  • @@ -35,9 +36,9 @@ done in the edit tab, click the 'Add Bridge Device' to finish that selection setup. The 'Already Configured Hue Devices' list below will show what is already setup for your Hue.

    -

    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, then click bulk add below. Your items - will be added with on and off or dim and off if selected with the + will be added with on, off and dim with the name of the device from the Hue.

    diff --git a/src/main/resources/public/views/lifxdevice.html b/src/main/resources/public/views/lifxdevice.html new file mode 100644 index 0000000..3973984 --- /dev/null +++ b/src/main/resources/public/views/lifxdevice.html @@ -0,0 +1,122 @@ + + +
    +
    +

    LIFX Devices

    +
    +
    +

    For any LIFX Device, use the build action buttons + to generate the item addition information into the ha-bridge device and this will put you into the edit screen. Then + you can modify the name to anything you want that will be the keyword + for the Echo or Google Home. Also, you can go back to any helper tab and click a build + action button to add another item for a multi-command. After you are + done in the edit tab, click the 'Add Bridge Device' to finish that selection + setup. The 'Already Configured LIFX Devices' list below will show what + is already setup for your LIFX.

    + +

    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, off and dim + with the name of the device from the LIFX device.

    + +
    + + + + + + + + + + + + + + + + +
    Row + NameIDTypeBuild Actions
    {{$index+1}}{{lifxdev.name}}{{lifxdev.id}}{{lifxdev.type}} + +
    +
    + + + +
    +
    +

    + Already Configured LIFX Devices +

    +
    +
    + + + + + + + + + + + + + + + + + + +
    RowNameLight NameMap IdActions
    {{$index+1}}{{device.name}}{{device.targetDevice}}{{device.mapId}} +

    + + +

    +
    +
    +
    +
    + \ No newline at end of file diff --git a/src/main/resources/public/views/logs.html b/src/main/resources/public/views/logs.html index 3645df5..a1939e9 100644 --- a/src/main/resources/public/views/logs.html +++ b/src/main/resources/public/views/logs.html @@ -18,6 +18,7 @@
  • MQTT Messages
  • HomeAssistant Devices
  • Domoticz Devices
  • +
  • LIFX Devices
  • Add/Edit
  • diff --git a/src/main/resources/public/views/mqttpublish.html b/src/main/resources/public/views/mqttpublish.html index 05f977b..6fd06db 100644 --- a/src/main/resources/public/views/mqttpublish.html +++ b/src/main/resources/public/views/mqttpublish.html @@ -12,6 +12,7 @@
  • HomeAssistant Devices
  • Domoticz Devices
  • +
  • LIFX Devices
  • Add/Edit
  • diff --git a/src/main/resources/public/views/nestactions.html b/src/main/resources/public/views/nestactions.html index 574b84b..59cdfbe 100644 --- a/src/main/resources/public/views/nestactions.html +++ b/src/main/resources/public/views/nestactions.html @@ -18,6 +18,7 @@
  • MQTT Messages
  • HomeAssistant Devices
  • Domoticz Devices
  • +
  • LIFX Devices
  • Add/Edit
  • diff --git a/src/main/resources/public/views/system.html b/src/main/resources/public/views/system.html index 19564fb..62e3bd8 100644 --- a/src/main/resources/public/views/system.html +++ b/src/main/resources/public/views/system.html @@ -19,6 +19,7 @@
  • MQTT Messages
  • HomeAssistant Devices
  • Domoticz Devices
  • +
  • LIFX Devices
  • Add/Edit
  • diff --git a/src/main/resources/public/views/veradevice.html b/src/main/resources/public/views/veradevice.html index f1eeaec..cba365c 100644 --- a/src/main/resources/public/views/veradevice.html +++ b/src/main/resources/public/views/veradevice.html @@ -17,6 +17,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 Vera Devices' list below will show what is already setup for your Vera.

    -

    +

    Also, use this select menu for which type of dim control you would like to be generated:

    -

    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 Vera.

    diff --git a/src/main/resources/public/views/verascene.html b/src/main/resources/public/views/verascene.html index 9e9f30c..70d8aba 100644 --- a/src/main/resources/public/views/verascene.html +++ b/src/main/resources/public/views/verascene.html @@ -17,6 +17,7 @@
  • MQTT Messages
  • HomeAssistant Devices
  • Domoticz Devices
  • +
  • LIFX Devices
  • Add/Edit