From 2dc245bb96f5fcec1450620b5464364e35ba3937 Mon Sep 17 00:00:00 2001 From: Monica Goward Date: Fri, 3 Feb 2017 11:51:05 +0000 Subject: [PATCH 01/14] HTML headers updates only --- .../public/views/domoticzdevice.html | 1 + .../resources/public/views/haldevice.html | 353 +++++++++--------- .../public/views/harmonyactivity.html | 221 +++++------ .../resources/public/views/harmonydevice.html | 259 ++++++------- .../resources/public/views/hassdevice.html | 1 + .../resources/public/views/huedevice.html | 253 ++++++------- src/main/resources/public/views/logs.html | 175 ++++----- .../resources/public/views/mqttpublish.html | 231 ++++++------ .../resources/public/views/nestactions.html | 263 ++++++------- .../resources/public/views/veradevice.html | 282 +++++++------- .../resources/public/views/verascene.html | 221 +++++------ 11 files changed, 1136 insertions(+), 1124 deletions(-) diff --git a/src/main/resources/public/views/domoticzdevice.html b/src/main/resources/public/views/domoticzdevice.html index 100c418..962a595 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
  • +
  • Somfy Devices
  • Add/Edit
  • diff --git a/src/main/resources/public/views/haldevice.html b/src/main/resources/public/views/haldevice.html index 31813ef..a8c743e 100644 --- a/src/main/resources/public/views/haldevice.html +++ b/src/main/resources/public/views/haldevice.html @@ -1,176 +1,177 @@ - - -
    -
    -

    HAL Device List - ({{bridge.haldevices.length}})

    -
    -
    -

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

    - - - - - - - - - - - - - - - - - - - - - - -
    Row - NameCategoryHALOn ButtonOff ButtonBuild Actions
    {{$index+1}} - {{haldevice.haldevicename}}{{haldevice.haldevicetype}}{{haldevice.halname}} - - - - - - - -
      -
    • -

      - - - -

      -

      - - -

      -
    • -
    -
    -
    - -
    -
    -
    -
    -

    - Already Configured HAL Devices -

    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    RowNameCategoryHALMap IdActions
    {{$index+1}}{{device.name}}{{device.deviceType}}{{device.targetDevice}}{{device.mapId}} -

    - - -

    -
    -
    -
    -
    - + + +
    +
    +

    HAL Device List + ({{bridge.haldevices.length}})

    +
    +
    +

    For any HAL 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 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 + 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.

    + + + + + + + + + + + + + + + + + + + + + + +
    Row + NameCategoryHALOn ButtonOff ButtonBuild Actions
    {{$index+1}} + {{haldevice.haldevicename}}{{haldevice.haldevicetype}}{{haldevice.halname}} + + + + + + + +
      +
    • +

      + + + +

      +

      + + +

      +
    • +
    +
    +
    + +
    +
    +
    +
    +

    + Already Configured HAL Devices +

    +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    RowNameCategoryHALMap IdActions
    {{$index+1}}{{device.name}}{{device.deviceType}}{{device.targetDevice}}{{device.mapId}} +

    + + +

    +
    +
    +
    +
    + diff --git a/src/main/resources/public/views/harmonyactivity.html b/src/main/resources/public/views/harmonyactivity.html index f933b0b..0eef1c1 100644 --- a/src/main/resources/public/views/harmonyactivity.html +++ b/src/main/resources/public/views/harmonyactivity.html @@ -1,111 +1,112 @@ - - -
    -
    -

    Harmony Activity List

    -
    -
    -

    For any Harmony Activity, 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 Activities' list - below will show what is already setup for your Harmony Hubs.

    - - - - - - - - - - - - - - - - - - - -
    RowNameIdHubBuild Actions
    {{$index+1}}{{harmonyactivity.activity.label}}{{harmonyactivity.activity.id}}{{harmonyactivity.hub}} - -
    -
    -
    -
    -
    -
    -

    - Already Configured Activities -

    -
    -
    - - - - - - - - - - - - - - - - - - -
    RowNameHubMap IdActions
    {{$index+1}}{{device.name}}{{device.targetDevice}}{{device.mapId}} -

    - - -

    -
    -
    -
    -
    - \ No newline at end of file diff --git a/src/main/resources/public/views/harmonydevice.html b/src/main/resources/public/views/harmonydevice.html index 137df4d..7f2e217 100644 --- a/src/main/resources/public/views/harmonydevice.html +++ b/src/main/resources/public/views/harmonydevice.html @@ -1,130 +1,131 @@ - - -
    -
    -

    Harmony Device List

    -
    -
    -

    For any Harmony Device and Buttons, 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 Harmony Buttons' list below will show what is already - setup for your Harmony Hubs.

    - - - - - - - - - - - - - - - - - - - - - - - -
    RowNameIdHubOn ButtonOff ButtonBuild Actions
    {{$index+1}}{{harmonydevice.device.label}}{{harmonydevice.device.id}}{{harmonydevice.hub}} - -
    -
    -
    -
    -
    -
    -

    - Already Configured Harmony Buttons -

    -
    -
    - - - - - - - - - - - - - - - - - - -
    RowNameHubHarmony Device-Button On-Button OffActions
    {{$index+1}}{{device.name}}{{device.targetDevice}}{{device.mapId}} -

    - - -

    -
    -
    -
    -
    - \ No newline at end of file diff --git a/src/main/resources/public/views/hassdevice.html b/src/main/resources/public/views/hassdevice.html index 256bf2a..13a31ee 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
  • +
  • Somfy Devices
  • Add/Edit
  • diff --git a/src/main/resources/public/views/huedevice.html b/src/main/resources/public/views/huedevice.html index 36fa45d..5e7e907 100644 --- a/src/main/resources/public/views/huedevice.html +++ b/src/main/resources/public/views/huedevice.html @@ -1,126 +1,127 @@ - - -
    -
    -

    Hue Device List - ({{bridge.huedevices.length}})

    -
    -
    -

    For any Hue 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 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 - 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 - name of the device from the Hue.

    - - - - - - - - - - - - - - - - - - -
    Row NameIdHueBuild Actions
    {{$index+1}} - {{huedevice.device.name}}{{huedevice.device.uniqueid}}{{huedevice.huename}} - -
    -
    - -
    -
    -
    -
    -

    - Already Configured Hue Devices -

    -
    -
    - - - - - - - - - - - - - - - - - - -
    RowNamehueMap IdActions
    {{$index+1}}{{device.name}}{{device.targetDevice}}{{device.mapId}} -

    - - -

    -
    -
    -
    -
    - + + +
    +
    +

    Hue Device List + ({{bridge.huedevices.length}})

    +
    +
    +

    For any Hue 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 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 + 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 + name of the device from the Hue.

    + + + + + + + + + + + + + + + + + + +
    Row NameIdHueBuild Actions
    {{$index+1}} + {{huedevice.device.name}}{{huedevice.device.uniqueid}}{{huedevice.huename}} + +
    +
    + +
    +
    +
    +
    +

    + Already Configured Hue Devices +

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

    + + +

    +
    +
    +
    +
    + diff --git a/src/main/resources/public/views/logs.html b/src/main/resources/public/views/logs.html index 3645df5..bcd1980 100644 --- a/src/main/resources/public/views/logs.html +++ b/src/main/resources/public/views/logs.html @@ -1,88 +1,89 @@ - - -
    -
    -

    Log Messages

    -
    -
    -

    - -

    - - - - - - - - - - - - - - - - -
    TimeLevelMessageComponent
    {{logMessage.time}}{{logMessage.level}}{{logMessage.message}}{{logMessage.component}}
    -
    -
    -
    -
    -
    -

    - Logging Configuration -

    -
    -
    -

    - - Show All Loggers - {{bridge.logShowAll}} -

    - - - - - - - - - - - - - - -
    Log LevelComponentNew Log Level
    {{logInfo.logLevel.substr(0,logInfo.logLevel.indexOf("_"))}}{{logInfo.loggerName}}
    -
    -
    + + +
    +
    +

    Log Messages

    +
    +
    +

    + +

    + + + + + + + + + + + + + + + + +
    TimeLevelMessageComponent
    {{logMessage.time}}{{logMessage.level}}{{logMessage.message}}{{logMessage.component}}
    +
    +
    +
    +
    +
    +

    + Logging Configuration +

    +
    +
    +

    + + Show All Loggers + {{bridge.logShowAll}} +

    + + + + + + + + + + + + + + +
    Log LevelComponentNew Log Level
    {{logInfo.logLevel.substr(0,logInfo.logLevel.indexOf("_"))}}{{logInfo.loggerName}}
    +
    +
    \ No newline at end of file diff --git a/src/main/resources/public/views/mqttpublish.html b/src/main/resources/public/views/mqttpublish.html index 05f977b..50755c2 100644 --- a/src/main/resources/public/views/mqttpublish.html +++ b/src/main/resources/public/views/mqttpublish.html @@ -1,116 +1,117 @@ - - -
    -
    -

    MQTT Messages

    -
    -
    -

    For any MQTT Broker, 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. - You can add topic and content in the text areas provided - then selecting the publish generation. 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 MQTT Publish messages' list below will show what is already - setup for your MQTT Brokers.

    - - - - - - - - - - - - - - - - - - - - - -
    RowClientIDIPTopicContentBuild Actions
    {{$index+1}}{{mqttbroker.clientId}}{{mqttbroker.ip}} - - - - - -
    -
    -
    -
    -
    -
    -

    - Already Configured MQTT Messages -

    -
    -
    - - - - - - - - - - - - - - - - - - -
    RowNameClientIDMap IdActions
    {{$index+1}}{{device.name}}{{device.targetDevice}}{{device.mapId}} -

    - - -

    -
    -
    -
    -
    - \ No newline at end of file diff --git a/src/main/resources/public/views/nestactions.html b/src/main/resources/public/views/nestactions.html index 574b84b..e5a139e 100644 --- a/src/main/resources/public/views/nestactions.html +++ b/src/main/resources/public/views/nestactions.html @@ -1,132 +1,133 @@ - - -
    -
    -

    Nest Items List

    -
    -
    -

    For any Nest Item, 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 Nest Items' list below will show what - is already setup for your Nest.

    - - - - - - - - - - - - - - - - - - - -
    RowNameTypeLocationBuild Actions
    {{$index+1}}{{nestitem.name}}{{nestitem.type}}{{nestitem.location}} -
      -
    • - -
    • -
    • -

      - - - -

      -

      - - - -

      -
    • -
    -
    -
    -
    -
    -
    -
    -

    - Already Configured Nest Items -

    -
    -
    - - - - - - - - - - - - - - - - - - -
    RowNameLocationMap IdActions
    {{$index+1}}{{device.name}}{{device.targetDevice}}{{device.mapId}} -

    - - -

    -
    -
    -
    -
    - \ No newline at end of file diff --git a/src/main/resources/public/views/veradevice.html b/src/main/resources/public/views/veradevice.html index f1eeaec..6f522e3 100644 --- a/src/main/resources/public/views/veradevice.html +++ b/src/main/resources/public/views/veradevice.html @@ -1,141 +1,143 @@ - - -
    -
    -

    Vera Device List - ({{bridge.veradevices.length}})

    -
    -
    -

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

    - - - - - - - - - - - - - - - - - - - - - - -
    Row NameIdCategoryRoomVeraBuild Actions
    {{$index+1}} - {{veradevice.name}}{{veradevice.id}}{{veradevice.category}}{{veradevice.room}}{{veradevice.veraname}} - -
    -
    - -
    -
    -
    -
    -

    - Already Configured Vera Devices -

    -
    -
    - - - - - - - - - - - - - - - - - - -
    RowNameVeraMap IdActions
    {{$index+1}}{{device.name}}{{device.targetDevice}}{{device.mapId}} -

    - - -

    -
    -
    -
    -
    - \ No newline at end of file diff --git a/src/main/resources/public/views/verascene.html b/src/main/resources/public/views/verascene.html index 9e9f30c..96de847 100644 --- a/src/main/resources/public/views/verascene.html +++ b/src/main/resources/public/views/verascene.html @@ -1,111 +1,112 @@ - - -
    -
    -

    Vera Scene List

    -
    -
    -

    For any Vera Scene, 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 Vera Scenes' list below will show what - is already setup for your Vera.

    - - - - - - - - - - - - - - - - - - - - - -
    RowNameIdRoomVeraBuild Actions
    {{$index+1}}{{verascene.name}}{{verascene.id}}{{verascene.room}}{{verascene.veraname}} - -
    -
    -
    -
    -
    -
    -

    - Already Configured Vera Scenes -

    -
    -
    - - - - - - - - - - - - - - - - - - -
    RowNameVeraMap IdActions
    {{$index+1}}{{device.name}}{{device.targetDevice}}{{device.mapId}} -

    - - -

    -
    -
    -
    -
    - \ No newline at end of file From 7a354619d0b333901c4f5a48536809d5b760600c Mon Sep 17 00:00:00 2001 From: Monica Goward Date: Fri, 3 Feb 2017 12:01:47 +0000 Subject: [PATCH 02/14] Generated pojos from JSON Somfy return data --- .../jsonschema2pojo/getsetup/Command.java | 32 +++ .../getsetup/Connectivity.java | 32 +++ .../getsetup/DataProperty.java | 32 +++ .../jsonschema2pojo/getsetup/Definition.java | 99 +++++++++ .../jsonschema2pojo/getsetup/Device.java | 198 +++++++++++++++++ .../jsonschema2pojo/getsetup/Feature.java | 32 +++ .../jsonschema2pojo/getsetup/Gateway.java | 120 ++++++++++ .../jsonschema2pojo/getsetup/GetSetup.java | 33 +++ .../jsonschema2pojo/getsetup/Location.java | 208 ++++++++++++++++++ .../jsonschema2pojo/getsetup/RootPlace.java | 77 +++++++ .../somfy/jsonschema2pojo/getsetup/Setup.java | 121 ++++++++++ .../somfy/jsonschema2pojo/getsetup/State.java | 55 +++++ .../jsonschema2pojo/getsetup/State_.java | 43 ++++ .../jsonschema2pojo/getsetup/SubPlace.java | 88 ++++++++ .../jsonschema2pojo/getsetup/SubPlace_.java | 88 ++++++++ .../jsonschema2pojo/getsetup/generationConfig | 17 ++ 16 files changed, 1275 insertions(+) create mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Command.java create mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Connectivity.java create mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/DataProperty.java create mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Definition.java create mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Device.java create mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Feature.java create mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Gateway.java create mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/GetSetup.java create mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Location.java create mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/RootPlace.java create mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Setup.java create mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/State.java create mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/State_.java create mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/SubPlace.java create mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/SubPlace_.java create mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/generationConfig diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Command.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Command.java new file mode 100644 index 0000000..e3df38d --- /dev/null +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Command.java @@ -0,0 +1,32 @@ + +package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Command { + + @SerializedName("commandName") + @Expose + private String commandName; + @SerializedName("nparams") + @Expose + private Long nparams; + + public String getCommandName() { + return commandName; + } + + public void setCommandName(String commandName) { + this.commandName = commandName; + } + + public Long getNparams() { + return nparams; + } + + public void setNparams(Long nparams) { + this.nparams = nparams; + } + +} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Connectivity.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Connectivity.java new file mode 100644 index 0000000..b2ca632 --- /dev/null +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Connectivity.java @@ -0,0 +1,32 @@ + +package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Connectivity { + + @SerializedName("status") + @Expose + private String status; + @SerializedName("protocolVersion") + @Expose + private String protocolVersion; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getProtocolVersion() { + return protocolVersion; + } + + public void setProtocolVersion(String protocolVersion) { + this.protocolVersion = protocolVersion; + } + +} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/DataProperty.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/DataProperty.java new file mode 100644 index 0000000..68df4d0 --- /dev/null +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/DataProperty.java @@ -0,0 +1,32 @@ + +package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class DataProperty { + + @SerializedName("value") + @Expose + private String value; + @SerializedName("qualifiedName") + @Expose + private String qualifiedName; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getQualifiedName() { + return qualifiedName; + } + + public void setQualifiedName(String qualifiedName) { + this.qualifiedName = qualifiedName; + } + +} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Definition.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Definition.java new file mode 100644 index 0000000..154ec8e --- /dev/null +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Definition.java @@ -0,0 +1,99 @@ + +package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; + +import java.util.List; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Definition { + + @SerializedName("commands") + @Expose + private List commands = null; + @SerializedName("events") + @Expose + private List events = null; + @SerializedName("states") + @Expose + private List states = null; + @SerializedName("dataProperties") + @Expose + private List dataProperties = null; + @SerializedName("widgetName") + @Expose + private String widgetName; + @SerializedName("uiClass") + @Expose + private String uiClass; + @SerializedName("qualifiedName") + @Expose + private String qualifiedName; + @SerializedName("type") + @Expose + private String type; + + public List getCommands() { + return commands; + } + + public void setCommands(List commands) { + this.commands = commands; + } + + public List getEvents() { + return events; + } + + public void setEvents(List events) { + this.events = events; + } + + public List getStates() { + return states; + } + + public void setStates(List states) { + this.states = states; + } + + public List getDataProperties() { + return dataProperties; + } + + public void setDataProperties(List dataProperties) { + this.dataProperties = dataProperties; + } + + public String getWidgetName() { + return widgetName; + } + + public void setWidgetName(String widgetName) { + this.widgetName = widgetName; + } + + public String getUiClass() { + return uiClass; + } + + public void setUiClass(String uiClass) { + this.uiClass = uiClass; + } + + public String getQualifiedName() { + return qualifiedName; + } + + public void setQualifiedName(String qualifiedName) { + this.qualifiedName = qualifiedName; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + +} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Device.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Device.java new file mode 100644 index 0000000..ddff606 --- /dev/null +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Device.java @@ -0,0 +1,198 @@ + +package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; + +import java.util.List; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Device { + + @SerializedName("creationTime") + @Expose + private Long creationTime; + @SerializedName("lastUpdateTime") + @Expose + private Long lastUpdateTime; + @SerializedName("label") + @Expose + private String label; + @SerializedName("deviceURL") + @Expose + private String deviceURL; + @SerializedName("shortcut") + @Expose + private Boolean shortcut; + @SerializedName("controllableName") + @Expose + private String controllableName; + @SerializedName("metadata") + @Expose + private String metadata; + @SerializedName("definition") + @Expose + private Definition definition; + @SerializedName("states") + @Expose + private List states = null; + @SerializedName("attributes") + @Expose + private List attributes = null; + @SerializedName("available") + @Expose + private Boolean available; + @SerializedName("enabled") + @Expose + private Boolean enabled; + @SerializedName("placeOID") + @Expose + private String placeOID; + @SerializedName("widget") + @Expose + private String widget; + @SerializedName("type") + @Expose + private Long type; + @SerializedName("oid") + @Expose + private String oid; + @SerializedName("uiClass") + @Expose + private String uiClass; + + public Long getCreationTime() { + return creationTime; + } + + public void setCreationTime(Long creationTime) { + this.creationTime = creationTime; + } + + public Long getLastUpdateTime() { + return lastUpdateTime; + } + + public void setLastUpdateTime(Long lastUpdateTime) { + this.lastUpdateTime = lastUpdateTime; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getDeviceURL() { + return deviceURL; + } + + public void setDeviceURL(String deviceURL) { + this.deviceURL = deviceURL; + } + + public Boolean getShortcut() { + return shortcut; + } + + public void setShortcut(Boolean shortcut) { + this.shortcut = shortcut; + } + + public String getControllableName() { + return controllableName; + } + + public void setControllableName(String controllableName) { + this.controllableName = controllableName; + } + + public String getMetadata() { + return metadata; + } + + public void setMetadata(String metadata) { + this.metadata = metadata; + } + + public Definition getDefinition() { + return definition; + } + + public void setDefinition(Definition definition) { + this.definition = definition; + } + + public List getStates() { + return states; + } + + public void setStates(List states) { + this.states = states; + } + + public List getAttributes() { + return attributes; + } + + public void setAttributes(List attributes) { + this.attributes = attributes; + } + + public Boolean getAvailable() { + return available; + } + + public void setAvailable(Boolean available) { + this.available = available; + } + + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public String getPlaceOID() { + return placeOID; + } + + public void setPlaceOID(String placeOID) { + this.placeOID = placeOID; + } + + public String getWidget() { + return widget; + } + + public void setWidget(String widget) { + this.widget = widget; + } + + public Long getType() { + return type; + } + + public void setType(Long type) { + this.type = type; + } + + public String getOid() { + return oid; + } + + public void setOid(String oid) { + this.oid = oid; + } + + public String getUiClass() { + return uiClass; + } + + public void setUiClass(String uiClass) { + this.uiClass = uiClass; + } + +} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Feature.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Feature.java new file mode 100644 index 0000000..62f1bd7 --- /dev/null +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Feature.java @@ -0,0 +1,32 @@ + +package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Feature { + + @SerializedName("name") + @Expose + private String name; + @SerializedName("source") + @Expose + private String source; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + +} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Gateway.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Gateway.java new file mode 100644 index 0000000..52487d9 --- /dev/null +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Gateway.java @@ -0,0 +1,120 @@ + +package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Gateway { + + @SerializedName("gatewayId") + @Expose + private String gatewayId; + @SerializedName("type") + @Expose + private Long type; + @SerializedName("subType") + @Expose + private Long subType; + @SerializedName("placeOID") + @Expose + private String placeOID; + @SerializedName("alive") + @Expose + private Boolean alive; + @SerializedName("timeReliable") + @Expose + private Boolean timeReliable; + @SerializedName("connectivity") + @Expose + private Connectivity connectivity; + @SerializedName("upToDate") + @Expose + private Boolean upToDate; + @SerializedName("mode") + @Expose + private String mode; + @SerializedName("functions") + @Expose + private String functions; + + public String getGatewayId() { + return gatewayId; + } + + public void setGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + } + + public Long getType() { + return type; + } + + public void setType(Long type) { + this.type = type; + } + + public Long getSubType() { + return subType; + } + + public void setSubType(Long subType) { + this.subType = subType; + } + + public String getPlaceOID() { + return placeOID; + } + + public void setPlaceOID(String placeOID) { + this.placeOID = placeOID; + } + + public Boolean getAlive() { + return alive; + } + + public void setAlive(Boolean alive) { + this.alive = alive; + } + + public Boolean getTimeReliable() { + return timeReliable; + } + + public void setTimeReliable(Boolean timeReliable) { + this.timeReliable = timeReliable; + } + + public Connectivity getConnectivity() { + return connectivity; + } + + public void setConnectivity(Connectivity connectivity) { + this.connectivity = connectivity; + } + + public Boolean getUpToDate() { + return upToDate; + } + + public void setUpToDate(Boolean upToDate) { + this.upToDate = upToDate; + } + + public String getMode() { + return mode; + } + + public void setMode(String mode) { + this.mode = mode; + } + + public String getFunctions() { + return functions; + } + + public void setFunctions(String functions) { + this.functions = functions; + } + +} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/GetSetup.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/GetSetup.java new file mode 100644 index 0000000..3ab0449 --- /dev/null +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/GetSetup.java @@ -0,0 +1,33 @@ + +package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; + +import java.util.List; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class GetSetup { + + @SerializedName("setup") + @Expose + private Setup setup; + @SerializedName("events") + @Expose + private List events = null; + + public Setup getSetup() { + return setup; + } + + public void setSetup(Setup setup) { + this.setup = setup; + } + + public List getEvents() { + return events; + } + + public void setEvents(List events) { + this.events = events; + } + +} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Location.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Location.java new file mode 100644 index 0000000..c4f9cf9 --- /dev/null +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Location.java @@ -0,0 +1,208 @@ + +package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Location { + + @SerializedName("creationTime") + @Expose + private Long creationTime; + @SerializedName("lastUpdateTime") + @Expose + private Long lastUpdateTime; + @SerializedName("city") + @Expose + private String city; + @SerializedName("country") + @Expose + private String country; + @SerializedName("postalCode") + @Expose + private String postalCode; + @SerializedName("addressLine1") + @Expose + private String addressLine1; + @SerializedName("addressLine2") + @Expose + private String addressLine2; + @SerializedName("timezone") + @Expose + private String timezone; + @SerializedName("longitude") + @Expose + private Double longitude; + @SerializedName("latitude") + @Expose + private Double latitude; + @SerializedName("twilightMode") + @Expose + private Long twilightMode; + @SerializedName("twilightAngle") + @Expose + private String twilightAngle; + @SerializedName("twilightCity") + @Expose + private String twilightCity; + @SerializedName("summerSolsticeDuskMinutes") + @Expose + private Long summerSolsticeDuskMinutes; + @SerializedName("winterSolsticeDuskMinutes") + @Expose + private Long winterSolsticeDuskMinutes; + @SerializedName("twilightOffsetEnabled") + @Expose + private Boolean twilightOffsetEnabled; + @SerializedName("dawnOffset") + @Expose + private Long dawnOffset; + @SerializedName("duskOffset") + @Expose + private Long duskOffset; + + public Long getCreationTime() { + return creationTime; + } + + public void setCreationTime(Long creationTime) { + this.creationTime = creationTime; + } + + public Long getLastUpdateTime() { + return lastUpdateTime; + } + + public void setLastUpdateTime(Long lastUpdateTime) { + this.lastUpdateTime = lastUpdateTime; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public String getPostalCode() { + return postalCode; + } + + public void setPostalCode(String postalCode) { + this.postalCode = postalCode; + } + + public String getAddressLine1() { + return addressLine1; + } + + public void setAddressLine1(String addressLine1) { + this.addressLine1 = addressLine1; + } + + public String getAddressLine2() { + return addressLine2; + } + + public void setAddressLine2(String addressLine2) { + this.addressLine2 = addressLine2; + } + + public String getTimezone() { + return timezone; + } + + public void setTimezone(String timezone) { + this.timezone = timezone; + } + + public Double getLongitude() { + return longitude; + } + + public void setLongitude(Double longitude) { + this.longitude = longitude; + } + + public Double getLatitude() { + return latitude; + } + + public void setLatitude(Double latitude) { + this.latitude = latitude; + } + + public Long getTwilightMode() { + return twilightMode; + } + + public void setTwilightMode(Long twilightMode) { + this.twilightMode = twilightMode; + } + + public String getTwilightAngle() { + return twilightAngle; + } + + public void setTwilightAngle(String twilightAngle) { + this.twilightAngle = twilightAngle; + } + + public String getTwilightCity() { + return twilightCity; + } + + public void setTwilightCity(String twilightCity) { + this.twilightCity = twilightCity; + } + + public Long getSummerSolsticeDuskMinutes() { + return summerSolsticeDuskMinutes; + } + + public void setSummerSolsticeDuskMinutes(Long summerSolsticeDuskMinutes) { + this.summerSolsticeDuskMinutes = summerSolsticeDuskMinutes; + } + + public Long getWinterSolsticeDuskMinutes() { + return winterSolsticeDuskMinutes; + } + + public void setWinterSolsticeDuskMinutes(Long winterSolsticeDuskMinutes) { + this.winterSolsticeDuskMinutes = winterSolsticeDuskMinutes; + } + + public Boolean getTwilightOffsetEnabled() { + return twilightOffsetEnabled; + } + + public void setTwilightOffsetEnabled(Boolean twilightOffsetEnabled) { + this.twilightOffsetEnabled = twilightOffsetEnabled; + } + + public Long getDawnOffset() { + return dawnOffset; + } + + public void setDawnOffset(Long dawnOffset) { + this.dawnOffset = dawnOffset; + } + + public Long getDuskOffset() { + return duskOffset; + } + + public void setDuskOffset(Long duskOffset) { + this.duskOffset = duskOffset; + } + +} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/RootPlace.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/RootPlace.java new file mode 100644 index 0000000..902dfbe --- /dev/null +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/RootPlace.java @@ -0,0 +1,77 @@ + +package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; + +import java.util.List; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class RootPlace { + + @SerializedName("creationTime") + @Expose + private Long creationTime; + @SerializedName("lastUpdateTime") + @Expose + private Long lastUpdateTime; + @SerializedName("label") + @Expose + private String label; + @SerializedName("type") + @Expose + private Long type; + @SerializedName("oid") + @Expose + private String oid; + @SerializedName("subPlaces") + @Expose + private List subPlaces = null; + + public Long getCreationTime() { + return creationTime; + } + + public void setCreationTime(Long creationTime) { + this.creationTime = creationTime; + } + + public Long getLastUpdateTime() { + return lastUpdateTime; + } + + public void setLastUpdateTime(Long lastUpdateTime) { + this.lastUpdateTime = lastUpdateTime; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public Long getType() { + return type; + } + + public void setType(Long type) { + this.type = type; + } + + public String getOid() { + return oid; + } + + public void setOid(String oid) { + this.oid = oid; + } + + public List getSubPlaces() { + return subPlaces; + } + + public void setSubPlaces(List subPlaces) { + this.subPlaces = subPlaces; + } + +} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Setup.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Setup.java new file mode 100644 index 0000000..57b5656 --- /dev/null +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Setup.java @@ -0,0 +1,121 @@ + +package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; + +import java.util.List; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Setup { + + @SerializedName("creationTime") + @Expose + private Long creationTime; + @SerializedName("lastUpdateTime") + @Expose + private Long lastUpdateTime; + @SerializedName("id") + @Expose + private String id; + @SerializedName("location") + @Expose + private Location location; + @SerializedName("gateways") + @Expose + private List gateways = null; + @SerializedName("devices") + @Expose + private List devices = null; + @SerializedName("zones") + @Expose + private List zones = null; + @SerializedName("resellerDelegationType") + @Expose + private String resellerDelegationType; + @SerializedName("rootPlace") + @Expose + private RootPlace rootPlace; + @SerializedName("features") + @Expose + private List features = null; + + public Long getCreationTime() { + return creationTime; + } + + public void setCreationTime(Long creationTime) { + this.creationTime = creationTime; + } + + public Long getLastUpdateTime() { + return lastUpdateTime; + } + + public void setLastUpdateTime(Long lastUpdateTime) { + this.lastUpdateTime = lastUpdateTime; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Location getLocation() { + return location; + } + + public void setLocation(Location location) { + this.location = location; + } + + public List getGateways() { + return gateways; + } + + public void setGateways(List gateways) { + this.gateways = gateways; + } + + public List getDevices() { + return devices; + } + + public void setDevices(List devices) { + this.devices = devices; + } + + public List getZones() { + return zones; + } + + public void setZones(List zones) { + this.zones = zones; + } + + public String getResellerDelegationType() { + return resellerDelegationType; + } + + public void setResellerDelegationType(String resellerDelegationType) { + this.resellerDelegationType = resellerDelegationType; + } + + public RootPlace getRootPlace() { + return rootPlace; + } + + public void setRootPlace(RootPlace rootPlace) { + this.rootPlace = rootPlace; + } + + public List getFeatures() { + return features; + } + + public void setFeatures(List features) { + this.features = features; + } + +} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/State.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/State.java new file mode 100644 index 0000000..41197f9 --- /dev/null +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/State.java @@ -0,0 +1,55 @@ + +package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; + +import java.util.List; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class State { + + @SerializedName("eventBased") + @Expose + private Boolean eventBased; + @SerializedName("values") + @Expose + private List values = null; + @SerializedName("type") + @Expose + private String type; + @SerializedName("qualifiedName") + @Expose + private String qualifiedName; + + public Boolean getEventBased() { + return eventBased; + } + + public void setEventBased(Boolean eventBased) { + this.eventBased = eventBased; + } + + public List getValues() { + return values; + } + + public void setValues(List values) { + this.values = values; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getQualifiedName() { + return qualifiedName; + } + + public void setQualifiedName(String qualifiedName) { + this.qualifiedName = qualifiedName; + } + +} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/State_.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/State_.java new file mode 100644 index 0000000..90b60a6 --- /dev/null +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/State_.java @@ -0,0 +1,43 @@ + +package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class State_ { + + @SerializedName("name") + @Expose + private String name; + @SerializedName("type") + @Expose + private Long type; + @SerializedName("value") + @Expose + private String value; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Long getType() { + return type; + } + + public void setType(Long type) { + this.type = type; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/SubPlace.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/SubPlace.java new file mode 100644 index 0000000..76cc486 --- /dev/null +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/SubPlace.java @@ -0,0 +1,88 @@ + +package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; + +import java.util.List; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class SubPlace { + + @SerializedName("creationTime") + @Expose + private Long creationTime; + @SerializedName("lastUpdateTime") + @Expose + private Long lastUpdateTime; + @SerializedName("label") + @Expose + private String label; + @SerializedName("type") + @Expose + private Long type; + @SerializedName("metadata") + @Expose + private String metadata; + @SerializedName("oid") + @Expose + private String oid; + @SerializedName("subPlaces") + @Expose + private List subPlaces = null; + + public Long getCreationTime() { + return creationTime; + } + + public void setCreationTime(Long creationTime) { + this.creationTime = creationTime; + } + + public Long getLastUpdateTime() { + return lastUpdateTime; + } + + public void setLastUpdateTime(Long lastUpdateTime) { + this.lastUpdateTime = lastUpdateTime; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public Long getType() { + return type; + } + + public void setType(Long type) { + this.type = type; + } + + public String getMetadata() { + return metadata; + } + + public void setMetadata(String metadata) { + this.metadata = metadata; + } + + public String getOid() { + return oid; + } + + public void setOid(String oid) { + this.oid = oid; + } + + public List getSubPlaces() { + return subPlaces; + } + + public void setSubPlaces(List subPlaces) { + this.subPlaces = subPlaces; + } + +} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/SubPlace_.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/SubPlace_.java new file mode 100644 index 0000000..abdd748 --- /dev/null +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/SubPlace_.java @@ -0,0 +1,88 @@ + +package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; + +import java.util.List; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class SubPlace_ { + + @SerializedName("creationTime") + @Expose + private Long creationTime; + @SerializedName("lastUpdateTime") + @Expose + private Long lastUpdateTime; + @SerializedName("label") + @Expose + private String label; + @SerializedName("type") + @Expose + private Long type; + @SerializedName("metadata") + @Expose + private String metadata; + @SerializedName("oid") + @Expose + private String oid; + @SerializedName("subPlaces") + @Expose + private List subPlaces = null; + + public Long getCreationTime() { + return creationTime; + } + + public void setCreationTime(Long creationTime) { + this.creationTime = creationTime; + } + + public Long getLastUpdateTime() { + return lastUpdateTime; + } + + public void setLastUpdateTime(Long lastUpdateTime) { + this.lastUpdateTime = lastUpdateTime; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public Long getType() { + return type; + } + + public void setType(Long type) { + this.type = type; + } + + public String getMetadata() { + return metadata; + } + + public void setMetadata(String metadata) { + this.metadata = metadata; + } + + public String getOid() { + return oid; + } + + public void setOid(String oid) { + this.oid = oid; + } + + public List getSubPlaces() { + return subPlaces; + } + + public void setSubPlaces(List subPlaces) { + this.subPlaces = subPlaces; + } + +} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/generationConfig b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/generationConfig new file mode 100644 index 0000000..e0d5d12 --- /dev/null +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/generationConfig @@ -0,0 +1,17 @@ +http://www.jsonschema2pojo.org/ + +The json was: +{"setup":{"creationTime":1481970091000,"lastUpdateTime":1481970091000,"id":"SETUP-1202-4393-9834","location":{"creationTime":1481970091000,"lastUpdateTime":1481970412000,"city":"London","country":"Switzerland","postalCode":"SW15 1QR","addressLine1":"5 Abbotstone Road","addressLine2":"","timezone":"Europe/Zurich","longitude":-0.1262,"latitude":51.5001,"twilightMode":3,"twilightAngle":"CIVIL","twilightCity":"london","summerSolsticeDuskMinutes":1290,"winterSolsticeDuskMinutes":990,"twilightOffsetEnabled":true,"dawnOffset":0,"duskOffset":0},"gateways":[{"gatewayId":"1202-4393-9834","type":29,"subType":2,"placeOID":"6bf877ec-bce0-4243-86d6-ec8526c97efe","alive":true,"timeReliable":true,"connectivity":{"status":"OK","protocolVersion":"16"},"upToDate":true,"mode":"ACTIVE","functions":"INTERNET_AUTHORIZATION,SCENARIO_DOWNLOAD,SCENARIO_AUTO_LAUNCHING,SCENARIO_TELECO_LAUNCHING,INTERNET_UPLOAD,INTERNET_UPDATE,TRIGGERS_SENSORS"}],"devices":[{"creationTime":1481970091000,"lastUpdateTime":1481970091000,"label":"Touch button","deviceURL":"internal://1202-4393-9834/pod/0","shortcut":false,"controllableName":"internal:PodV2Component","metadata":"{\"tahoma\":{\"touchButtonFlag\":true}}","definition":{"commands":[{"commandName":"getName","nparams":0},{"commandName":"refreshBatteryStatus","nparams":0},{"commandName":"refreshPodMode","nparams":0},{"commandName":"setLightingLedPodMode","nparams":1},{"commandName":"setPodLedOff","nparams":0},{"commandName":"setPodLedOn","nparams":0}],"events":[],"states":[{"eventBased":false,"values":["pressed","stop"],"type":"DiscreteState","qualifiedName":"core:CyclicButtonState"},{"eventBased":false,"type":"DataState","qualifiedName":"core:NameState"},{"eventBased":false,"type":"ContinuousState","qualifiedName":"internal:BatteryStatusState"},{"eventBased":false,"type":"ContinuousState","qualifiedName":"internal:LightingLedPodModeState"}],"dataProperties":[],"widgetName":"Pod","uiClass":"Pod","qualifiedName":"internal:PodV2Component","type":"ACTUATOR"},"states":[{"name":"core:NameState","type":3,"value":"Box"},{"name":"internal:BatteryStatusState","type":3,"value":"no"},{"name":"internal:LightingLedPodModeState","type":3,"value":"1"}],"attributes":[],"available":true,"enabled":true,"placeOID":"6bf877ec-bce0-4243-86d6-ec8526c97efe","widget":"Pod","type":1,"oid":"1b8766cd-298c-4bfe-95ad-26b4cc8f0ae5","uiClass":"Pod"},{"creationTime":1481978106000,"lastUpdateTime":1481978106000,"label":"Corridor Window","deviceURL":"io://1202-4393-9834/1867135","shortcut":false,"controllableName":"io:WindowOpenerVeluxIOComponent","definition":{"commands":[{"commandName":"close","nparams":0},{"commandName":"delayedStopIdentify","nparams":1},{"commandName":"getName","nparams":0},{"commandName":"identify","nparams":0},{"commandName":"open","nparams":0},{"commandName":"setClosure","nparams":1},{"commandName":"setName","nparams":1},{"commandName":"startIdentify","nparams":0},{"commandName":"stopIdentify","nparams":0},{"commandName":"wink","nparams":1}],"events":[],"states":[{"eventBased":false,"type":"ContinuousState","qualifiedName":"core:ClosureState"},{"eventBased":false,"type":"DataState","qualifiedName":"core:NameState"},{"eventBased":false,"values":["closed","open"],"type":"DiscreteState","qualifiedName":"core:OpenClosedState"},{"eventBased":false,"type":"ContinuousState","qualifiedName":"core:PriorityLockTimerState"},{"eventBased":false,"type":"ContinuousState","qualifiedName":"core:RSSILevelState"},{"eventBased":false,"values":["available","unavailable"],"type":"DiscreteState","qualifiedName":"core:StatusState"},{"eventBased":false,"values":["comfortLevel1","comfortLevel2","comfortLevel3","comfortLevel4","environmentProtection","humanProtection","userLevel1","userLevel2"],"type":"DiscreteState","qualifiedName":"io:PriorityLockLevelState"},{"eventBased":false,"values":["LSC","SAAC","SFC","UPS","externalGateway","localUser","myself","rain","security","timer","user","wind"],"type":"DiscreteState","qualifiedName":"io:PriorityLockOriginatorState"}],"dataProperties":[{"value":"500","qualifiedName":"core:identifyInterval"}],"widgetName":"PositionableTiltedWindow","uiClass":"Window","qualifiedName":"io:WindowOpenerVeluxIOComponent","type":"ACTUATOR"},"states":[{"name":"core:NameState","type":3,"value":"Corridor Window"},{"name":"core:StatusState","type":3,"value":"unavailable"},{"name":"core:RSSILevelState","type":2,"value":100.0},{"name":"core:ClosureState","type":1,"value":100},{"name":"core:OpenClosedState","type":3,"value":"closed"}],"attributes":[],"available":false,"enabled":true,"placeOID":"05badcc3-b8f3-4562-9c03-ac5f39e976f0","widget":"PositionableTiltedWindow","type":1,"oid":"4e589092-0aec-4bff-9881-3711117fb432","uiClass":"Window"},{"creationTime":1481978106000,"lastUpdateTime":1481978106000,"label":"Bathroom Window","deviceURL":"io://1202-4393-9834/8711888","shortcut":false,"controllableName":"io:WindowOpenerVeluxIOComponent","definition":{"commands":[{"commandName":"close","nparams":0},{"commandName":"delayedStopIdentify","nparams":1},{"commandName":"getName","nparams":0},{"commandName":"identify","nparams":0},{"commandName":"open","nparams":0},{"commandName":"setClosure","nparams":1},{"commandName":"setName","nparams":1},{"commandName":"startIdentify","nparams":0},{"commandName":"stopIdentify","nparams":0},{"commandName":"wink","nparams":1}],"events":[],"states":[{"eventBased":false,"type":"ContinuousState","qualifiedName":"core:ClosureState"},{"eventBased":false,"type":"DataState","qualifiedName":"core:NameState"},{"eventBased":false,"values":["closed","open"],"type":"DiscreteState","qualifiedName":"core:OpenClosedState"},{"eventBased":false,"type":"ContinuousState","qualifiedName":"core:PriorityLockTimerState"},{"eventBased":false,"type":"ContinuousState","qualifiedName":"core:RSSILevelState"},{"eventBased":false,"values":["available","unavailable"],"type":"DiscreteState","qualifiedName":"core:StatusState"},{"eventBased":false,"values":["comfortLevel1","comfortLevel2","comfortLevel3","comfortLevel4","environmentProtection","humanProtection","userLevel1","userLevel2"],"type":"DiscreteState","qualifiedName":"io:PriorityLockLevelState"},{"eventBased":false,"values":["LSC","SAAC","SFC","UPS","externalGateway","localUser","myself","rain","security","timer","user","wind"],"type":"DiscreteState","qualifiedName":"io:PriorityLockOriginatorState"}],"dataProperties":[{"value":"500","qualifiedName":"core:identifyInterval"}],"widgetName":"PositionableTiltedWindow","uiClass":"Window","qualifiedName":"io:WindowOpenerVeluxIOComponent","type":"ACTUATOR"},"states":[{"name":"core:NameState","type":3,"value":"Bathroom Window"},{"name":"core:StatusState","type":3,"value":"available"},{"name":"core:RSSILevelState","type":2,"value":100.0},{"name":"core:ClosureState","type":1,"value":100},{"name":"core:OpenClosedState","type":3,"value":"closed"}],"attributes":[],"available":true,"enabled":true,"placeOID":"73104664-4ceb-4831-bc5d-97af8cb45144","widget":"PositionableTiltedWindow","type":1,"oid":"e6d0639b-a587-4bd6-aa38-56d6d16df3c5","uiClass":"Window"}],"zones":[],"resellerDelegationType":"NEVER","rootPlace":{"creationTime":1481970091000,"lastUpdateTime":1481978338000,"label":"House","type":200,"oid":"6bf877ec-bce0-4243-86d6-ec8526c97efe","subPlaces":[{"creationTime":1481979193000,"lastUpdateTime":1481979193000,"label":"terrace","type":106,"metadata":"{\"tahoma\":{\"position\":-0.25,\"decor\":[{\"id\":\"tree2\",\"type\":1002,\"offset\":0}]}}","oid":"ee20af13-2e41-4938-a458-a6b6b9417035","subPlaces":[]},{"creationTime":1481979193000,"lastUpdateTime":1481979193000,"label":"2nd floor","type":103,"oid":"849b8684-ba45-47f3-8ccb-57292ef6beef","subPlaces":[{"creationTime":1481979193000,"lastUpdateTime":1481979193000,"label":"Bathroom Upstairs","type":8,"metadata":"{\"tahoma\":{\"order\":2}}","oid":"73104664-4ceb-4831-bc5d-97af8cb45144","subPlaces":[]},{"creationTime":1481979193000,"lastUpdateTime":1481979193000,"label":"Study","type":16,"metadata":"{\"tahoma\":{\"order\":1}}","oid":"35bc314c-4608-49ab-8a0f-6b5ced4b03e3","subPlaces":[]},{"creationTime":1481979193000,"lastUpdateTime":1481979193000,"label":"Bedroom Alice","type":6,"metadata":"{\"tahoma\":{\"order\":3}}","oid":"a5d69ff0-bf92-4d38-bb32-c1dcba36149f","subPlaces":[]},{"creationTime":1481979193000,"lastUpdateTime":1481979193000,"label":"Corridor Top","type":23,"metadata":"{\"tahoma\":{\"order\":0}}","oid":"05badcc3-b8f3-4562-9c03-ac5f39e976f0","subPlaces":[]}]}]},"features":[{"name":"tahoma-basic-plus","source":"GATEWAY_TYPE"}]},"events":[]} + +package: com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup +Class name: GetSetup + +Source type: JSON + +Annotation style: Gson + +Boxes checked: + Use long integers + Use double numbers + Include getters and setters + Allow additional properties \ No newline at end of file From 99e2243e2da5640e440b1e955beb7890463491a4 Mon Sep 17 00:00:00 2001 From: Monica Goward Date: Fri, 3 Feb 2017 12:07:44 +0000 Subject: [PATCH 03/14] HTML headers updates only --- .../resources/public/views/configuration.html | 289 +++++++++--------- 1 file changed, 145 insertions(+), 144 deletions(-) diff --git a/src/main/resources/public/views/configuration.html b/src/main/resources/public/views/configuration.html index 07a9962..991b8df 100644 --- a/src/main/resources/public/views/configuration.html +++ b/src/main/resources/public/views/configuration.html @@ -1,144 +1,145 @@ - - - -
    -
    -

    Current devices ({{bridge.devices.length}})

    -
    -
    - -

    - -

    - - - - - - - - - - - - - - - - - - - - - - - - - -
    RowIDNameTypeTargetInactiveNo StateActions
    {{$index+1}}{{device.id}}{{device.name}}{{device.deviceType}}{{device.targetDevice}}{{device.inactive}}{{device.noState}} -

    - - - - - -

    -
    -
    -
    -
    -
    -
    -

    - Bridge Device DB Backup -

    -
    -
    -

    Control your backups from this area. Use the default name by hitting backup or specify your own.

    -
    -
    - - -
    - -
    - -
    -
    - - - - - - - - - - - -
    FilenameActions
    {{backup}} - - -
    -
    -
    - - - + + + +
    +
    +

    Current devices ({{bridge.devices.length}})

    +
    +
    + +

    + +

    + + + + + + + + + + + + + + + + + + + + + + + + + +
    RowIDNameTypeTargetInactiveNo StateActions
    {{$index+1}}{{device.id}}{{device.name}}{{device.deviceType}}{{device.targetDevice}}{{device.inactive}}{{device.noState}} +

    + + + + + +

    +
    +
    +
    +
    +
    +
    +

    + Bridge Device DB Backup +

    +
    +
    +

    Control your backups from this area. Use the default name by hitting backup or specify your own.

    +
    +
    + + +
    + +
    + +
    +
    + + + + + + + + + + + +
    FilenameActions
    {{backup}} + + +
    +
    +
    + + + From 65b0d6e4700a260c8492fa0225a7b221376e5c33 Mon Sep 17 00:00:00 2001 From: Monica Goward Date: Fri, 3 Feb 2017 12:08:46 +0000 Subject: [PATCH 04/14] HTML headers updates only --- src/main/resources/public/views/editdevice.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/public/views/editdevice.html b/src/main/resources/public/views/editdevice.html index 625a147..25d0bae 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
  • +
  • Somfy Devices
  • @@ -41,7 +42,7 @@ payload"},{"item":"another payload"}] to execute multiple entries. Adding the value replacements (${intensity..byte},${intensity.percent},${intensity.math(X*1)}) will - also work. Also, you can go back to any helper tab and click a build + 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 Device" Button.

    From 1c897e3b36b96575f6d38614b6edbd208134635f Mon Sep 17 00:00:00 2001 From: Monica Goward Date: Sat, 4 Feb 2017 18:28:25 +0000 Subject: [PATCH 05/14] Add Somfy devices --- .../HABridge/BridgeSettingsDescriptor.java | 29 +- .../bwssystems/HABridge/DeviceMapTypes.java | 164 +++++----- .../devicemanagmeent/DeviceResource.java | 8 +- src/main/resources/public/scripts/app.js | 302 +++++++++++++++--- 4 files changed, 365 insertions(+), 138 deletions(-) diff --git a/src/main/java/com/bwssystems/HABridge/BridgeSettingsDescriptor.java b/src/main/java/com/bwssystems/HABridge/BridgeSettingsDescriptor.java index 442513b..2ceeb5b 100644 --- a/src/main/java/com/bwssystems/HABridge/BridgeSettingsDescriptor.java +++ b/src/main/java/com/bwssystems/HABridge/BridgeSettingsDescriptor.java @@ -40,13 +40,16 @@ public class BridgeSettingsDescriptor { private String hubversion; private IpList domoticzaddress; private boolean domoticzconfigured; - + private IpList somfyaddress; + private boolean somfyconfigured; + public BridgeSettingsDescriptor() { super(); this.upnpstrict = true; this.traceupnp = false; this.nestconfigured = false; this.veraconfigured = false; + this.somfyconfigured = false; this.harmonyconfigured = false; this.hueconfigured = false; this.halconfigured = false; @@ -92,9 +95,15 @@ public class BridgeSettingsDescriptor { public IpList getVeraAddress() { return veraaddress; } + public IpList getSomfyAddress() { + return somfyaddress; + } public void setVeraAddress(IpList veraAddress) { this.veraaddress = veraAddress; } + public void setSomfyAddress(IpList somfyAddress) { + this.somfyaddress = somfyAddress; + } public IpList getHarmonyAddress() { return harmonyaddress; } @@ -128,9 +137,15 @@ public class BridgeSettingsDescriptor { public boolean isVeraconfigured() { return veraconfigured; } + public boolean isSomfyconfigured() { + return somfyconfigured; + } public void setVeraconfigured(boolean veraconfigured) { this.veraconfigured = veraconfigured; } + public void setSomfyconfigured(boolean somfyconfigured) { + this.somfyconfigured = somfyconfigured; + } public boolean isHarmonyconfigured() { return harmonyconfigured; } @@ -314,7 +329,7 @@ public class BridgeSettingsDescriptor { } public Boolean isValidHass() { if(this.getHassaddress() == null || this.getHassaddress().getDevices().size() <= 0) - return false; + return false; List devicesList = this.getHassaddress().getDevices(); if(devicesList.get(0).getIp().contains(Configuration.DEFAULT_ADDRESS)) return false; @@ -322,10 +337,18 @@ public class BridgeSettingsDescriptor { } public Boolean isValidDomoticz() { if(this.getDomoticzaddress() == null || this.getDomoticzaddress().getDevices().size() <= 0) - return false; + return false; List devicesList = this.getDomoticzaddress().getDevices(); if(devicesList.get(0).getIp().contains(Configuration.DEFAULT_ADDRESS)) return false; return true; } + public Boolean isValidSomfy() { + if(this.getSomfyAddress() == null || this.getSomfyAddress().getDevices().size() <= 0) + return false; + List devicesList = this.getSomfyAddress().getDevices(); + if(devicesList.get(0).getIp().contains(Configuration.DEFAULT_ADDRESS)) + return false; + return true; + } } diff --git a/src/main/java/com/bwssystems/HABridge/DeviceMapTypes.java b/src/main/java/com/bwssystems/HABridge/DeviceMapTypes.java index 870fa2c..fda444e 100644 --- a/src/main/java/com/bwssystems/HABridge/DeviceMapTypes.java +++ b/src/main/java/com/bwssystems/HABridge/DeviceMapTypes.java @@ -1,82 +1,84 @@ -package com.bwssystems.HABridge; - -import java.util.ArrayList; - -public class DeviceMapTypes { - - public final static String[] CUSTOM_DEVICE = { "custom", "Custom"}; - public final static String[] VERA_DEVICE = { "veraDevice", "Vera Device"}; - public final static String[] VERA_SCENE = { "veraScene", "Vera Scene"}; - public final static String[] HARMONY_ACTIVITY = { "harmonyActivity", "Harmony Activity"}; - public final static String[] HARMONY_BUTTON = { "harmonyButton", "Harmony Button"}; - public final static String[] NEST_HOMEAWAY = { "nestHomeAway", "Nest Home Status"}; - public final static String[] NEST_THERMO_SET = { "nestThermoSet", "Nest Thermostat"}; - public final static String[] HUE_DEVICE = { "hueDevice", "Hue Device"}; - public final static String[] HAL_DEVICE = { "halDevice", "HAL Device"}; - public final static String[] HAL_BUTTON = { "halButton", "HAL Button"}; - public final static String[] HAL_HOME = { "halHome", "HAL Home Status"}; - public final static String[] HAL_THERMO_SET = { "halThermoSet", "HAL Thermostat"}; - public final static String[] MQTT_MESSAGE = { "mqttMessage", "MQTT Message"}; - public final static String[] EXEC_DEVICE_COMPAT = { "exec", "Execute Script/Program"}; - public final static String[] CMD_DEVICE = { "cmdDevice", "Execute Command/Script/Program"}; - public final static String[] HASS_DEVICE = { "hassDevice", "HomeAssistant Device"}; - public final static String[] TCP_DEVICE = { "tcpDevice", "TCP Device"}; - public final static String[] TCP_DEVICE_COMPAT = { "TCP", "TCP Device"}; - public final static String[] UDP_DEVICE = { "udpDevice", "UDP Device"}; - public final static String[] UDP_DEVICE_COMPAT = { "UDP", "UDP Device"}; - public final static String[] HTTP_DEVICE = { "httpDevice", "HTTP Device"}; - public final static String[] DOMOTICZ_DEVICE = { "domoticzDevice", "Domoticz Device"}; - - public final static int typeIndex = 0; - public final static int displayIndex = 1; - - ArrayList deviceMapTypes; - - public DeviceMapTypes() { - super(); - deviceMapTypes = new ArrayList(); - deviceMapTypes.add(CMD_DEVICE); - deviceMapTypes.add(DOMOTICZ_DEVICE); - deviceMapTypes.add(HAL_DEVICE); - deviceMapTypes.add(HAL_HOME); - deviceMapTypes.add(HAL_THERMO_SET); - deviceMapTypes.add(HAL_BUTTON); - deviceMapTypes.add(HARMONY_ACTIVITY); - deviceMapTypes.add(HARMONY_BUTTON); - deviceMapTypes.add(HASS_DEVICE); - deviceMapTypes.add(HTTP_DEVICE); - deviceMapTypes.add(HUE_DEVICE); - deviceMapTypes.add(MQTT_MESSAGE); - deviceMapTypes.add(NEST_HOMEAWAY); - deviceMapTypes.add(NEST_THERMO_SET); - deviceMapTypes.add(TCP_DEVICE); - deviceMapTypes.add(UDP_DEVICE); - deviceMapTypes.add(VERA_DEVICE); - deviceMapTypes.add(VERA_SCENE); - } - public static int getTypeIndex() { - return typeIndex; - } - public static int getDisplayIndex() { - return displayIndex; - } - public ArrayList getDeviceMapTypes() { - return deviceMapTypes; - } - - public Boolean validateType(String type) { - if(type == null || type.trim().isEmpty()) - return false; - for(String[] mapType : deviceMapTypes) { - if(type.trim().contentEquals(mapType[typeIndex])) - return true; - } - if(type.trim().contentEquals(EXEC_DEVICE_COMPAT[typeIndex])) - return true; - if(type.trim().contentEquals(TCP_DEVICE_COMPAT[typeIndex])) - return true; - if(type.trim().contentEquals(UDP_DEVICE_COMPAT[typeIndex])) - return true; - return false; - } +package com.bwssystems.HABridge; + +import java.util.ArrayList; + +public class DeviceMapTypes { + + public final static String[] CUSTOM_DEVICE = { "custom", "Custom"}; + public final static String[] VERA_DEVICE = { "veraDevice", "Vera Device"}; + public final static String[] VERA_SCENE = { "veraScene", "Vera Scene"}; + public final static String[] HARMONY_ACTIVITY = { "harmonyActivity", "Harmony Activity"}; + public final static String[] HARMONY_BUTTON = { "harmonyButton", "Harmony Button"}; + public final static String[] NEST_HOMEAWAY = { "nestHomeAway", "Nest Home Status"}; + public final static String[] NEST_THERMO_SET = { "nestThermoSet", "Nest Thermostat"}; + public final static String[] HUE_DEVICE = { "hueDevice", "Hue Device"}; + public final static String[] HAL_DEVICE = { "halDevice", "HAL Device"}; + public final static String[] HAL_BUTTON = { "halButton", "HAL Button"}; + public final static String[] HAL_HOME = { "halHome", "HAL Home Status"}; + public final static String[] HAL_THERMO_SET = { "halThermoSet", "HAL Thermostat"}; + public final static String[] MQTT_MESSAGE = { "mqttMessage", "MQTT Message"}; + public final static String[] EXEC_DEVICE_COMPAT = { "exec", "Execute Script/Program"}; + public final static String[] CMD_DEVICE = { "cmdDevice", "Execute Command/Script/Program"}; + public final static String[] HASS_DEVICE = { "hassDevice", "HomeAssistant Device"}; + public final static String[] TCP_DEVICE = { "tcpDevice", "TCP Device"}; + public final static String[] TCP_DEVICE_COMPAT = { "TCP", "TCP Device"}; + public final static String[] UDP_DEVICE = { "udpDevice", "UDP Device"}; + public final static String[] UDP_DEVICE_COMPAT = { "UDP", "UDP Device"}; + public final static String[] HTTP_DEVICE = { "httpDevice", "HTTP Device"}; + public final static String[] DOMOTICZ_DEVICE = { "domoticzDevice", "Domoticz Device"}; + public final static String[] SOMFY_DEVICE = { "somfyDevice", "Somfy Device"}; + + public final static int typeIndex = 0; + public final static int displayIndex = 1; + + ArrayList deviceMapTypes; + + public DeviceMapTypes() { + super(); + deviceMapTypes = new ArrayList(); + deviceMapTypes.add(CMD_DEVICE); + deviceMapTypes.add(DOMOTICZ_DEVICE); + deviceMapTypes.add(HAL_DEVICE); + deviceMapTypes.add(HAL_HOME); + deviceMapTypes.add(HAL_THERMO_SET); + deviceMapTypes.add(HAL_BUTTON); + deviceMapTypes.add(HARMONY_ACTIVITY); + deviceMapTypes.add(HARMONY_BUTTON); + deviceMapTypes.add(HASS_DEVICE); + deviceMapTypes.add(HTTP_DEVICE); + deviceMapTypes.add(HUE_DEVICE); + deviceMapTypes.add(MQTT_MESSAGE); + deviceMapTypes.add(NEST_HOMEAWAY); + deviceMapTypes.add(NEST_THERMO_SET); + deviceMapTypes.add(TCP_DEVICE); + deviceMapTypes.add(UDP_DEVICE); + deviceMapTypes.add(VERA_DEVICE); + deviceMapTypes.add(VERA_SCENE); + deviceMapTypes.add(SOMFY_DEVICE); + } + public static int getTypeIndex() { + return typeIndex; + } + public static int getDisplayIndex() { + return displayIndex; + } + public ArrayList getDeviceMapTypes() { + return deviceMapTypes; + } + + public Boolean validateType(String type) { + if(type == null || type.trim().isEmpty()) + return false; + for(String[] mapType : deviceMapTypes) { + if(type.trim().contentEquals(mapType[typeIndex])) + return true; + } + if(type.trim().contentEquals(EXEC_DEVICE_COMPAT[typeIndex])) + return true; + if(type.trim().contentEquals(TCP_DEVICE_COMPAT[typeIndex])) + return true; + if(type.trim().contentEquals(UDP_DEVICE_COMPAT[typeIndex])) + return true; + return false; + } } \ No newline at end of file diff --git a/src/main/java/com/bwssystems/HABridge/devicemanagmeent/DeviceResource.java b/src/main/java/com/bwssystems/HABridge/devicemanagmeent/DeviceResource.java index e4b861b..43f7835 100644 --- a/src/main/java/com/bwssystems/HABridge/devicemanagmeent/DeviceResource.java +++ b/src/main/java/com/bwssystems/HABridge/devicemanagmeent/DeviceResource.java @@ -219,7 +219,13 @@ public class DeviceResource { return homeManager.findResource(DeviceMapTypes.DOMOTICZ_DEVICE[DeviceMapTypes.typeIndex]).getItems(DeviceMapTypes.DOMOTICZ_DEVICE[DeviceMapTypes.typeIndex]); }, new JsonTransformer()); - get (API_CONTEXT + "/map/types", "application/json", (request, response) -> { + get (API_CONTEXT + "/somfy/devices", "application/json", (request, response) -> { + log.debug("Get somfy devices"); + response.status(HttpStatus.SC_OK); + return homeManager.findResource(DeviceMapTypes.SOMFY_DEVICE[DeviceMapTypes.typeIndex]).getItems(DeviceMapTypes.SOMFY_DEVICE[DeviceMapTypes.typeIndex]); + }, new JsonTransformer()); + + get (API_CONTEXT + "/map/types", "application/json", (request, response) -> { log.debug("Get map types"); return new DeviceMapTypes().getDeviceMapTypes(); }, new JsonTransformer()); diff --git a/src/main/resources/public/scripts/app.js b/src/main/resources/public/scripts/app.js index bc77ffd..757ad9a 100644 --- a/src/main/resources/public/scripts/app.js +++ b/src/main/resources/public/scripts/app.js @@ -20,7 +20,7 @@ app.config (function ($locationProvider, $routeProvider) { controller: 'VeraController' }).when ('/verascenes', { templateUrl: 'views/verascene.html', - controller: 'VeraController' + controller: 'VeraController' }).when ('/harmonydevices', { templateUrl: 'views/harmonydevice.html', controller: 'HarmonyController' @@ -41,11 +41,14 @@ app.config (function ($locationProvider, $routeProvider) { controller: 'MQTTController' }).when ('/hassdevices', { templateUrl: 'views/hassdevice.html', - controller: 'HassController' + controller: 'HassController' }).when ('/domoticzdevices', { templateUrl: 'views/domoticzdevice.html', - controller: 'DomoticzController' - }).otherwise ({ + controller: 'DomoticzController' + }).when('/somfydevices', { + templateUrl: 'views/somfydevice.html', + controller: 'SomfyController' + }).otherwise ({ templateUrl: 'views/configuration.html', controller: 'ViewingController' }) @@ -71,7 +74,7 @@ String.prototype.replaceAll = function (search, replace) app.service ('bridgeService', function ($http, $window, ngToast) { var self = this; - this.state = {base: window.location.origin + "/api/devices", bridgelocation: window.location.origin, systemsbase: window.location.origin + "/system", huebase: window.location.origin + "/api", configs: [], backups: [], devices: [], device: {}, mapandid: [], type: "", settings: [], myToastMsg: [], logMsgs: [], loggerInfo: [], mapTypes: [], olddevicename: "", logShowAll: false, isInControl: false, showVera: false, showHarmony: false, showNest: false, showHue: false, showHal: false, showMqtt: false, showHass: false, showDomoticz: false, habridgeversion: ""}; + this.state = {base: window.location.origin + "/api/devices", bridgelocation: window.location.origin, systemsbase: window.location.origin + "/system", huebase: window.location.origin + "/api", configs: [], backups: [], devices: [], device: {}, mapandid: [], type: "", settings: [], myToastMsg: [], logMsgs: [], loggerInfo: [], mapTypes: [], olddevicename: "", logShowAll: false, isInControl: false, showVera: false, showHarmony: false, showNest: false, showHue: false, showHal: false, showMqtt: false, showHass: false, showDomoticz: false, showSomfy: false, habridgeversion: ""}; this.displayWarn = function(errorTitle, error) { var toastContent = errorTitle; @@ -164,20 +167,20 @@ app.service ('bridgeService', function ($http, $window, ngToast) { this.deviceContainsType = function (device, aType) { if(device.mapType !== undefined && device.mapType !== null && device.mapType.indexOf(aType) >= 0) return true; - + if(device.deviceType !== undefined && device.deviceType !== null && device.deviceType.indexOf(aType) >= 0) return true; - + if(device.onUrl !== undefined && device.onUrl !== null && device.onUrl.indexOf(aType) >= 0) return true; - + if(device.dimUrl !== undefined && device.dimUrl !== null && device.dimUrl.indexOf(aType) >= 0) return true; - + if(device.offUrl !== undefined && device.offUrl !== null && device.offUrl.indexOf(aType) >= 0) return true; - - + + return false; } this.compareHarmonyNumber = function(r1, r2) { @@ -257,6 +260,11 @@ app.service ('bridgeService', function ($http, $window, ngToast) { return; } + this.updateShowSomfy = function () { + this.state.showSomfy = self.state.settings.somfyconfigured; + return; + } + this.loadBridgeSettings = function () { return $http.get(this.state.systemsbase + "/settings").then( function (response) { @@ -269,6 +277,7 @@ app.service ('bridgeService', function ($http, $window, ngToast) { self.updateShowMqtt(); self.updateShowHass(); self.updateShowDomoticz(); + self.updateShowSomfy(); }, function (error) { self.displayWarn("Load Bridge Settings Error: ", error); @@ -450,6 +459,20 @@ app.service ('bridgeService', function ($http, $window, ngToast) { ); }; + this.viewSomfyDevices = function () { + if(!this.state.showSomfy) + return; + return $http.get(this.state.base + "/somfy/devices").then( + function (response) { + self.state.somfydevices = response.data; + }, + function (error) { + self.displayWarn("Get Somfy Devices Error: ", error); + } + ); + }; + + this.formatCallItem = function (currentItem) { if(!currentItem.startsWith("{\"item") && !currentItem.startsWith("[{\"item")) { if (currentItem.startsWith("[") || currentItem.startsWith("{")) @@ -461,7 +484,7 @@ app.service ('bridgeService', function ($http, $window, ngToast) { return currentItem; }; - + this.getCallObjects = function (deviceString) { if (deviceString === undefined || deviceString === "") return null; @@ -481,7 +504,7 @@ app.service ('bridgeService', function ($http, $window, ngToast) { } return newDevices } - + this.updateCallObjectsType = function (theDevices) { var i, s, type, len = theDevices.length for (i=0; i= 0; i--) { + if($scope.bridge.settings.somfyaddress.devices[i].name === somfyname && $scope.bridge.settings.somfyaddress.devices[i].ip === somfyip) { + $scope.bridge.settings.somfyaddress.devices.splice(i, 1); + } + } + }; + $scope.bridgeReinit = function () { bridgeService.reinit(); }; @@ -1331,7 +1373,7 @@ app.controller('VeraController', function ($scope, $location, $http, bridgeServi className: 'ngdialog-theme-default' }); }; - + $scope.editDevice = function (device) { bridgeService.editDevice(device); $location.path('/editdevice'); @@ -1356,7 +1398,7 @@ app.controller('HarmonyController', function ($scope, $location, $http, bridgeSe $scope.buildActivityUrls = function (harmonyactivity) { onpayload = "{\"name\":\"" + harmonyactivity.activity.id + "\",\"hub\":\"" + harmonyactivity.hub + "\"}"; - offpayload = "{\"name\":\"-1\",\"hub\":\"" + harmonyactivity.hub + "\"}"; + offpayload = "{\"name\":\"-1\",\"hub\":\"" + harmonyactivity.hub + "\"}"; bridgeService.buildUrls(onpayload, null, offpayload, true, harmonyactivity.activity.id, harmonyactivity.activity.label, harmonyactivity.hub, "activity", "harmonyActivity", null, null); $scope.device = bridgeService.state.device; @@ -1392,7 +1434,7 @@ app.controller('HarmonyController', function ($scope, $location, $http, bridgeSe className: 'ngdialog-theme-default' }); }; - + $scope.editDevice = function (device) { bridgeService.editDevice(device); $location.path('/editdevice'); @@ -1493,7 +1535,7 @@ app.controller('NestController', function ($scope, $location, $http, bridgeServi className: 'ngdialog-theme-default' }); }; - + $scope.editDevice = function (device) { bridgeService.editDevice(device); $location.path('/editdevice'); @@ -1610,7 +1652,7 @@ app.controller('HueController', function ($scope, $location, $http, bridgeServic className: 'ngdialog-theme-default' }); }; - + $scope.editDevice = function (device) { bridgeService.editDevice(device); $location.path('/editdevice'); @@ -1680,7 +1722,7 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic + nameCmd + haldevice.haldevicename.replaceAll(" ", "%20") + postCmd; - offpayload = "http://" + haldevice.haladdress + offpayload = "http://" + haldevice.haladdress + preOffCmd + nameCmd + haldevice.haldevicename.replaceAll(" ", "%20") @@ -1713,17 +1755,17 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic }; $scope.buildHALHeatUrls = function (haldevice) { - onpayload = "http://" + haldevice.haladdress + onpayload = "http://" + haldevice.haladdress + "/HVACService!HVACCmd=Set!HVACName=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!HVACMode=Heat?Token=" + $scope.bridge.settings.haltoken; - dimpayload = "http://" + haldevice.haladdress + dimpayload = "http://" + haldevice.haladdress + "/HVACService!HVACCmd=Set!HVACName=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!HVACMode=Heat!HeatSpValue=${intensity.percent}?Token=" + $scope.bridge.settings.haltoken; - offpayload = "http://" + haldevice.haladdress + offpayload = "http://" + haldevice.haladdress + "/HVACService!HVACCmd=Set!HVACName=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!HVACMode=Off?Token=" @@ -1735,17 +1777,17 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic }; $scope.buildHALCoolUrls = function (haldevice) { - onpayload = "http://" + haldevice.haladdress + onpayload = "http://" + haldevice.haladdress + "/HVACService!HVACCmd=Set!HVACName=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!HVACMode=Cool?Token=" + $scope.bridge.settings.haltoken; - dimpayload = "http://" + haldevice.haladdress + dimpayload = "http://" + haldevice.haladdress + "/HVACService!HVACCmd=Set!HVACName=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!HVACMode=Cool!CoolSpValue=${intensity.percent}?Token=" + $scope.bridge.settings.haltoken; - offpayload = "http://" + haldevice.haladdress + offpayload = "http://" + haldevice.haladdress + "/HVACService!HVACCmd=Set!HVACName=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!HVACMode=Off?Token=" @@ -1757,12 +1799,12 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic }; $scope.buildHALAutoUrls = function (haldevice) { - onpayload = "http://" + haldevice.haladdress + onpayload = "http://" + haldevice.haladdress + "/HVACService!HVACCmd=Set!HVACName=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!HVACMode=Auto?Token=" + $scope.bridge.settings.haltoken; - offpayload = "http://" + haldevice.haladdress + offpayload = "http://" + haldevice.haladdress + "/HVACService!HVACCmd=Set!HVACName=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!HVACMode=Off?Token=" @@ -1773,16 +1815,16 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic }; $scope.buildHALOffUrls = function (haldevice) { - onpayload = "http://" + haldevice.haladdress + onpayload = "http://" + haldevice.haladdress + "/HVACService!HVACCmd=Set!HVACName=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!HVACMode=Auto?Token=" + $scope.bridge.settings.haltoken; - offpayload = "http://" + haldevice.haladdress + offpayload = "http://" + haldevice.haladdress + "/HVACService!HVACCmd=Set!HVACName=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!HVACMode=Off?Token=" - $scope.device.offUrl = "http://" + haldevice.haladdress + $scope.device.offUrl = "http://" + haldevice.haladdress bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-TurnOff", haldevice.haldevicename + " Thermostat", haldevice.halname, "thermo", "halThermoSet", null, null); $scope.device = bridgeService.state.device; bridgeService.editNewDevice($scope.device); @@ -1790,12 +1832,12 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic }; $scope.buildHALFanUrls = function (haldevice) { - onpayload = "http://" + haldevice.haladdress - + "/HVACService!HVACCmd=Set!HVACName=" - + haldevice.haldevicename.replaceAll(" ", "%20") + onpayload = "http://" + haldevice.haladdress + + "/HVACService!HVACCmd=Set!HVACName=" + + haldevice.haldevicename.replaceAll(" ", "%20") + "!FanMode=On?Token=" + $scope.bridge.settings.haltoken; - offpayload = "http://" + haldevice.haladdress + offpayload = "http://" + haldevice.haladdress + "/HVACService!HVACCmd=Set!HVACName=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!FanMode=Auto?Token=" @@ -1897,7 +1939,7 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic className: 'ngdialog-theme-default' }); }; - + $scope.editDevice = function (device) { bridgeService.editDevice(device); $location.path('/editdevice'); @@ -1942,7 +1984,7 @@ app.controller('MQTTController', function ($scope, $location, $http, bridgeServi className: 'ngdialog-theme-default' }); }; - + $scope.editDevice = function (device) { bridgeService.editDevice(device); $location.path('/editdevice'); @@ -2137,7 +2179,7 @@ app.controller('HassController', function ($scope, $location, $http, bridgeServi className: 'ngdialog-theme-default' }); }; - + $scope.editDevice = function (device) { bridgeService.editDevice(device); $location.path('/editdevice'); @@ -2192,7 +2234,7 @@ app.controller('DomoticzController', function ($scope, $location, $http, bridgeS + preCmd + domoticzdevice.idx + postOnCmd; - offpayload = "http://" + domoticzdevice.domoticzaddress + offpayload = "http://" + domoticzdevice.domoticzaddress + preCmd + domoticzdevice.idx + postOffCmd; @@ -2288,7 +2330,131 @@ app.controller('DomoticzController', function ($scope, $location, $http, bridgeS className: 'ngdialog-theme-default' }); }; - + + $scope.editDevice = function (device) { + bridgeService.editDevice(device); + $location.path('/editdevice'); + }; +}); + +app.controller('SomfyController', function ($scope, $location, $http, bridgeService, ngDialog) { + $scope.bridge = bridgeService.state; + $scope.device = bridgeService.state.device; + $scope.device_dim_control = ""; + $scope.bulk = { devices: [] }; + $scope.selectAll = false; + $scope.somfy = {base: "http://", port: "3480", id: ""}; + bridgeService.viewSomfyDevices(); + $scope.imgButtonsUrl = "glyphicon glyphicon-plus"; + $scope.buttonsVisible = false; + $scope.comparatorUniqueId = bridgeService.compareUniqueId; + + $scope.clearDevice = function () { + bridgeService.clearDevice(); + $scope.device = bridgeService.state.device; + }; + + $scope.buildDeviceUrls = function (somfydevice, dim_control) { + //TODO - support partial window opening + dimpayload = ""; + onpayload = "{\"label\":\"Label that is ignored probably\",\"actions\":[{\"deviceURL\":\""+ somfydevice.deviceUrl+"\",\"commands\":[{\"name\":\"open\",\"parameters\":[]}]}]}"; + offpayload = "{\"label\":\"Label that is ignored probably\",\"actions\":[{\"deviceURL\":\""+ somfydevice.deviceUrl+"\",\"commands\":[{\"name\":\"close\",\"parameters\":[]}]}]}"; + + bridgeService.buildUrls(onpayload, dimpayload, offpayload, true, somfydevice.id, somfydevice.name, somfydevice.somfyname, "switch", "somfyDevice", null, null); + $scope.device = bridgeService.state.device; + bridgeService.editNewDevice($scope.device); + $location.path('/editdevice'); + + }; + + + $scope.bulkAddDevices = function(dim_control) { + var devicesList = []; + for(var i = 0; i < $scope.bulk.devices.length; i++) { + for(var x = 0; x < bridgeService.state.somfydevices.length; x++) { + if(bridgeService.state.somfydevices[x].id === $scope.bulk.devices[i]) { + $scope.buildDeviceUrls(bridgeService.state.somfydevices[x],dim_control); + devicesList[i] = { + name: $scope.device.name, + mapId: $scope.device.mapId, + mapType: $scope.device.mapType, + deviceType: $scope.device.deviceType, + targetDevice: $scope.device.targetDevice, + onUrl: $scope.device.onUrl, + dimUrl: $scope.device.dimUrl, + offUrl: $scope.device.offUrl, + headers: $scope.device.headers, + httpVerb: $scope.device.httpVerb, + contentType: $scope.device.contentType, + contentBody: $scope.device.contentBody, + contentBodyDim: $scope.device.contentBodyDim, + contentBodyOff: $scope.device.contentBodyOff + }; + } + } + } + bridgeService.bulkAddDevice(devicesList).then( + function () { + $scope.clearDevice(); + bridgeService.viewDevices(); + bridgeService.viewSomfyDevices(); + }, + function (error) { + bridgeService.displayWarn("Error adding Somfy devices in bulk.", error) + } + ); + $scope.bulk = { devices: [] }; + $scope.selectAll = false; + }; + + $scope.toggleSelection = function toggleSelection(deviceId) { + var idx = $scope.bulk.devices.indexOf(deviceId); + + // is currently selected + if (idx > -1) { + $scope.bulk.devices.splice(idx, 1); + if($scope.bulk.devices.length === 0 && $scope.selectAll) + $scope.selectAll = false; + } + + // is newly selected + else { + $scope.bulk.devices.push(deviceId); + $scope.selectAll = true; + } + }; + + $scope.toggleSelectAll = function toggleSelectAll() { + if($scope.selectAll) { + $scope.selectAll = false; + $scope.bulk = { devices: [] }; + } + else { + $scope.selectAll = true; + for(var x = 0; x < bridgeService.state.somfydevices.length; x++) { + if($scope.bulk.devices.indexOf(bridgeService.state.somfydevices[x]) < 0 && !bridgeService.findDeviceByMapId(bridgeService.state.somfydevices[x].id, bridgeService.state.somfydevices[x].somfyname, "somfyDevice")) + $scope.bulk.devices.push(bridgeService.state.somfydevices[x].id); + } + } + }; + + $scope.toggleButtons = function () { + $scope.buttonsVisible = !$scope.buttonsVisible; + if($scope.buttonsVisible) + $scope.imgButtonsUrl = "glyphicon glyphicon-minus"; + else + $scope.imgButtonsUrl = "glyphicon glyphicon-plus"; + }; + + $scope.deleteDevice = function (device) { + $scope.bridge.device = device; + ngDialog.open({ + template: 'deleteDialog', + controller: 'DeleteDialogCtrl', + className: 'ngdialog-theme-default' + }); + }; + $scope.editDevice = function (device) { bridgeService.editDevice(device); $location.path('/editdevice'); @@ -2310,11 +2476,11 @@ app.controller('EditController', function ($scope, $location, $http, bridgeServi if($scope.bridge.device.offUrl !== undefined) $scope.offDevices = bridgeService.getCallObjects($scope.bridge.device.offUrl); } - + $scope.newOnItem = {}; $scope.newDimItem = {}; $scope.newOffItem = {}; - $scope.mapTypeSelected = bridgeService.getMapType($scope.device.mapType); + $scope.mapTypeSelected = bridgeService.getMapType($scope.device.mapType); $scope.device_dim_control = ""; $scope.imgButtonsUrl = "glyphicon glyphicon-plus"; $scope.buttonsVisible = false; @@ -2380,7 +2546,7 @@ app.controller('EditController', function ($scope, $location, $http, bridgeServi if($scope.onDevices[i].item === anItem.item && $scope.onDevices[i].type === anItem.type) { $scope.onDevices.splice(i, 1); } - } + } }; $scope.addItemDim = function (anItem) { @@ -2397,7 +2563,7 @@ app.controller('EditController', function ($scope, $location, $http, bridgeServi if($scope.dimDevices[i].item === anItem.item && $scope.dimDevices[i].type === anItem.type) { $scope.dimDevices.splice(i, 1); } - } + } }; $scope.addItemOff = function (anItem) { @@ -2414,7 +2580,7 @@ app.controller('EditController', function ($scope, $location, $http, bridgeServi if($scope.offDevices[i].item === anItem.item && $scope.offDevices[i].type === anItem.type) { $scope.offDevices.splice(i, 1); } - } + } }; $scope.toggleButtons = function () { $scope.buttonsVisible = !$scope.buttonsVisible; @@ -2566,6 +2732,36 @@ app.filter('configuredDomoticzItems', function (bridgeService) { } }); + +app.filter('availableSomfyDeviceId', function(bridgeService) { + return function(input) { + var out = []; + if(input == null) + return out; + for (var i = 0; i < input.length; i++) { + if(!bridgeService.findDeviceByMapId(input[i].id, input[i].somfyname, "somfyDevice")){ + out.push(input[i]); + } + } + return out; + } +}); + +app.filter('unavailableSomfyDeviceId', function(bridgeService) { + return function(input) { + var out = []; + if(input == null) + return out; + for (var i = 0; i < input.length; i++) { + if(bridgeService.findDeviceByMapId(input[i].id, input[i].somfyname, "somfyDevice")){ + out.push(input[i]); + } + } + return out; + } +}); + + app.controller('VersionController', function ($scope, bridgeService) { $scope.bridge = bridgeService.state; }); \ No newline at end of file From 1221df4c9683df33221c3a6f36790ab6bc18a272 Mon Sep 17 00:00:00 2001 From: Monica Goward Date: Sat, 4 Feb 2017 18:28:59 +0000 Subject: [PATCH 06/14] add Somfy settings --- .../bwssystems/HABridge/BridgeSettings.java | 581 +++++++++--------- src/main/resources/public/views/system.html | 41 ++ 2 files changed, 341 insertions(+), 281 deletions(-) diff --git a/src/main/java/com/bwssystems/HABridge/BridgeSettings.java b/src/main/java/com/bwssystems/HABridge/BridgeSettings.java index 1d67a37..d27f88c 100644 --- a/src/main/java/com/bwssystems/HABridge/BridgeSettings.java +++ b/src/main/java/com/bwssystems/HABridge/BridgeSettings.java @@ -1,281 +1,300 @@ -package com.bwssystems.HABridge; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.NetworkInterface; -import java.net.SocketException; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardOpenOption; -import java.nio.file.attribute.PosixFilePermission; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.Set; - -import org.apache.http.conn.util.InetAddressUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.bwssystems.HABridge.util.BackupHandler; -import com.bwssystems.HABridge.util.JsonTransformer; -import com.google.gson.Gson; - -public class BridgeSettings extends BackupHandler { - private static final Logger log = LoggerFactory.getLogger(BridgeSettings.class); - private BridgeSettingsDescriptor theBridgeSettings; - private BridgeControlDescriptor bridgeControl; - - public BridgeSettings() { - super(); - bridgeControl = new BridgeControlDescriptor(); - theBridgeSettings = new BridgeSettingsDescriptor(); - String ipV6Stack = System.getProperty("ipV6Stack"); - if(ipV6Stack == null || !ipV6Stack.equalsIgnoreCase("true")) { - System.setProperty("java.net.preferIPv4Stack" , "true"); - } - - } - public BridgeControlDescriptor getBridgeControl() { - return bridgeControl; - } - public BridgeSettingsDescriptor getBridgeSettingsDescriptor() { - return theBridgeSettings; - } - public void buildSettings() { - String addressString = null; - String theVeraAddress = null; - String theHarmonyAddress = null; - String configFileProperty = System.getProperty("config.file"); - if(configFileProperty == null) { - Path filePath = Paths.get(Configuration.CONFIG_FILE); - if(Files.exists(filePath) && Files.isReadable(filePath)) - configFileProperty = Configuration.CONFIG_FILE; - } - String serverPortOverride = System.getProperty("server.port"); - String serverIpOverride = System.getProperty("server.ip"); - if(configFileProperty != null) - { - log.info("reading from config file: " + configFileProperty); - theBridgeSettings.setConfigfile(configFileProperty); - _loadConfig(); - } - else - { - log.info("reading from system properties"); - theBridgeSettings.setNumberoflogmessages(Configuration.NUMBER_OF_LOG_MESSAGES); - theBridgeSettings.setFarenheit(true); - theBridgeSettings.setConfigfile(Configuration.CONFIG_FILE); - theBridgeSettings.setServerPort(System.getProperty("server.port", Configuration.DEFAULT_WEB_PORT)); - theBridgeSettings.setUpnpConfigAddress(System.getProperty("upnp.config.address")); - theBridgeSettings.setUpnpDeviceDb(System.getProperty("upnp.device.db")); - theBridgeSettings.setUpnpResponsePort(System.getProperty("upnp.response.port", Configuration.UPNP_RESPONSE_PORT)); - - theVeraAddress = System.getProperty("vera.address"); - IpList theVeraList = null; - if(theVeraAddress != null) { - try { - theVeraList = new Gson().fromJson(theVeraAddress, IpList.class); - } catch (Exception e) { - try { - theVeraList = new Gson().fromJson("{devices:[{name:default,ip:" + theVeraAddress + "}]}", IpList.class); - } catch (Exception et) { - log.error("Cannot parse vera.address, not set with message: " + e.getMessage(), e); - theVeraList = null; - } - } - } - theBridgeSettings.setVeraAddress(theVeraList); - - theHarmonyAddress = System.getProperty("harmony.address"); - IpList theHarmonyList = null; - if(theHarmonyAddress != null) { - try { - theHarmonyList = new Gson().fromJson(theHarmonyAddress, IpList.class); - } catch (Exception e) { - try { - theHarmonyList = new Gson().fromJson("{devices:[{name:default,ip:" + theHarmonyAddress + "}]}", IpList.class); - } catch (Exception et) { - log.error("Cannot parse harmony.address, not set with message: " + e.getMessage(), e); - theHarmonyList = null; - } - } - } - theBridgeSettings.setHarmonyAddress(theHarmonyList); - theBridgeSettings.setUpnpStrict(Boolean.parseBoolean(System.getProperty("upnp.strict", "true"))); - theBridgeSettings.setTraceupnp(Boolean.parseBoolean(System.getProperty("trace.upnp", "false"))); - theBridgeSettings.setButtonsleep(Integer.parseInt(System.getProperty("button.sleep", Configuration.DEFAULT_BUTTON_SLEEP))); - theBridgeSettings.setNestuser(System.getProperty("nest.user")); - theBridgeSettings.setNestpwd(System.getProperty("nest.pwd")); - } - - if(theBridgeSettings.getUpnpConfigAddress() == null || theBridgeSettings.getUpnpConfigAddress().equals("")) { - addressString = checkIpAddress(null, true); - if(addressString != null) { - theBridgeSettings.setUpnpConfigAddress(addressString); - log.info("Adding " + addressString + " as our default upnp config address."); - } - else - log.error("Cannot get ip address of this host."); - } - else { - addressString = checkIpAddress(theBridgeSettings.getUpnpConfigAddress(), false); - if(addressString == null) - log.warn("The upnp config address, " + theBridgeSettings.getUpnpConfigAddress() + ", does not match any known IP's on this host."); - } - - if(theBridgeSettings.getUpnpResponsePort() == null) - theBridgeSettings.setUpnpResponsePort(Configuration.UPNP_RESPONSE_PORT); - - if(theBridgeSettings.getServerPort() == null) - theBridgeSettings.setServerPort(Configuration.DEFAULT_WEB_PORT); - - if(theBridgeSettings.getUpnpDeviceDb() == null) - theBridgeSettings.setUpnpDeviceDb(Configuration.DEVICE_DB_DIRECTORY); - - if(theBridgeSettings.getNumberoflogmessages() == null || theBridgeSettings.getNumberoflogmessages() <= 0) - theBridgeSettings.setNumberoflogmessages(new Integer(Configuration.NUMBER_OF_LOG_MESSAGES)); - - if(theBridgeSettings.getButtonsleep() == null || theBridgeSettings.getButtonsleep() < 0) - theBridgeSettings.setButtonsleep(Integer.parseInt(Configuration.DEFAULT_BUTTON_SLEEP)); - - theBridgeSettings.setVeraconfigured(theBridgeSettings.isValidVera()); - theBridgeSettings.setHarmonyconfigured(theBridgeSettings.isValidHarmony()); - theBridgeSettings.setNestConfigured(theBridgeSettings.isValidNest()); - theBridgeSettings.setHueconfigured(theBridgeSettings.isValidHue()); - theBridgeSettings.setHalconfigured(theBridgeSettings.isValidHal()); - theBridgeSettings.setMqttconfigured(theBridgeSettings.isValidMQTT()); - theBridgeSettings.setHassconfigured(theBridgeSettings.isValidHass()); - theBridgeSettings.setDomoticzconfigured(theBridgeSettings.isValidDomoticz()); - if(serverPortOverride != null) - theBridgeSettings.setServerPort(serverPortOverride); - if(serverIpOverride != null) - theBridgeSettings.setWebaddress(serverIpOverride); - setupParams(Paths.get(theBridgeSettings.getConfigfile()), ".cfgbk", "habridge.config-"); - } - - public void loadConfig() { - if(theBridgeSettings.getConfigfile() != null) - _loadConfig(); - } - private void _loadConfig() { - Path configPath = Paths.get(theBridgeSettings.getConfigfile()); - _loadConfig(configPath); - } - - private void _loadConfig(Path aPath) { - String jsonContent = configReader(aPath); - if(jsonContent == null) - return; - try { - theBridgeSettings = new Gson().fromJson(jsonContent, BridgeSettingsDescriptor.class); - } catch (Exception e) { - log.warn("Issue loading values from file: " + aPath.toUri().toString() + ", Gson convert failed."); - theBridgeSettings = new BridgeSettingsDescriptor(); - theBridgeSettings.setConfigfile(aPath.toString()); - } - } - - public void save(BridgeSettingsDescriptor newBridgeSettings) { - log.debug("Save HA Bridge settings."); - Path configPath = Paths.get(theBridgeSettings.getConfigfile()); - JsonTransformer aRenderer = new JsonTransformer(); - String jsonValue = aRenderer.render(newBridgeSettings); - configWriter(jsonValue, configPath); - _loadConfig(configPath); - } - - - private void configWriter(String content, Path filePath) { - if(Files.exists(filePath) && !Files.isWritable(filePath)){ - log.error("Error file is not writable: " + filePath); - return; - } - - if(Files.notExists(filePath.getParent())) { - try { - Files.createDirectories(filePath.getParent()); - } catch (IOException e) { - log.error("Error creating the directory: " + filePath + " message: " + e.getMessage(), e); - } - } - - try { - Path target = null; - if(Files.exists(filePath)) { - target = FileSystems.getDefault().getPath(filePath.getParent().toString(), "habridge.config.old"); - Files.move(filePath, target); - } - Files.write(filePath, content.getBytes(), StandardOpenOption.CREATE); - - // set attributes to be for user only - // using PosixFilePermission to set file permissions - Set perms = new HashSet(); - // add owners permission - perms.add(PosixFilePermission.OWNER_READ); - perms.add(PosixFilePermission.OWNER_WRITE); - - try { - Files.setPosixFilePermissions(filePath, perms); - } catch(UnsupportedOperationException e) { - log.info("Cannot set permissions for config file on this system as it is not supported. Continuing"); - } - if(target != null) - Files.delete(target); - } catch (IOException e) { - log.error("Error writing the file: " + filePath + " message: " + e.getMessage(), e); - } - } - - private String configReader(Path filePath) { - String content = null; - if(Files.notExists(filePath) || !Files.isReadable(filePath)){ - log.warn("Error reading the file: " + filePath + " - Does not exist or is not readable. continuing..."); - return null; - } - - try { - content = new String(Files.readAllBytes(filePath)); - } catch (IOException e) { - log.error("Error reading the file: " + filePath + " message: " + e.getMessage(), e); - } - - return content; - } - - private String checkIpAddress(String ipAddress, boolean checkForLocalhost) { - Enumeration ifs = null; - try { - ifs = NetworkInterface.getNetworkInterfaces(); - } catch(SocketException e) { - log.error("checkIpAddress cannot get ip address of this host, Exiting with message: " + e.getMessage(), e); - return null; - } - String addressString = null; - InetAddress address = null; - while (ifs.hasMoreElements() && addressString == null) { - NetworkInterface xface = ifs.nextElement(); - Enumeration addrs = xface.getInetAddresses(); - String name = xface.getName(); - int IPsPerNic = 0; - - while (addrs.hasMoreElements() && IPsPerNic == 0) { - address = addrs.nextElement(); - if (InetAddressUtils.isIPv4Address(address.getHostAddress())) { - log.debug(name + " ... has IPV4 addr " + address); - if(checkForLocalhost && (!name.equalsIgnoreCase(Configuration.LOOP_BACK_INTERFACE) || !address.getHostAddress().equalsIgnoreCase(Configuration.LOOP_BACK_ADDRESS))) { - IPsPerNic++; - addressString = address.getHostAddress(); - log.debug("checkIpAddress found " + addressString + " from interface " + name); - } - else if(ipAddress != null && ipAddress.equalsIgnoreCase(address.getHostAddress())){ - addressString = ipAddress; - IPsPerNic++; - } - } - } - } - return addressString; - } -} +package com.bwssystems.HABridge; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.SocketException; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; +import java.nio.file.attribute.PosixFilePermission; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Set; + +import org.apache.http.conn.util.InetAddressUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.bwssystems.HABridge.util.BackupHandler; +import com.bwssystems.HABridge.util.JsonTransformer; +import com.google.gson.Gson; + +public class BridgeSettings extends BackupHandler { + private static final Logger log = LoggerFactory.getLogger(BridgeSettings.class); + private BridgeSettingsDescriptor theBridgeSettings; + private BridgeControlDescriptor bridgeControl; + + public BridgeSettings() { + super(); + bridgeControl = new BridgeControlDescriptor(); + theBridgeSettings = new BridgeSettingsDescriptor(); + String ipV6Stack = System.getProperty("ipV6Stack"); + if(ipV6Stack == null || !ipV6Stack.equalsIgnoreCase("true")) { + System.setProperty("java.net.preferIPv4Stack" , "true"); + } + + } + public BridgeControlDescriptor getBridgeControl() { + return bridgeControl; + } + public BridgeSettingsDescriptor getBridgeSettingsDescriptor() { + return theBridgeSettings; + } + public void buildSettings() { + String addressString = null; + String theVeraAddress = null; + String theSomfyAddress = null; + String theHarmonyAddress = null; + String configFileProperty = System.getProperty("config.file"); + if(configFileProperty == null) { + Path filePath = Paths.get(Configuration.CONFIG_FILE); + if(Files.exists(filePath) && Files.isReadable(filePath)) + configFileProperty = Configuration.CONFIG_FILE; + } + String serverPortOverride = System.getProperty("server.port"); + String serverIpOverride = System.getProperty("server.ip"); + if(configFileProperty != null) + { + log.info("reading from config file: " + configFileProperty); + theBridgeSettings.setConfigfile(configFileProperty); + _loadConfig(); + } + else + { + log.info("reading from system properties"); + theBridgeSettings.setNumberoflogmessages(Configuration.NUMBER_OF_LOG_MESSAGES); + theBridgeSettings.setFarenheit(true); + theBridgeSettings.setConfigfile(Configuration.CONFIG_FILE); + theBridgeSettings.setServerPort(System.getProperty("server.port", Configuration.DEFAULT_WEB_PORT)); + theBridgeSettings.setUpnpConfigAddress(System.getProperty("upnp.config.address")); + theBridgeSettings.setUpnpDeviceDb(System.getProperty("upnp.device.db")); + theBridgeSettings.setUpnpResponsePort(System.getProperty("upnp.response.port", Configuration.UPNP_RESPONSE_PORT)); + + theVeraAddress = System.getProperty("vera.address"); + IpList theVeraList = null; + if(theVeraAddress != null) { + try { + theVeraList = new Gson().fromJson(theVeraAddress, IpList.class); + } catch (Exception e) { + try { + theVeraList = new Gson().fromJson("{devices:[{name:default,ip:" + theVeraAddress + "}]}", IpList.class); + } catch (Exception et) { + log.error("Cannot parse vera.address, not set with message: " + e.getMessage(), e); + theVeraList = null; + } + } + } + theBridgeSettings.setVeraAddress(theVeraList); + + theHarmonyAddress = System.getProperty("harmony.address"); + IpList theHarmonyList = null; + if(theHarmonyAddress != null) { + try { + theHarmonyList = new Gson().fromJson(theHarmonyAddress, IpList.class); + } catch (Exception e) { + try { + theHarmonyList = new Gson().fromJson("{devices:[{name:default,ip:" + theHarmonyAddress + "}]}", IpList.class); + } catch (Exception et) { + log.error("Cannot parse harmony.address, not set with message: " + e.getMessage(), e); + theHarmonyList = null; + } + } + } + theBridgeSettings.setHarmonyAddress(theHarmonyList); + + theSomfyAddress = System.getProperty("somfy.address"); + IpList theSomfyList = null; + if(theSomfyAddress != null) { + try { + theSomfyList = new Gson().fromJson(theSomfyAddress, IpList.class); + } catch (Exception e) { + try { + theSomfyList = new Gson().fromJson("{devices:[{name:default,ip:" + theSomfyAddress + "}]}", IpList.class); + } catch (Exception et) { + log.error("Cannot parse somfy.address, not set with message: " + e.getMessage(), e); + theSomfyList = null; + } + } + } + theBridgeSettings.setSomfyAddress(theSomfyList); + + theBridgeSettings.setUpnpStrict(Boolean.parseBoolean(System.getProperty("upnp.strict", "true"))); + theBridgeSettings.setTraceupnp(Boolean.parseBoolean(System.getProperty("trace.upnp", "false"))); + theBridgeSettings.setButtonsleep(Integer.parseInt(System.getProperty("button.sleep", Configuration.DEFAULT_BUTTON_SLEEP))); + theBridgeSettings.setNestuser(System.getProperty("nest.user")); + theBridgeSettings.setNestpwd(System.getProperty("nest.pwd")); + } + + if(theBridgeSettings.getUpnpConfigAddress() == null || theBridgeSettings.getUpnpConfigAddress().equals("")) { + addressString = checkIpAddress(null, true); + if(addressString != null) { + theBridgeSettings.setUpnpConfigAddress(addressString); + log.info("Adding " + addressString + " as our default upnp config address."); + } + else + log.error("Cannot get ip address of this host."); + } + else { + addressString = checkIpAddress(theBridgeSettings.getUpnpConfigAddress(), false); + if(addressString == null) + log.warn("The upnp config address, " + theBridgeSettings.getUpnpConfigAddress() + ", does not match any known IP's on this host."); + } + + if(theBridgeSettings.getUpnpResponsePort() == null) + theBridgeSettings.setUpnpResponsePort(Configuration.UPNP_RESPONSE_PORT); + + if(theBridgeSettings.getServerPort() == null) + theBridgeSettings.setServerPort(Configuration.DEFAULT_WEB_PORT); + + if(theBridgeSettings.getUpnpDeviceDb() == null) + theBridgeSettings.setUpnpDeviceDb(Configuration.DEVICE_DB_DIRECTORY); + + if(theBridgeSettings.getNumberoflogmessages() == null || theBridgeSettings.getNumberoflogmessages() <= 0) + theBridgeSettings.setNumberoflogmessages(new Integer(Configuration.NUMBER_OF_LOG_MESSAGES)); + + if(theBridgeSettings.getButtonsleep() == null || theBridgeSettings.getButtonsleep() < 0) + theBridgeSettings.setButtonsleep(Integer.parseInt(Configuration.DEFAULT_BUTTON_SLEEP)); + + theBridgeSettings.setVeraconfigured(theBridgeSettings.isValidVera()); + theBridgeSettings.setHarmonyconfigured(theBridgeSettings.isValidHarmony()); + theBridgeSettings.setNestConfigured(theBridgeSettings.isValidNest()); + theBridgeSettings.setHueconfigured(theBridgeSettings.isValidHue()); + theBridgeSettings.setHalconfigured(theBridgeSettings.isValidHal()); + theBridgeSettings.setMqttconfigured(theBridgeSettings.isValidMQTT()); + theBridgeSettings.setHassconfigured(theBridgeSettings.isValidHass()); + theBridgeSettings.setDomoticzconfigured(theBridgeSettings.isValidDomoticz()); + theBridgeSettings.setSomfyconfigured(theBridgeSettings.isValidSomfy()); + if(serverPortOverride != null) + theBridgeSettings.setServerPort(serverPortOverride); + if(serverIpOverride != null) + theBridgeSettings.setWebaddress(serverIpOverride); + setupParams(Paths.get(theBridgeSettings.getConfigfile()), ".cfgbk", "habridge.config-"); + } + + public void loadConfig() { + if(theBridgeSettings.getConfigfile() != null) + _loadConfig(); + } + private void _loadConfig() { + Path configPath = Paths.get(theBridgeSettings.getConfigfile()); + _loadConfig(configPath); + } + + private void _loadConfig(Path aPath) { + String jsonContent = configReader(aPath); + if(jsonContent == null) + return; + try { + theBridgeSettings = new Gson().fromJson(jsonContent, BridgeSettingsDescriptor.class); + } catch (Exception e) { + log.warn("Issue loading values from file: " + aPath.toUri().toString() + ", Gson convert failed."); + theBridgeSettings = new BridgeSettingsDescriptor(); + theBridgeSettings.setConfigfile(aPath.toString()); + } + } + + public void save(BridgeSettingsDescriptor newBridgeSettings) { + log.debug("Save HA Bridge settings."); + Path configPath = Paths.get(theBridgeSettings.getConfigfile()); + JsonTransformer aRenderer = new JsonTransformer(); + String jsonValue = aRenderer.render(newBridgeSettings); + configWriter(jsonValue, configPath); + _loadConfig(configPath); + } + + + private void configWriter(String content, Path filePath) { + if(Files.exists(filePath) && !Files.isWritable(filePath)){ + log.error("Error file is not writable: " + filePath); + return; + } + + if(Files.notExists(filePath.getParent())) { + try { + Files.createDirectories(filePath.getParent()); + } catch (IOException e) { + log.error("Error creating the directory: " + filePath + " message: " + e.getMessage(), e); + } + } + + try { + Path target = null; + if(Files.exists(filePath)) { + target = FileSystems.getDefault().getPath(filePath.getParent().toString(), "habridge.config.old"); + Files.move(filePath, target); + } + Files.write(filePath, content.getBytes(), StandardOpenOption.CREATE); + + // set attributes to be for user only + // using PosixFilePermission to set file permissions + Set perms = new HashSet(); + // add owners permission + perms.add(PosixFilePermission.OWNER_READ); + perms.add(PosixFilePermission.OWNER_WRITE); + + try { + Files.setPosixFilePermissions(filePath, perms); + } catch(UnsupportedOperationException e) { + log.info("Cannot set permissions for config file on this system as it is not supported. Continuing"); + } + if(target != null) + Files.delete(target); + } catch (IOException e) { + log.error("Error writing the file: " + filePath + " message: " + e.getMessage(), e); + } + } + + private String configReader(Path filePath) { + String content = null; + if(Files.notExists(filePath) || !Files.isReadable(filePath)){ + log.warn("Error reading the file: " + filePath + " - Does not exist or is not readable. continuing..."); + return null; + } + + try { + content = new String(Files.readAllBytes(filePath)); + } catch (IOException e) { + log.error("Error reading the file: " + filePath + " message: " + e.getMessage(), e); + } + + return content; + } + + private String checkIpAddress(String ipAddress, boolean checkForLocalhost) { + Enumeration ifs = null; + try { + ifs = NetworkInterface.getNetworkInterfaces(); + } catch(SocketException e) { + log.error("checkIpAddress cannot get ip address of this host, Exiting with message: " + e.getMessage(), e); + return null; + } + String addressString = null; + InetAddress address = null; + while (ifs.hasMoreElements() && addressString == null) { + NetworkInterface xface = ifs.nextElement(); + Enumeration addrs = xface.getInetAddresses(); + String name = xface.getName(); + int IPsPerNic = 0; + + while (addrs.hasMoreElements() && IPsPerNic == 0) { + address = addrs.nextElement(); + if (InetAddressUtils.isIPv4Address(address.getHostAddress())) { + log.debug(name + " ... has IPV4 addr " + address); + if(checkForLocalhost && (!name.equalsIgnoreCase(Configuration.LOOP_BACK_INTERFACE) || !address.getHostAddress().equalsIgnoreCase(Configuration.LOOP_BACK_ADDRESS))) { + IPsPerNic++; + addressString = address.getHostAddress(); + log.debug("checkIpAddress found " + addressString + " from interface " + name); + } + else if(ipAddress != null && ipAddress.equalsIgnoreCase(address.getHostAddress())){ + addressString = ipAddress; + IPsPerNic++; + } + } + } + } + return addressString; + } +} diff --git a/src/main/resources/public/views/system.html b/src/main/resources/public/views/system.html index 6451311..e84cc4a 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
  • +
  • Somfy Devices
  • Add/Edit
  • @@ -357,6 +358,46 @@ + + Somfy Names and IP Addresses + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameIP/hostnameUsernamePassword Manage
    {{somfy.name}}{{somfy.ip}}{{somfy.username}}*******
    + Nest Username Date: Sat, 4 Feb 2017 18:29:50 +0000 Subject: [PATCH 07/14] Add Somfy devices --- .../com/bwssystems/HABridge/HomeManager.java | 4 + .../HABridge/plugins/somfy/SomfyDevice.java | 67 +++++++ .../HABridge/plugins/somfy/SomfyHome.java | 103 ++++++++++ .../HABridge/plugins/somfy/SomfyInfo.java | 184 ++++++++++++++++++ .../resources/public/views/somfydevice.html | 147 ++++++++++++++ 5 files changed, 505 insertions(+) create mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyDevice.java create mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java create mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyInfo.java create mode 100644 src/main/resources/public/views/somfydevice.html diff --git a/src/main/java/com/bwssystems/HABridge/HomeManager.java b/src/main/java/com/bwssystems/HABridge/HomeManager.java index 83b1118..5838e6c 100644 --- a/src/main/java/com/bwssystems/HABridge/HomeManager.java +++ b/src/main/java/com/bwssystems/HABridge/HomeManager.java @@ -13,6 +13,7 @@ import com.bwssystems.HABridge.plugins.hass.HassHome; import com.bwssystems.HABridge.plugins.http.HTTPHome; import com.bwssystems.HABridge.plugins.hue.HueHome; import com.bwssystems.HABridge.plugins.mqtt.MQTTHome; +import com.bwssystems.HABridge.plugins.somfy.SomfyHome; import com.bwssystems.HABridge.plugins.tcp.TCPHome; import com.bwssystems.HABridge.plugins.udp.UDPHome; import com.bwssystems.HABridge.plugins.vera.VeraHome; @@ -86,6 +87,9 @@ public class HomeManager { //setup the HomeAssistant configuration if available aHome = new DomoticzHome(bridgeSettings); resourceList.put(DeviceMapTypes.DOMOTICZ_DEVICE[DeviceMapTypes.typeIndex], aHome); + //setup the Somfy configuration if available + aHome = new SomfyHome(bridgeSettings); + homeList.put(DeviceMapTypes.SOMFY_DEVICE[DeviceMapTypes.typeIndex], aHome); } public Home findHome(String type) { diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyDevice.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyDevice.java new file mode 100644 index 0000000..e29743a --- /dev/null +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyDevice.java @@ -0,0 +1,67 @@ +package com.bwssystems.HABridge.plugins.somfy; + +public class SomfyDevice { + private String id; + private String room; + private String category; + private String somfyname; + private String name; + private String deviceUrl; + private String deviceType; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return id; + } + + public void setRoom(String room) { + this.room = room; + } + + public String getRoom() { + return room; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getCategory() { + return category; + } + + public void setSomfyname(String somfyname) { + this.somfyname = somfyname; + } + + public String getSomfyname() { + return somfyname; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setDeviceUrl(String deviceUrl) { + this.deviceUrl = deviceUrl; + } + + public String getDeviceUrl() { + return deviceUrl; + } + + public void setDeviceType(String deviceType) { + this.deviceType = deviceType; + } + + public String getDeviceType() { + return deviceType; + } +} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java new file mode 100644 index 0000000..9f2476d --- /dev/null +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java @@ -0,0 +1,103 @@ +package com.bwssystems.HABridge.plugins.somfy; + +import com.bwssystems.HABridge.BridgeSettingsDescriptor; +import com.bwssystems.HABridge.DeviceMapTypes; +import com.bwssystems.HABridge.Home; +import com.bwssystems.HABridge.NamedIP; +import com.bwssystems.HABridge.api.CallItem; +import com.bwssystems.HABridge.dao.DeviceDescriptor; +import com.bwssystems.HABridge.hue.MultiCommandUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.*; + +public class SomfyHome implements Home { + private static final Logger log = LoggerFactory.getLogger(SomfyHome.class); + private Map somfys; + private Boolean validSomfy; + + public SomfyHome(BridgeSettingsDescriptor bridgeSettings) { + createHome(bridgeSettings); + + } + + public SomfyInfo getSomfyHandler(String somfyName) { + return somfys.get(somfyName); + } + + public List getDevices() { + log.debug("consolidating devices for somfy"); + Iterator keys = somfys.keySet().iterator(); + ArrayList deviceList = new ArrayList<>(); + while(keys.hasNext()) { + String key = keys.next(); + List devices = somfys.get(key).getSomfyDevices(); + deviceList.addAll(devices); + } + return deviceList; + } + + @Override + public Object getItems(String type) { + if(validSomfy) { + if(type.equalsIgnoreCase(DeviceMapTypes.SOMFY_DEVICE[DeviceMapTypes.typeIndex])) + return getDevices(); + } + return null; + } + + @Override + public String deviceHandler(CallItem anItem, MultiCommandUtil aMultiUtil, String lightId, int intensity, Integer targetBri, Integer targetBriInc, DeviceDescriptor device, String body) { + String responseString = null; + if (!validSomfy) { + log.warn("Should not get here, no somfy hub available"); + responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId + + "\",\"description\": \"Should not get here, no somfy hub available\", \"parameter\": \"/lights/" + + lightId + "state\"}}]"; + } else { + if (anItem.getType() != null && anItem.getType().trim().equalsIgnoreCase(DeviceMapTypes.SOMFY_DEVICE[DeviceMapTypes.typeIndex])) { + + log.debug("executing HUE api request to change activity to Somfy: " + anItem.getItem().getAsString()); + String jsonToPost = anItem.getItem().getAsString(); + + //RunActivity anActivity = new Gson().fromJson(url, RunActivity.class); + SomfyInfo somfyHandler = getSomfyHandler(device.getTargetDevice()); + if(somfyHandler == null) { + log.warn("Should not get here, no Somfy configured"); + responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId + + "\",\"description\": \"Should not get here, no somfy configured\", \"parameter\": \"/lights/" + + lightId + "state\"}}]"; + } else { + try { + somfyHandler.execApply(jsonToPost); + } catch (Exception e) { + throw new RuntimeException(e); + } + + } + } + } + return responseString; + } + + @Override + public Home createHome(BridgeSettingsDescriptor bridgeSettings) { + validSomfy = bridgeSettings.isValidSomfy(); + log.info("Vera Home created." + (validSomfy ? "" : " No Veras configured.")); + if(validSomfy) { + somfys = new HashMap(); + Iterator theList = bridgeSettings.getSomfyAddress().getDevices().iterator(); + while (theList.hasNext()) { + NamedIP aSomfy = theList.next(); + somfys.put(aSomfy.getName(), new SomfyInfo(aSomfy, aSomfy.getName())); + } + } + return this; + } + + @Override + public void closeHome() { + + } +} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyInfo.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyInfo.java new file mode 100644 index 0000000..95f4a8a --- /dev/null +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyInfo.java @@ -0,0 +1,184 @@ +package com.bwssystems.HABridge.plugins.somfy; + +import com.bwssystems.HABridge.NamedIP; +import com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup.Device; +import com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup.GetSetup; +import com.google.gson.Gson; +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.NameValuePair; +import org.apache.http.client.HttpClient; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.conn.ssl.AllowAllHostnameVerifier; +import org.apache.http.conn.ssl.TrustStrategy; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.ssl.SSLContextBuilder; +import org.apache.http.util.EntityUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import spark.utils.IOUtils; +import us.monoid.json.JSONException; + +import java.io.IOException; +import java.nio.charset.Charset; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.util.*; + + +public class SomfyInfo { + private static final Logger log = LoggerFactory.getLogger(SomfyInfo.class); + private final String somfyName; + private final NamedIP namedIP; + private HttpClient httpClient; + private static final String CONNECT_HOST = "https://www.tahomalink.com/"; + private static final String BASE_URL = CONNECT_HOST + "enduser-mobile-web/externalAPI/"; + private static final String BASE_URL_ENDUSER = CONNECT_HOST + "enduser-mobile-web/enduserAPI/"; + + public SomfyInfo(NamedIP namedIP, String somfyName) { + super(); + this.somfyName = somfyName; + this.namedIP = namedIP; + } + + private void initHttpClient() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException { + if(httpClient==null) { + httpClient = HttpClients.custom(). + setHostnameVerifier(new AllowAllHostnameVerifier()). + setSslcontext(new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() { + public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { + return true; + } + }).build()).build(); + } + } + + + // This function executes the url against the vera + protected String doHttpGETRequest(String url) { + String theContent = null; + log.debug("calling GET on URL: " + url); + HttpGet httpGet = new HttpGet(url); + try { + HttpResponse response = httpClient.execute(httpGet); + log.debug("GET on URL responded: " + response.getStatusLine().getStatusCode()); + if(response.getStatusLine().getStatusCode() == 200){ + theContent = EntityUtils.toString(response.getEntity(), Charset.forName("UTF-8")); //read content for data + EntityUtils.consume(response.getEntity()); //close out inputstream ignore content + } + } catch (IOException e) { + log.error("doHttpGETRequest: Error calling out to HA gateway: " + e.getMessage()); + } + return theContent; + } + + public List getSomfyDevices() { + + List somfyDevices = new ArrayList<>(); + try { + login(namedIP.getUsername(), namedIP.getPassword()); + GetSetup setupData = getSetup(); + for(Device device : setupData.getSetup().getDevices()) { + somfyDevices.add(mapDeviceToSomfyDevice(device)); + } + } catch (Exception e) { + log.error("Could not get Somfy devices", e); + } + return somfyDevices; + } + + + public void login(String username, String password) throws Exception { + + initHttpClient(); + HttpPost httpPost = new HttpPost(BASE_URL + "json/login"); + + //HttpHost proxy = new HttpHost("127.0.0.1", 8888, "http"); + RequestConfig config = RequestConfig.custom() + // .setProxy(proxy) + .build(); + httpPost.setConfig(config); + httpPost.addHeader("User-Agent","mine"); + List nvps = new ArrayList(); + nvps.add(new BasicNameValuePair("userId", username)); + nvps.add(new BasicNameValuePair("userPassword", password)); + httpPost.setEntity(new UrlEncodedFormEntity(nvps)); + System.out.println("Making SOMFY http login call"); + HttpResponse response = httpClient.execute(httpPost); + + //try { + System.out.println(response.getStatusLine()); + HttpEntity entity = response.getEntity(); + EntityUtils.consume(entity); + //} finally { + // response.close(); + //} + } + + public GetSetup getSetup() throws IOException, JSONException { + HttpGet httpGet = new HttpGet(BASE_URL + "json/getSetup"); + httpGet.addHeader("User-Agent","mine"); + System.out.println("Making SOMFY http setup call"); + + HttpResponse response = httpClient.execute(httpGet); + //try { + System.out.println(response.getStatusLine()); + HttpEntity entity = response.getEntity(); + + String json = IOUtils.toString(entity.getContent()); + System.out.println(json); + GetSetup setupData = new Gson().fromJson(json, GetSetup.class); + return setupData; + + //} finally { + // response.close(); + //} + } + + public void execApply(String jsonToPost) throws Exception { + login("house@edonica.com", "drawde123"); + HttpPost httpPost = new HttpPost(BASE_URL_ENDUSER + "exec/apply"); + + //HttpHost proxy = new HttpHost("127.0.0.1", 8888, "http"); + RequestConfig config = RequestConfig.custom() + // .setProxy(proxy) + .build(); + httpPost.setConfig(config); + httpPost.addHeader("User-Agent", "mine"); + httpPost.addHeader("Content-Type", "application/json;charset=UTF-8"); + + httpPost.setEntity(new StringEntity(jsonToPost, "UTF-8")); + System.out.println("Making SOMFY http exec call"); + HttpResponse response = httpClient.execute(httpPost); + + //try { + System.out.println(response.getStatusLine()); + HttpEntity entity = response.getEntity(); + EntityUtils.consume(entity); + //} finally { + //response.close(); + //} + } + + + protected SomfyDevice mapDeviceToSomfyDevice(Device device) { + SomfyDevice somfyDevice = new SomfyDevice(); + somfyDevice.setId(device.getOid()); + somfyDevice.setCategory(device.getUiClass()); + somfyDevice.setRoom(""); + somfyDevice.setSomfyname(somfyName); + somfyDevice.setName(device.getLabel()); + somfyDevice.setDeviceUrl(device.getDeviceURL()); + somfyDevice.setDeviceType(device.getWidget()); + return somfyDevice; + } + +} diff --git a/src/main/resources/public/views/somfydevice.html b/src/main/resources/public/views/somfydevice.html new file mode 100644 index 0000000..bae9cd7 --- /dev/null +++ b/src/main/resources/public/views/somfydevice.html @@ -0,0 +1,147 @@ + + +
    +
    +

    Somfy Device List + ({{bridge.somfydevices.length}})

    +
    +
    +

    For any Somfy 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 Somfy Devices' list below will show + what is already setup for your Somfy.

    +

    + 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 + 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 Somfy.

    +
    + + + + + + + + + + + + + + + + + + + + + + +
    Row NameIdCategoryRoomSomfyBuild Actions
    {{$index+1}} + {{somfydevice.name}}{{somfydevice.id}}{{somfydevice.category}}{{somfydevice.room}}{{somfydevice.somfyname}} + +
    +
    + +
    + +
    +
    +

    + Already Configured Somfy Devices +

    +
    +
    + + + + + + + + + + + + + + + + + + + + + + +
    RowNameIdCategoryRoomSomfyActions
    {{$index+1}}{{device.name}}{{device.id}}{{device.category}}{{device.room}}{{device.somfyname}} +

    + + +

    +
    +
    +
    +
    + \ No newline at end of file From 6b8a7149599b45d3027c838d4edbeb10d1012767 Mon Sep 17 00:00:00 2001 From: Monica Goward Date: Sat, 4 Feb 2017 18:40:28 +0000 Subject: [PATCH 08/14] Re-instating line endings that were erroneously removed --- .../HABridge/BridgeSettingsDescriptor.java | 4 +- .../bwssystems/HABridge/DeviceMapTypes.java | 2 +- src/main/resources/public/scripts/app.js | 100 +++++++++--------- .../resources/public/views/editdevice.html | 2 +- .../resources/public/views/haldevice.html | 4 +- .../public/views/harmonyactivity.html | 2 +- .../resources/public/views/harmonydevice.html | 2 +- .../resources/public/views/huedevice.html | 2 +- .../resources/public/views/mqttpublish.html | 2 +- .../resources/public/views/nestactions.html | 2 +- .../resources/public/views/veradevice.html | 3 +- .../resources/public/views/verascene.html | 2 +- 12 files changed, 63 insertions(+), 64 deletions(-) diff --git a/src/main/java/com/bwssystems/HABridge/BridgeSettingsDescriptor.java b/src/main/java/com/bwssystems/HABridge/BridgeSettingsDescriptor.java index 2ceeb5b..58032ff 100644 --- a/src/main/java/com/bwssystems/HABridge/BridgeSettingsDescriptor.java +++ b/src/main/java/com/bwssystems/HABridge/BridgeSettingsDescriptor.java @@ -329,7 +329,7 @@ public class BridgeSettingsDescriptor { } public Boolean isValidHass() { if(this.getHassaddress() == null || this.getHassaddress().getDevices().size() <= 0) - return false; + return false; List devicesList = this.getHassaddress().getDevices(); if(devicesList.get(0).getIp().contains(Configuration.DEFAULT_ADDRESS)) return false; @@ -337,7 +337,7 @@ public class BridgeSettingsDescriptor { } public Boolean isValidDomoticz() { if(this.getDomoticzaddress() == null || this.getDomoticzaddress().getDevices().size() <= 0) - return false; + return false; List devicesList = this.getDomoticzaddress().getDevices(); if(devicesList.get(0).getIp().contains(Configuration.DEFAULT_ADDRESS)) return false; diff --git a/src/main/java/com/bwssystems/HABridge/DeviceMapTypes.java b/src/main/java/com/bwssystems/HABridge/DeviceMapTypes.java index fda444e..c25946a 100644 --- a/src/main/java/com/bwssystems/HABridge/DeviceMapTypes.java +++ b/src/main/java/com/bwssystems/HABridge/DeviceMapTypes.java @@ -65,7 +65,7 @@ public class DeviceMapTypes { public ArrayList getDeviceMapTypes() { return deviceMapTypes; } - + public Boolean validateType(String type) { if(type == null || type.trim().isEmpty()) return false; diff --git a/src/main/resources/public/scripts/app.js b/src/main/resources/public/scripts/app.js index a3c8df6..1178439 100644 --- a/src/main/resources/public/scripts/app.js +++ b/src/main/resources/public/scripts/app.js @@ -20,7 +20,7 @@ app.config (function ($locationProvider, $routeProvider) { controller: 'VeraController' }).when ('/verascenes', { templateUrl: 'views/verascene.html', - controller: 'VeraController' + controller: 'VeraController' }).when ('/harmonydevices', { templateUrl: 'views/harmonydevice.html', controller: 'HarmonyController' @@ -41,7 +41,7 @@ app.config (function ($locationProvider, $routeProvider) { controller: 'MQTTController' }).when ('/hassdevices', { templateUrl: 'views/hassdevice.html', - controller: 'HassController' + controller: 'HassController' }).when ('/domoticzdevices', { templateUrl: 'views/domoticzdevice.html', controller: 'DomoticzController' @@ -167,20 +167,20 @@ app.service ('bridgeService', function ($http, $window, ngToast) { this.deviceContainsType = function (device, aType) { if(device.mapType !== undefined && device.mapType !== null && device.mapType.indexOf(aType) >= 0) return true; - + if(device.deviceType !== undefined && device.deviceType !== null && device.deviceType.indexOf(aType) >= 0) return true; - + if(device.onUrl !== undefined && device.onUrl !== null && device.onUrl.indexOf(aType) >= 0) return true; - + if(device.dimUrl !== undefined && device.dimUrl !== null && device.dimUrl.indexOf(aType) >= 0) return true; - + if(device.offUrl !== undefined && device.offUrl !== null && device.offUrl.indexOf(aType) >= 0) return true; - - + + return false; } this.compareHarmonyNumber = function(r1, r2) { @@ -484,7 +484,7 @@ app.service ('bridgeService', function ($http, $window, ngToast) { return currentItem; }; - + this.getCallObjects = function (deviceString) { if (deviceString === undefined || deviceString === "") return null; @@ -504,7 +504,7 @@ app.service ('bridgeService', function ($http, $window, ngToast) { } return newDevices } - + this.updateCallObjectsType = function (theDevices) { var i, s, type, len = theDevices.length for (i=0; i

    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 a8c743e..8345aaa 100644 --- a/src/main/resources/public/views/haldevice.html +++ b/src/main/resources/public/views/haldevice.html @@ -30,7 +30,7 @@

    For any HAL 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 + 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 HAL Devices' list below will show what @@ -132,7 +132,7 @@

    - + diff --git a/src/main/resources/public/views/harmonyactivity.html b/src/main/resources/public/views/harmonyactivity.html index 0eef1c1..ef470d7 100644 --- a/src/main/resources/public/views/harmonyactivity.html +++ b/src/main/resources/public/views/harmonyactivity.html @@ -30,7 +30,7 @@

    For any Harmony Activity, 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 + 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 Activities' list diff --git a/src/main/resources/public/views/harmonydevice.html b/src/main/resources/public/views/harmonydevice.html index 7f2e217..a1f58df 100644 --- a/src/main/resources/public/views/harmonydevice.html +++ b/src/main/resources/public/views/harmonydevice.html @@ -30,7 +30,7 @@

    For any Harmony Device and Buttons, 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 + 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 diff --git a/src/main/resources/public/views/huedevice.html b/src/main/resources/public/views/huedevice.html index 5e7e907..535d5c3 100644 --- a/src/main/resources/public/views/huedevice.html +++ b/src/main/resources/public/views/huedevice.html @@ -31,7 +31,7 @@

    For any Hue 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 + 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 Hue Devices' list below will show what diff --git a/src/main/resources/public/views/mqttpublish.html b/src/main/resources/public/views/mqttpublish.html index 50755c2..6f09211 100644 --- a/src/main/resources/public/views/mqttpublish.html +++ b/src/main/resources/public/views/mqttpublish.html @@ -26,7 +26,7 @@ to generate the item addition information into the ha-bridge device and this will put you into the edit screen. You can add topic and content in the text areas provided then selecting the publish generation. 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 + 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 diff --git a/src/main/resources/public/views/nestactions.html b/src/main/resources/public/views/nestactions.html index e5a139e..78fbcaa 100644 --- a/src/main/resources/public/views/nestactions.html +++ b/src/main/resources/public/views/nestactions.html @@ -30,7 +30,7 @@

    For any Nest Item, 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 + 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 Nest Items' list below will show what diff --git a/src/main/resources/public/views/veradevice.html b/src/main/resources/public/views/veradevice.html index 6f522e3..4eb4222 100644 --- a/src/main/resources/public/views/veradevice.html +++ b/src/main/resources/public/views/veradevice.html @@ -31,7 +31,7 @@ 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 + 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 Vera Devices' list below will show @@ -50,7 +50,6 @@ 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 96de847..8e38bbd 100644 --- a/src/main/resources/public/views/verascene.html +++ b/src/main/resources/public/views/verascene.html @@ -29,7 +29,7 @@

    For any Vera Scene, 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 + 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 Vera Scenes' list below will show what From e5871e61b5f4fc7a15ffc5867f28fe2aaf1e1caf Mon Sep 17 00:00:00 2001 From: Monica Goward Date: Sat, 4 Feb 2017 19:04:34 +0000 Subject: [PATCH 09/14] Added some initial docs --- README.md | 10 +++++++--- .../com/bwssystems/HABridge/HomeManager.java | 1 + .../HABridge/plugins/somfy/SomfyHome.java | 18 +++++++++++++++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e0c06d8..2f7ad7a 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Emulates Philips Hue api to other home automation gateways such as an Amazon Ech **FAQ: Please look here for the current FAQs! https://github.com/bwssytems/ha-bridge/wiki/HA-Bridge-FAQs** -In the cases of systems that require authorization and/or have API's that cannot be handled in the current method, a module may need to be built. The Harmony Hub is such a module and so is the Nest module. The Bridge has helpers to build devices for the gateway for the Logitech Harmony Hub, Vera, Vera Lite or Vera Edge, Nest and the ability to proxy all of your real Hue bridges behind this bridge. +In the cases of systems that require authorization and/or have API's that cannot be handled in the current method, a module may need to be built. The Harmony Hub is such a module and so is the Nest module. The Bridge has helpers to build devices for the gateway for the Logitech Harmony Hub, Vera, Vera Lite or Vera Edge, Nest, Somfy Tahoma and the ability to proxy all of your real Hue bridges behind this bridge. Alternatively the Bridge supports custom calls as well using http/https/udp and tcp such as the LimitlessLED/MiLight bulbs using the UDP protocol. Binary data is supported with UDP/TCP. @@ -261,7 +261,7 @@ The server defaults to running on port 80. To override what the default is, spec #### UPNP Response Port The upnp response port that will be used. The default is 50000. #### Vera Names and IP Addresses -Provide IP Addresses of your Veras that you want to utilize with the bridge. Also, give a meaningful name to each one so it is easy to decipher in the helper tab. When these names and IP's are given, the bridge will be able to control the devices or scenes by the call it receives and send it to the target Vera and device/scene you configure. +Provide IP Addresses of your Veras that you want to utilize with the bridge. Also, give a meaningful name to each one so it is easy to decipher in the helper tab. When these names and IP's are given, the bridge will be able to control the devices or scenes by the call it receives and send it to the target Vera and device/scene you configure. Note you have to 'turn on' a window to open it, and 'turn off' to close. #### Harmony Names and IP Addresses Provide IP Addresses of your Harmony Hubs that you want to utilize with the bridge. Also, give a meaningful name to each one so it is easy to decipher in the helper tab. When these names and IP's are given, the bridge will be able to control the activity or buttons by the call it receives and send it to the target Harmony Hub and activity/button you configure. #### Harmony Username @@ -284,6 +284,10 @@ The user name of the home.nest.com account for the Nest user. This needs to be g The password for the user name of the home.nest.com account for the Nest user. This needs to be given if you are using the Nest features. #### Nest Temp Fahrenheit This setting allows the value being sent into the bridge to be interpreted as Fahrenheit or Celsius. The default is to have Fahrenheit. +#### Somfy Tahoma Username +The user name used to login to www.tahomalink.com. This needs to be provided if you're using the Somfy Tahoma features (for connecting to IO Homecontrol used by Velux among others). There is no need to give any IP address or host information as this contacts your cloud account +#### Somfy Tahoma Password +The password associated with the Somfy Tahoma username above #### Button Press/Call Item Loop Sleep Interval (ms) This setting is the time used in between button presses when there is multiple buttons in a button device. It also controls the time between multiple items in a custom device call. This is defaulted to 100ms and the number represents milliseconds (1000 milliseconds = 1 second). #### Log Messages to Buffer @@ -334,7 +338,7 @@ The Add/Edit tab will show you the fields to fill in for the above in a form, wh The format of the item can be the default HTTP request which executes the URLs formatted as `http://` as a GET. Other options to this are to select the HTTP Verb and add the data type and add a body that is passed with the request. Secure https is supported as well, just use `https://`. When using POST and PUT, you have the ability to specify the body that will be sent with the request as well as the application type for the http call. The valid device types are: "custom", "veraDevice", "veraScene", "harmonyActivity", "harmonyButton", "nestHomeAway", "nestThermoSet", "hueDevice", "halDevice", - "halButton", "halHome", "halThermoSet", "mqttMessage", "cmdDevice", "hassDevice", "tcpDevice", "udpDevice", "httpDevice", "domoticzDevice" + "halButton", "halHome", "halThermoSet", "mqttMessage", "cmdDevice", "hassDevice", "tcpDevice", "udpDevice", "httpDevice", "domoticzDevice", "somfyDevice" Filter Ip example: ``` diff --git a/src/main/java/com/bwssystems/HABridge/HomeManager.java b/src/main/java/com/bwssystems/HABridge/HomeManager.java index 5838e6c..ae4ace1 100644 --- a/src/main/java/com/bwssystems/HABridge/HomeManager.java +++ b/src/main/java/com/bwssystems/HABridge/HomeManager.java @@ -90,6 +90,7 @@ public class HomeManager { //setup the Somfy configuration if available aHome = new SomfyHome(bridgeSettings); homeList.put(DeviceMapTypes.SOMFY_DEVICE[DeviceMapTypes.typeIndex], aHome); + resourceList.put(DeviceMapTypes.SOMFY_DEVICE[DeviceMapTypes.typeIndex], aHome); } public Home findHome(String type) { diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java index 9f2476d..60b2a9d 100644 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java @@ -10,8 +10,24 @@ import com.bwssystems.HABridge.hue.MultiCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.*; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.HashMap; +/** + * Support for Somfy Tahoma hub which allows control of IO Homecontrol devices such as Velux windows. + * Currently supports 'turn on' for open window, and 'turn off' for close. + * + * Known issues: + * //TODO - Fix bug on UI where bulk update seems to add the single device twice + * //TODO - Fix bug on UI where already configured devices are not shown as such. + * + * Enhancements: + * //TODO - support 'dimming' for partial window opening. + * + */ public class SomfyHome implements Home { private static final Logger log = LoggerFactory.getLogger(SomfyHome.class); private Map somfys; From ee066f1449d111f591d8bf63d67719735361dafd Mon Sep 17 00:00:00 2001 From: Monica Goward Date: Sat, 4 Feb 2017 19:12:20 +0000 Subject: [PATCH 10/14] Cleanup --- .../HABridge/plugins/somfy/SomfyHome.java | 2 +- .../HABridge/plugins/somfy/SomfyInfo.java | 84 +++++-------------- 2 files changed, 21 insertions(+), 65 deletions(-) diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java index 60b2a9d..acbdf89 100644 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java @@ -102,7 +102,7 @@ public class SomfyHome implements Home { validSomfy = bridgeSettings.isValidSomfy(); log.info("Vera Home created." + (validSomfy ? "" : " No Veras configured.")); if(validSomfy) { - somfys = new HashMap(); + somfys = new HashMap<>(); Iterator theList = bridgeSettings.getSomfyAddress().getDevices().iterator(); while (theList.hasNext()) { NamedIP aSomfy = theList.next(); diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyInfo.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyInfo.java index 95f4a8a..303d934 100644 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyInfo.java +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyInfo.java @@ -51,34 +51,11 @@ public class SomfyInfo { private void initHttpClient() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException { if(httpClient==null) { - httpClient = HttpClients.custom(). - setHostnameVerifier(new AllowAllHostnameVerifier()). - setSslcontext(new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() { - public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { - return true; - } - }).build()).build(); + httpClient = HttpClients.createDefault(); } } - - // This function executes the url against the vera - protected String doHttpGETRequest(String url) { - String theContent = null; - log.debug("calling GET on URL: " + url); - HttpGet httpGet = new HttpGet(url); - try { - HttpResponse response = httpClient.execute(httpGet); - log.debug("GET on URL responded: " + response.getStatusLine().getStatusCode()); - if(response.getStatusLine().getStatusCode() == 200){ - theContent = EntityUtils.toString(response.getEntity(), Charset.forName("UTF-8")); //read content for data - EntityUtils.consume(response.getEntity()); //close out inputstream ignore content - } - } catch (IOException e) { - log.error("doHttpGETRequest: Error calling out to HA gateway: " + e.getMessage()); - } - return theContent; - } + public List getSomfyDevices() { @@ -100,72 +77,51 @@ public class SomfyInfo { initHttpClient(); HttpPost httpPost = new HttpPost(BASE_URL + "json/login"); - - //HttpHost proxy = new HttpHost("127.0.0.1", 8888, "http"); - RequestConfig config = RequestConfig.custom() - // .setProxy(proxy) - .build(); - httpPost.setConfig(config); httpPost.addHeader("User-Agent","mine"); List nvps = new ArrayList(); nvps.add(new BasicNameValuePair("userId", username)); nvps.add(new BasicNameValuePair("userPassword", password)); httpPost.setEntity(new UrlEncodedFormEntity(nvps)); - System.out.println("Making SOMFY http login call"); + log.debug("Making SOMFY http login call"); HttpResponse response = httpClient.execute(httpPost); - //try { - System.out.println(response.getStatusLine()); - HttpEntity entity = response.getEntity(); - EntityUtils.consume(entity); - //} finally { - // response.close(); - //} + log.debug(response.getStatusLine().toString()); + HttpEntity entity = response.getEntity(); + EntityUtils.consume(entity); } public GetSetup getSetup() throws IOException, JSONException { HttpGet httpGet = new HttpGet(BASE_URL + "json/getSetup"); httpGet.addHeader("User-Agent","mine"); - System.out.println("Making SOMFY http setup call"); + log.info("Making SOMFY http setup call"); HttpResponse response = httpClient.execute(httpGet); - //try { - System.out.println(response.getStatusLine()); - HttpEntity entity = response.getEntity(); + log.debug(response.getStatusLine().toString()); + HttpEntity entity = response.getEntity(); - String json = IOUtils.toString(entity.getContent()); - System.out.println(json); - GetSetup setupData = new Gson().fromJson(json, GetSetup.class); - return setupData; - - //} finally { - // response.close(); - //} + String json = IOUtils.toString(entity.getContent()); + log.debug(json); + GetSetup setupData = new Gson().fromJson(json, GetSetup.class); + return setupData; } public void execApply(String jsonToPost) throws Exception { login("house@edonica.com", "drawde123"); HttpPost httpPost = new HttpPost(BASE_URL_ENDUSER + "exec/apply"); - //HttpHost proxy = new HttpHost("127.0.0.1", 8888, "http"); - RequestConfig config = RequestConfig.custom() - // .setProxy(proxy) - .build(); + RequestConfig config = RequestConfig.custom().build(); httpPost.setConfig(config); httpPost.addHeader("User-Agent", "mine"); httpPost.addHeader("Content-Type", "application/json;charset=UTF-8"); httpPost.setEntity(new StringEntity(jsonToPost, "UTF-8")); - System.out.println("Making SOMFY http exec call"); + log.info("Making SOMFY http exec call"); HttpResponse response = httpClient.execute(httpPost); - - //try { - System.out.println(response.getStatusLine()); - HttpEntity entity = response.getEntity(); - EntityUtils.consume(entity); - //} finally { - //response.close(); - //} + + log.info(response.getStatusLine().toString()); + HttpEntity entity = response.getEntity(); + EntityUtils.consume(entity); + } From f8474f5f41c3a4b36c5068f54303eba289e61a1f Mon Sep 17 00:00:00 2001 From: Monica Goward Date: Mon, 6 Feb 2017 21:28:06 +0000 Subject: [PATCH 11/14] Initial fixes and cleanup prior to pull request 1 --- .../HABridge/plugins/somfy/SomfyHome.java | 13 ++++--- src/main/resources/public/scripts/app.js | 26 ++++---------- .../resources/public/views/somfydevice.html | 34 ++++++++----------- 3 files changed, 28 insertions(+), 45 deletions(-) diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java index acbdf89..bdab8a3 100644 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java @@ -21,9 +21,7 @@ import java.util.HashMap; * Currently supports 'turn on' for open window, and 'turn off' for close. * * Known issues: - * //TODO - Fix bug on UI where bulk update seems to add the single device twice - * //TODO - Fix bug on UI where already configured devices are not shown as such. - * + * //TODO - Fix bug on UI where bulk update seems to add the single device twice if 'update' is clicked (this is a general bug with Vera too I think) * Enhancements: * //TODO - support 'dimming' for partial window opening. * @@ -76,8 +74,7 @@ public class SomfyHome implements Home { log.debug("executing HUE api request to change activity to Somfy: " + anItem.getItem().getAsString()); String jsonToPost = anItem.getItem().getAsString(); - - //RunActivity anActivity = new Gson().fromJson(url, RunActivity.class); + SomfyInfo somfyHandler = getSomfyHandler(device.getTargetDevice()); if(somfyHandler == null) { log.warn("Should not get here, no Somfy configured"); @@ -88,7 +85,9 @@ public class SomfyHome implements Home { try { somfyHandler.execApply(jsonToPost); } catch (Exception e) { - throw new RuntimeException(e); + log.warn("Error posting request to Somfy"); + responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId + + "\",\"description\": \"Error posting request to SomfyTahoma\", \"parameter\": \"/lights/" + lightId + "state\"}}]"; } } @@ -114,6 +113,6 @@ public class SomfyHome implements Home { @Override public void closeHome() { - + somfys = null; } } diff --git a/src/main/resources/public/scripts/app.js b/src/main/resources/public/scripts/app.js index 4d28bf5..cbad3e0 100644 --- a/src/main/resources/public/scripts/app.js +++ b/src/main/resources/public/scripts/app.js @@ -2344,6 +2344,7 @@ app.controller('SomfyController', function ($scope, $location, $http, bridgeServ $scope.bulk = { devices: [] }; $scope.selectAll = false; $scope.somfy = {base: "http://", port: "3480", id: ""}; + bridgeService.viewDevices(); //Needs this if you're navigating to the 'somfy' page directly without going to the home page first.. bridgeService.viewSomfyDevices(); $scope.imgButtonsUrl = "glyphicon glyphicon-plus"; $scope.buttonsVisible = false; @@ -2354,8 +2355,8 @@ app.controller('SomfyController', function ($scope, $location, $http, bridgeServ $scope.device = bridgeService.state.device; }; - $scope.buildDeviceUrls = function (somfydevice, dim_control) { - //TODO - support partial window opening + $scope.buildDeviceUrls = function (somfydevice) { + //TODO - support partial window opening - add back 'dim_control' second param in here, and in somfydevice.html dimpayload = ""; onpayload = "{\"label\":\"Label that is ignored probably\",\"actions\":[{\"deviceURL\":\""+ somfydevice.deviceUrl+"\",\"commands\":[{\"name\":\"open\",\"parameters\":[]}]}]}"; offpayload = "{\"label\":\"Label that is ignored probably\",\"actions\":[{\"deviceURL\":\""+ somfydevice.deviceUrl+"\",\"commands\":[{\"name\":\"close\",\"parameters\":[]}]}]}"; @@ -2732,14 +2733,13 @@ app.filter('configuredDomoticzItems', function (bridgeService) { } }); - -app.filter('availableSomfyDeviceId', function(bridgeService) { +app.filter('configuredSomfyDevices', function (bridgeService) { return function(input) { var out = []; - if(input == null) + if(input === undefined || input === null || input.length === undefined) return out; for (var i = 0; i < input.length; i++) { - if(!bridgeService.findDeviceByMapId(input[i].id, input[i].somfyname, "somfyDevice")){ + if(bridgeService.deviceContainsType(input[i], "somfyDevice")){ out.push(input[i]); } } @@ -2747,19 +2747,7 @@ app.filter('availableSomfyDeviceId', function(bridgeService) { } }); -app.filter('unavailableSomfyDeviceId', function(bridgeService) { - return function(input) { - var out = []; - if(input == null) - return out; - for (var i = 0; i < input.length; i++) { - if(bridgeService.findDeviceByMapId(input[i].id, input[i].somfyname, "somfyDevice")){ - out.push(input[i]); - } - } - return out; - } -}); + app.controller('VersionController', function ($scope, bridgeService) { diff --git a/src/main/resources/public/views/somfydevice.html b/src/main/resources/public/views/somfydevice.html index bae9cd7..7bdbc07 100644 --- a/src/main/resources/public/views/somfydevice.html +++ b/src/main/resources/public/views/somfydevice.html @@ -36,20 +36,19 @@ done in the edit tab, click the 'Add Bridge Device' to finish that selection setup. The 'Already Configured Somfy Devices' list below will show what is already setup for your Somfy.

    -

    +

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

    + feature. Select your items, then click + bulk add below. Your items will be added with the name of the device from the Somfy Tahoma.

    @@ -80,15 +79,16 @@
    {{somfydevice.room}} {{somfydevice.somfyname}} + + ng-click="buildDeviceUrls(somfydevice)">Build Item
    @@ -97,7 +97,7 @@

    Already Configured Somfy Devices + class={{imgButtonsUrl}} aria-hidden="true">

    @@ -107,10 +107,8 @@ Row Name - Id - Category - Room - Somfy + Somfy + Map Id Actions @@ -118,10 +116,8 @@ ng-repeat="device in bridge.devices |configuredSomfyDevices"> {{$index+1}} {{device.name}} - {{device.id}} - {{device.category}} - {{device.room}} - {{device.somfyname}} + {{device.targetDevice}} + {{device.mapId}}

    - \ No newline at end of file + From 88f34f3221efd7c7ef1a3442a7b48b7fa11615d6 Mon Sep 17 00:00:00 2001 From: Monica Goward Date: Wed, 22 Feb 2017 21:44:17 +0000 Subject: [PATCH 12/14] Update to use HABridge HTTPHandler --- .../HABridge/plugins/somfy/SomfyInfo.java | 82 +++++++------------ 1 file changed, 29 insertions(+), 53 deletions(-) diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyInfo.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyInfo.java index 303d934..cd70fc9 100644 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyInfo.java +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyInfo.java @@ -1,44 +1,32 @@ package com.bwssystems.HABridge.plugins.somfy; import com.bwssystems.HABridge.NamedIP; +import com.bwssystems.HABridge.api.NameValue; +import com.bwssystems.HABridge.plugins.http.HTTPHandler; import com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup.Device; import com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup.GetSetup; import com.google.gson.Gson; -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; -import org.apache.http.client.HttpClient; -import org.apache.http.client.config.RequestConfig; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; -import org.apache.http.conn.ssl.AllowAllHostnameVerifier; -import org.apache.http.conn.ssl.TrustStrategy; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicNameValuePair; -import org.apache.http.ssl.SSLContextBuilder; -import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import spark.utils.IOUtils; -import us.monoid.json.JSONException; - +import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.nio.charset.Charset; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.util.*; +import java.util.ArrayList; +import java.util.List; public class SomfyInfo { private static final Logger log = LoggerFactory.getLogger(SomfyInfo.class); private final String somfyName; private final NamedIP namedIP; - private HttpClient httpClient; + private HTTPHandler httpClient; private static final String CONNECT_HOST = "https://www.tahomalink.com/"; private static final String BASE_URL = CONNECT_HOST + "enduser-mobile-web/externalAPI/"; private static final String BASE_URL_ENDUSER = CONNECT_HOST + "enduser-mobile-web/enduserAPI/"; @@ -51,7 +39,7 @@ public class SomfyInfo { private void initHttpClient() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException { if(httpClient==null) { - httpClient = HttpClients.createDefault(); + httpClient = new HTTPHandler(); } } @@ -76,52 +64,40 @@ public class SomfyInfo { public void login(String username, String password) throws Exception { initHttpClient(); - HttpPost httpPost = new HttpPost(BASE_URL + "json/login"); - httpPost.addHeader("User-Agent","mine"); + NameValue[] httpHeader = getHttpHeaders(); List nvps = new ArrayList(); nvps.add(new BasicNameValuePair("userId", username)); nvps.add(new BasicNameValuePair("userPassword", password)); - httpPost.setEntity(new UrlEncodedFormEntity(nvps)); log.debug("Making SOMFY http login call"); - HttpResponse response = httpClient.execute(httpPost); - - log.debug(response.getStatusLine().toString()); - HttpEntity entity = response.getEntity(); - EntityUtils.consume(entity); + UrlEncodedFormEntity urlEncodedFormEntity = new UrlEncodedFormEntity(nvps); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + urlEncodedFormEntity.writeTo(bos); + String body = bos.toString(); + String response = httpClient.doHttpRequest(BASE_URL + "json/login",HttpPost.METHOD_NAME, "application/x-www-form-urlencoded", body,httpHeader); + log.debug(response); } - public GetSetup getSetup() throws IOException, JSONException { - HttpGet httpGet = new HttpGet(BASE_URL + "json/getSetup"); - httpGet.addHeader("User-Agent","mine"); + private NameValue[] getHttpHeaders() { + NameValue userAgentHeader = new NameValue(); + userAgentHeader.setName("User-Agent"); + userAgentHeader.setValue("mine"); + return new NameValue[]{userAgentHeader}; + } + + public GetSetup getSetup() throws IOException { + NameValue[] httpHeader = getHttpHeaders(); log.info("Making SOMFY http setup call"); - - HttpResponse response = httpClient.execute(httpGet); - log.debug(response.getStatusLine().toString()); - HttpEntity entity = response.getEntity(); - - String json = IOUtils.toString(entity.getContent()); - log.debug(json); - GetSetup setupData = new Gson().fromJson(json, GetSetup.class); + String response = httpClient.doHttpRequest(BASE_URL + "json/getSetup", HttpGet.METHOD_NAME, "", "", httpHeader ); + log.debug(response); + GetSetup setupData = new Gson().fromJson(response, GetSetup.class); return setupData; } public void execApply(String jsonToPost) throws Exception { - login("house@edonica.com", "drawde123"); - HttpPost httpPost = new HttpPost(BASE_URL_ENDUSER + "exec/apply"); - - RequestConfig config = RequestConfig.custom().build(); - httpPost.setConfig(config); - httpPost.addHeader("User-Agent", "mine"); - httpPost.addHeader("Content-Type", "application/json;charset=UTF-8"); - - httpPost.setEntity(new StringEntity(jsonToPost, "UTF-8")); + login(namedIP.getUsername(), namedIP.getPassword()); log.info("Making SOMFY http exec call"); - HttpResponse response = httpClient.execute(httpPost); - - log.info(response.getStatusLine().toString()); - HttpEntity entity = response.getEntity(); - EntityUtils.consume(entity); - + String response = httpClient.doHttpRequest(BASE_URL_ENDUSER + "exec/apply", HttpPost.METHOD_NAME, "application/json;charset=UTF-8", jsonToPost, getHttpHeaders()); + log.info(response); } From c8b1827150e20b6f647a6e9ce76ece7c74c92b83 Mon Sep 17 00:00:00 2001 From: Monica Goward Date: Thu, 16 Mar 2017 12:59:43 +0000 Subject: [PATCH 13/14] Fixes post merge to comply with updated js code json --- .../HABridge/plugins/somfy/SomfyHome.java | 4 ++-- src/main/resources/public/scripts/app.js | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java index bdab8a3..01520e1 100644 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java @@ -72,8 +72,8 @@ public class SomfyHome implements Home { } else { if (anItem.getType() != null && anItem.getType().trim().equalsIgnoreCase(DeviceMapTypes.SOMFY_DEVICE[DeviceMapTypes.typeIndex])) { - log.debug("executing HUE api request to change activity to Somfy: " + anItem.getItem().getAsString()); - String jsonToPost = anItem.getItem().getAsString(); + log.debug("executing HUE api request to change activity to Somfy: " + anItem.getItem().toString()); + String jsonToPost = anItem.getItem().toString(); SomfyInfo somfyHandler = getSomfyHandler(device.getTargetDevice()); if(somfyHandler == null) { diff --git a/src/main/resources/public/scripts/app.js b/src/main/resources/public/scripts/app.js index 1fffbbe..e73742f 100644 --- a/src/main/resources/public/scripts/app.js +++ b/src/main/resources/public/scripts/app.js @@ -2462,7 +2462,7 @@ app.controller('SomfyController', function ($scope, $location, $http, bridgeServ $scope.device = bridgeService.state.device; }; - $scope.buildDeviceUrls = function (somfydevice) { + $scope.buildDeviceUrls = function (somfydevice, dim_control, buildonly) { //TODO - support partial window opening - add back 'dim_control' second param in here, and in somfydevice.html dimpayload = ""; onpayload = "{\"label\":\"Label that is ignored probably\",\"actions\":[{\"deviceURL\":\""+ somfydevice.deviceUrl+"\",\"commands\":[{\"name\":\"open\",\"parameters\":[]}]}]}"; @@ -2470,18 +2470,20 @@ app.controller('SomfyController', function ($scope, $location, $http, bridgeServ bridgeService.buildUrls(onpayload, dimpayload, offpayload, true, somfydevice.id, somfydevice.name, somfydevice.somfyname, "switch", "somfyDevice", null, null); $scope.device = bridgeService.state.device; - bridgeService.editNewDevice($scope.device); - $location.path('/editdevice'); - + if (!buildonly) { + bridgeService.editNewDevice($scope.device); + $location.path('/editdevice'); + } }; $scope.bulkAddDevices = function(dim_control) { var devicesList = []; + $scope.clearDevice(); for(var i = 0; i < $scope.bulk.devices.length; i++) { for(var x = 0; x < bridgeService.state.somfydevices.length; x++) { if(bridgeService.state.somfydevices[x].id === $scope.bulk.devices[i]) { - $scope.buildDeviceUrls(bridgeService.state.somfydevices[x],dim_control); + $scope.buildDeviceUrls(bridgeService.state.somfydevices[x],dim_control, true); devicesList[i] = { name: $scope.device.name, mapId: $scope.device.mapId, @@ -2498,6 +2500,7 @@ app.controller('SomfyController', function ($scope, $location, $http, bridgeServ contentBodyDim: $scope.device.contentBodyDim, contentBodyOff: $scope.device.contentBodyOff }; + $scope.clearDevice(); } } } From c9c6d6e66dfcce7ee5cde7f94cff614daac29a33 Mon Sep 17 00:00:00 2001 From: Monica Goward Date: Thu, 16 Mar 2017 13:13:53 +0000 Subject: [PATCH 14/14] Cleanup json->pojo mapping --- .../HABridge/plugins/somfy/SomfyHome.java | 2 +- .../jsonschema2pojo/getsetup/Command.java | 32 --- .../getsetup/Connectivity.java | 32 --- .../getsetup/DataProperty.java | 32 --- .../jsonschema2pojo/getsetup/Definition.java | 99 --------- .../jsonschema2pojo/getsetup/Device.java | 135 +----------- .../jsonschema2pojo/getsetup/Feature.java | 32 --- .../jsonschema2pojo/getsetup/Gateway.java | 120 ---------- .../jsonschema2pojo/getsetup/GetSetup.java | 12 - .../jsonschema2pojo/getsetup/Location.java | 208 ------------------ .../jsonschema2pojo/getsetup/RootPlace.java | 77 ------- .../somfy/jsonschema2pojo/getsetup/Setup.java | 88 +------- .../somfy/jsonschema2pojo/getsetup/State.java | 55 ----- .../jsonschema2pojo/getsetup/State_.java | 43 ---- .../jsonschema2pojo/getsetup/SubPlace.java | 88 -------- .../jsonschema2pojo/getsetup/SubPlace_.java | 88 -------- .../jsonschema2pojo/getsetup/generationConfig | 4 +- 17 files changed, 8 insertions(+), 1139 deletions(-) delete mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Command.java delete mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Connectivity.java delete mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/DataProperty.java delete mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Definition.java delete mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Feature.java delete mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Gateway.java delete mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Location.java delete mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/RootPlace.java delete mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/State.java delete mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/State_.java delete mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/SubPlace.java delete mode 100644 src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/SubPlace_.java diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java index 01520e1..9073bb1 100644 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java @@ -99,7 +99,7 @@ public class SomfyHome implements Home { @Override public Home createHome(BridgeSettingsDescriptor bridgeSettings) { validSomfy = bridgeSettings.isValidSomfy(); - log.info("Vera Home created." + (validSomfy ? "" : " No Veras configured.")); + log.info("Somfy Home created." + (validSomfy ? "" : " No Somfys configured.")); if(validSomfy) { somfys = new HashMap<>(); Iterator theList = bridgeSettings.getSomfyAddress().getDevices().iterator(); diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Command.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Command.java deleted file mode 100644 index e3df38d..0000000 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Command.java +++ /dev/null @@ -1,32 +0,0 @@ - -package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Command { - - @SerializedName("commandName") - @Expose - private String commandName; - @SerializedName("nparams") - @Expose - private Long nparams; - - public String getCommandName() { - return commandName; - } - - public void setCommandName(String commandName) { - this.commandName = commandName; - } - - public Long getNparams() { - return nparams; - } - - public void setNparams(Long nparams) { - this.nparams = nparams; - } - -} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Connectivity.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Connectivity.java deleted file mode 100644 index b2ca632..0000000 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Connectivity.java +++ /dev/null @@ -1,32 +0,0 @@ - -package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Connectivity { - - @SerializedName("status") - @Expose - private String status; - @SerializedName("protocolVersion") - @Expose - private String protocolVersion; - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getProtocolVersion() { - return protocolVersion; - } - - public void setProtocolVersion(String protocolVersion) { - this.protocolVersion = protocolVersion; - } - -} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/DataProperty.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/DataProperty.java deleted file mode 100644 index 68df4d0..0000000 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/DataProperty.java +++ /dev/null @@ -1,32 +0,0 @@ - -package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class DataProperty { - - @SerializedName("value") - @Expose - private String value; - @SerializedName("qualifiedName") - @Expose - private String qualifiedName; - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public String getQualifiedName() { - return qualifiedName; - } - - public void setQualifiedName(String qualifiedName) { - this.qualifiedName = qualifiedName; - } - -} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Definition.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Definition.java deleted file mode 100644 index 154ec8e..0000000 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Definition.java +++ /dev/null @@ -1,99 +0,0 @@ - -package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; - -import java.util.List; -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Definition { - - @SerializedName("commands") - @Expose - private List commands = null; - @SerializedName("events") - @Expose - private List events = null; - @SerializedName("states") - @Expose - private List states = null; - @SerializedName("dataProperties") - @Expose - private List dataProperties = null; - @SerializedName("widgetName") - @Expose - private String widgetName; - @SerializedName("uiClass") - @Expose - private String uiClass; - @SerializedName("qualifiedName") - @Expose - private String qualifiedName; - @SerializedName("type") - @Expose - private String type; - - public List getCommands() { - return commands; - } - - public void setCommands(List commands) { - this.commands = commands; - } - - public List getEvents() { - return events; - } - - public void setEvents(List events) { - this.events = events; - } - - public List getStates() { - return states; - } - - public void setStates(List states) { - this.states = states; - } - - public List getDataProperties() { - return dataProperties; - } - - public void setDataProperties(List dataProperties) { - this.dataProperties = dataProperties; - } - - public String getWidgetName() { - return widgetName; - } - - public void setWidgetName(String widgetName) { - this.widgetName = widgetName; - } - - public String getUiClass() { - return uiClass; - } - - public void setUiClass(String uiClass) { - this.uiClass = uiClass; - } - - public String getQualifiedName() { - return qualifiedName; - } - - public void setQualifiedName(String qualifiedName) { - this.qualifiedName = qualifiedName; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - -} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Device.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Device.java index ddff606..b61aaee 100644 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Device.java +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Device.java @@ -6,52 +6,16 @@ import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; public class Device { - - @SerializedName("creationTime") - @Expose - private Long creationTime; - @SerializedName("lastUpdateTime") - @Expose - private Long lastUpdateTime; + @SerializedName("label") @Expose private String label; @SerializedName("deviceURL") @Expose private String deviceURL; - @SerializedName("shortcut") - @Expose - private Boolean shortcut; - @SerializedName("controllableName") - @Expose - private String controllableName; - @SerializedName("metadata") - @Expose - private String metadata; - @SerializedName("definition") - @Expose - private Definition definition; - @SerializedName("states") - @Expose - private List states = null; - @SerializedName("attributes") - @Expose - private List attributes = null; - @SerializedName("available") - @Expose - private Boolean available; - @SerializedName("enabled") - @Expose - private Boolean enabled; - @SerializedName("placeOID") - @Expose - private String placeOID; @SerializedName("widget") @Expose private String widget; - @SerializedName("type") - @Expose - private Long type; @SerializedName("oid") @Expose private String oid; @@ -59,21 +23,6 @@ public class Device { @Expose private String uiClass; - public Long getCreationTime() { - return creationTime; - } - - public void setCreationTime(Long creationTime) { - this.creationTime = creationTime; - } - - public Long getLastUpdateTime() { - return lastUpdateTime; - } - - public void setLastUpdateTime(Long lastUpdateTime) { - this.lastUpdateTime = lastUpdateTime; - } public String getLabel() { return label; @@ -90,79 +39,8 @@ public class Device { public void setDeviceURL(String deviceURL) { this.deviceURL = deviceURL; } - - public Boolean getShortcut() { - return shortcut; - } - - public void setShortcut(Boolean shortcut) { - this.shortcut = shortcut; - } - - public String getControllableName() { - return controllableName; - } - - public void setControllableName(String controllableName) { - this.controllableName = controllableName; - } - - public String getMetadata() { - return metadata; - } - - public void setMetadata(String metadata) { - this.metadata = metadata; - } - - public Definition getDefinition() { - return definition; - } - - public void setDefinition(Definition definition) { - this.definition = definition; - } - - public List getStates() { - return states; - } - - public void setStates(List states) { - this.states = states; - } - - public List getAttributes() { - return attributes; - } - - public void setAttributes(List attributes) { - this.attributes = attributes; - } - - public Boolean getAvailable() { - return available; - } - - public void setAvailable(Boolean available) { - this.available = available; - } - - public Boolean getEnabled() { - return enabled; - } - - public void setEnabled(Boolean enabled) { - this.enabled = enabled; - } - - public String getPlaceOID() { - return placeOID; - } - - public void setPlaceOID(String placeOID) { - this.placeOID = placeOID; - } - + + public String getWidget() { return widget; } @@ -171,13 +49,6 @@ public class Device { this.widget = widget; } - public Long getType() { - return type; - } - - public void setType(Long type) { - this.type = type; - } public String getOid() { return oid; diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Feature.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Feature.java deleted file mode 100644 index 62f1bd7..0000000 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Feature.java +++ /dev/null @@ -1,32 +0,0 @@ - -package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Feature { - - @SerializedName("name") - @Expose - private String name; - @SerializedName("source") - @Expose - private String source; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getSource() { - return source; - } - - public void setSource(String source) { - this.source = source; - } - -} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Gateway.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Gateway.java deleted file mode 100644 index 52487d9..0000000 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Gateway.java +++ /dev/null @@ -1,120 +0,0 @@ - -package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Gateway { - - @SerializedName("gatewayId") - @Expose - private String gatewayId; - @SerializedName("type") - @Expose - private Long type; - @SerializedName("subType") - @Expose - private Long subType; - @SerializedName("placeOID") - @Expose - private String placeOID; - @SerializedName("alive") - @Expose - private Boolean alive; - @SerializedName("timeReliable") - @Expose - private Boolean timeReliable; - @SerializedName("connectivity") - @Expose - private Connectivity connectivity; - @SerializedName("upToDate") - @Expose - private Boolean upToDate; - @SerializedName("mode") - @Expose - private String mode; - @SerializedName("functions") - @Expose - private String functions; - - public String getGatewayId() { - return gatewayId; - } - - public void setGatewayId(String gatewayId) { - this.gatewayId = gatewayId; - } - - public Long getType() { - return type; - } - - public void setType(Long type) { - this.type = type; - } - - public Long getSubType() { - return subType; - } - - public void setSubType(Long subType) { - this.subType = subType; - } - - public String getPlaceOID() { - return placeOID; - } - - public void setPlaceOID(String placeOID) { - this.placeOID = placeOID; - } - - public Boolean getAlive() { - return alive; - } - - public void setAlive(Boolean alive) { - this.alive = alive; - } - - public Boolean getTimeReliable() { - return timeReliable; - } - - public void setTimeReliable(Boolean timeReliable) { - this.timeReliable = timeReliable; - } - - public Connectivity getConnectivity() { - return connectivity; - } - - public void setConnectivity(Connectivity connectivity) { - this.connectivity = connectivity; - } - - public Boolean getUpToDate() { - return upToDate; - } - - public void setUpToDate(Boolean upToDate) { - this.upToDate = upToDate; - } - - public String getMode() { - return mode; - } - - public void setMode(String mode) { - this.mode = mode; - } - - public String getFunctions() { - return functions; - } - - public void setFunctions(String functions) { - this.functions = functions; - } - -} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/GetSetup.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/GetSetup.java index 3ab0449..0478b58 100644 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/GetSetup.java +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/GetSetup.java @@ -10,9 +10,6 @@ public class GetSetup { @SerializedName("setup") @Expose private Setup setup; - @SerializedName("events") - @Expose - private List events = null; public Setup getSetup() { return setup; @@ -21,13 +18,4 @@ public class GetSetup { public void setSetup(Setup setup) { this.setup = setup; } - - public List getEvents() { - return events; - } - - public void setEvents(List events) { - this.events = events; - } - } diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Location.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Location.java deleted file mode 100644 index c4f9cf9..0000000 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Location.java +++ /dev/null @@ -1,208 +0,0 @@ - -package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Location { - - @SerializedName("creationTime") - @Expose - private Long creationTime; - @SerializedName("lastUpdateTime") - @Expose - private Long lastUpdateTime; - @SerializedName("city") - @Expose - private String city; - @SerializedName("country") - @Expose - private String country; - @SerializedName("postalCode") - @Expose - private String postalCode; - @SerializedName("addressLine1") - @Expose - private String addressLine1; - @SerializedName("addressLine2") - @Expose - private String addressLine2; - @SerializedName("timezone") - @Expose - private String timezone; - @SerializedName("longitude") - @Expose - private Double longitude; - @SerializedName("latitude") - @Expose - private Double latitude; - @SerializedName("twilightMode") - @Expose - private Long twilightMode; - @SerializedName("twilightAngle") - @Expose - private String twilightAngle; - @SerializedName("twilightCity") - @Expose - private String twilightCity; - @SerializedName("summerSolsticeDuskMinutes") - @Expose - private Long summerSolsticeDuskMinutes; - @SerializedName("winterSolsticeDuskMinutes") - @Expose - private Long winterSolsticeDuskMinutes; - @SerializedName("twilightOffsetEnabled") - @Expose - private Boolean twilightOffsetEnabled; - @SerializedName("dawnOffset") - @Expose - private Long dawnOffset; - @SerializedName("duskOffset") - @Expose - private Long duskOffset; - - public Long getCreationTime() { - return creationTime; - } - - public void setCreationTime(Long creationTime) { - this.creationTime = creationTime; - } - - public Long getLastUpdateTime() { - return lastUpdateTime; - } - - public void setLastUpdateTime(Long lastUpdateTime) { - this.lastUpdateTime = lastUpdateTime; - } - - public String getCity() { - return city; - } - - public void setCity(String city) { - this.city = city; - } - - public String getCountry() { - return country; - } - - public void setCountry(String country) { - this.country = country; - } - - public String getPostalCode() { - return postalCode; - } - - public void setPostalCode(String postalCode) { - this.postalCode = postalCode; - } - - public String getAddressLine1() { - return addressLine1; - } - - public void setAddressLine1(String addressLine1) { - this.addressLine1 = addressLine1; - } - - public String getAddressLine2() { - return addressLine2; - } - - public void setAddressLine2(String addressLine2) { - this.addressLine2 = addressLine2; - } - - public String getTimezone() { - return timezone; - } - - public void setTimezone(String timezone) { - this.timezone = timezone; - } - - public Double getLongitude() { - return longitude; - } - - public void setLongitude(Double longitude) { - this.longitude = longitude; - } - - public Double getLatitude() { - return latitude; - } - - public void setLatitude(Double latitude) { - this.latitude = latitude; - } - - public Long getTwilightMode() { - return twilightMode; - } - - public void setTwilightMode(Long twilightMode) { - this.twilightMode = twilightMode; - } - - public String getTwilightAngle() { - return twilightAngle; - } - - public void setTwilightAngle(String twilightAngle) { - this.twilightAngle = twilightAngle; - } - - public String getTwilightCity() { - return twilightCity; - } - - public void setTwilightCity(String twilightCity) { - this.twilightCity = twilightCity; - } - - public Long getSummerSolsticeDuskMinutes() { - return summerSolsticeDuskMinutes; - } - - public void setSummerSolsticeDuskMinutes(Long summerSolsticeDuskMinutes) { - this.summerSolsticeDuskMinutes = summerSolsticeDuskMinutes; - } - - public Long getWinterSolsticeDuskMinutes() { - return winterSolsticeDuskMinutes; - } - - public void setWinterSolsticeDuskMinutes(Long winterSolsticeDuskMinutes) { - this.winterSolsticeDuskMinutes = winterSolsticeDuskMinutes; - } - - public Boolean getTwilightOffsetEnabled() { - return twilightOffsetEnabled; - } - - public void setTwilightOffsetEnabled(Boolean twilightOffsetEnabled) { - this.twilightOffsetEnabled = twilightOffsetEnabled; - } - - public Long getDawnOffset() { - return dawnOffset; - } - - public void setDawnOffset(Long dawnOffset) { - this.dawnOffset = dawnOffset; - } - - public Long getDuskOffset() { - return duskOffset; - } - - public void setDuskOffset(Long duskOffset) { - this.duskOffset = duskOffset; - } - -} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/RootPlace.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/RootPlace.java deleted file mode 100644 index 902dfbe..0000000 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/RootPlace.java +++ /dev/null @@ -1,77 +0,0 @@ - -package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; - -import java.util.List; -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class RootPlace { - - @SerializedName("creationTime") - @Expose - private Long creationTime; - @SerializedName("lastUpdateTime") - @Expose - private Long lastUpdateTime; - @SerializedName("label") - @Expose - private String label; - @SerializedName("type") - @Expose - private Long type; - @SerializedName("oid") - @Expose - private String oid; - @SerializedName("subPlaces") - @Expose - private List subPlaces = null; - - public Long getCreationTime() { - return creationTime; - } - - public void setCreationTime(Long creationTime) { - this.creationTime = creationTime; - } - - public Long getLastUpdateTime() { - return lastUpdateTime; - } - - public void setLastUpdateTime(Long lastUpdateTime) { - this.lastUpdateTime = lastUpdateTime; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public Long getType() { - return type; - } - - public void setType(Long type) { - this.type = type; - } - - public String getOid() { - return oid; - } - - public void setOid(String oid) { - this.oid = oid; - } - - public List getSubPlaces() { - return subPlaces; - } - - public void setSubPlaces(List subPlaces) { - this.subPlaces = subPlaces; - } - -} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Setup.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Setup.java index 57b5656..90f76dd 100644 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Setup.java +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/Setup.java @@ -6,53 +6,13 @@ import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; public class Setup { - - @SerializedName("creationTime") - @Expose - private Long creationTime; - @SerializedName("lastUpdateTime") - @Expose - private Long lastUpdateTime; + @SerializedName("id") @Expose private String id; - @SerializedName("location") - @Expose - private Location location; - @SerializedName("gateways") - @Expose - private List gateways = null; @SerializedName("devices") @Expose private List devices = null; - @SerializedName("zones") - @Expose - private List zones = null; - @SerializedName("resellerDelegationType") - @Expose - private String resellerDelegationType; - @SerializedName("rootPlace") - @Expose - private RootPlace rootPlace; - @SerializedName("features") - @Expose - private List features = null; - - public Long getCreationTime() { - return creationTime; - } - - public void setCreationTime(Long creationTime) { - this.creationTime = creationTime; - } - - public Long getLastUpdateTime() { - return lastUpdateTime; - } - - public void setLastUpdateTime(Long lastUpdateTime) { - this.lastUpdateTime = lastUpdateTime; - } public String getId() { return id; @@ -62,22 +22,6 @@ public class Setup { this.id = id; } - public Location getLocation() { - return location; - } - - public void setLocation(Location location) { - this.location = location; - } - - public List getGateways() { - return gateways; - } - - public void setGateways(List gateways) { - this.gateways = gateways; - } - public List getDevices() { return devices; } @@ -86,36 +30,6 @@ public class Setup { this.devices = devices; } - public List getZones() { - return zones; - } - public void setZones(List zones) { - this.zones = zones; - } - - public String getResellerDelegationType() { - return resellerDelegationType; - } - - public void setResellerDelegationType(String resellerDelegationType) { - this.resellerDelegationType = resellerDelegationType; - } - - public RootPlace getRootPlace() { - return rootPlace; - } - - public void setRootPlace(RootPlace rootPlace) { - this.rootPlace = rootPlace; - } - - public List getFeatures() { - return features; - } - - public void setFeatures(List features) { - this.features = features; - } } diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/State.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/State.java deleted file mode 100644 index 41197f9..0000000 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/State.java +++ /dev/null @@ -1,55 +0,0 @@ - -package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; - -import java.util.List; -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class State { - - @SerializedName("eventBased") - @Expose - private Boolean eventBased; - @SerializedName("values") - @Expose - private List values = null; - @SerializedName("type") - @Expose - private String type; - @SerializedName("qualifiedName") - @Expose - private String qualifiedName; - - public Boolean getEventBased() { - return eventBased; - } - - public void setEventBased(Boolean eventBased) { - this.eventBased = eventBased; - } - - public List getValues() { - return values; - } - - public void setValues(List values) { - this.values = values; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getQualifiedName() { - return qualifiedName; - } - - public void setQualifiedName(String qualifiedName) { - this.qualifiedName = qualifiedName; - } - -} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/State_.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/State_.java deleted file mode 100644 index 90b60a6..0000000 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/State_.java +++ /dev/null @@ -1,43 +0,0 @@ - -package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class State_ { - - @SerializedName("name") - @Expose - private String name; - @SerializedName("type") - @Expose - private Long type; - @SerializedName("value") - @Expose - private String value; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Long getType() { - return type; - } - - public void setType(Long type) { - this.type = type; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - -} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/SubPlace.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/SubPlace.java deleted file mode 100644 index 76cc486..0000000 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/SubPlace.java +++ /dev/null @@ -1,88 +0,0 @@ - -package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; - -import java.util.List; -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class SubPlace { - - @SerializedName("creationTime") - @Expose - private Long creationTime; - @SerializedName("lastUpdateTime") - @Expose - private Long lastUpdateTime; - @SerializedName("label") - @Expose - private String label; - @SerializedName("type") - @Expose - private Long type; - @SerializedName("metadata") - @Expose - private String metadata; - @SerializedName("oid") - @Expose - private String oid; - @SerializedName("subPlaces") - @Expose - private List subPlaces = null; - - public Long getCreationTime() { - return creationTime; - } - - public void setCreationTime(Long creationTime) { - this.creationTime = creationTime; - } - - public Long getLastUpdateTime() { - return lastUpdateTime; - } - - public void setLastUpdateTime(Long lastUpdateTime) { - this.lastUpdateTime = lastUpdateTime; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public Long getType() { - return type; - } - - public void setType(Long type) { - this.type = type; - } - - public String getMetadata() { - return metadata; - } - - public void setMetadata(String metadata) { - this.metadata = metadata; - } - - public String getOid() { - return oid; - } - - public void setOid(String oid) { - this.oid = oid; - } - - public List getSubPlaces() { - return subPlaces; - } - - public void setSubPlaces(List subPlaces) { - this.subPlaces = subPlaces; - } - -} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/SubPlace_.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/SubPlace_.java deleted file mode 100644 index abdd748..0000000 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/SubPlace_.java +++ /dev/null @@ -1,88 +0,0 @@ - -package com.bwssystems.HABridge.plugins.somfy.jsonschema2pojo.getsetup; - -import java.util.List; -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class SubPlace_ { - - @SerializedName("creationTime") - @Expose - private Long creationTime; - @SerializedName("lastUpdateTime") - @Expose - private Long lastUpdateTime; - @SerializedName("label") - @Expose - private String label; - @SerializedName("type") - @Expose - private Long type; - @SerializedName("metadata") - @Expose - private String metadata; - @SerializedName("oid") - @Expose - private String oid; - @SerializedName("subPlaces") - @Expose - private List subPlaces = null; - - public Long getCreationTime() { - return creationTime; - } - - public void setCreationTime(Long creationTime) { - this.creationTime = creationTime; - } - - public Long getLastUpdateTime() { - return lastUpdateTime; - } - - public void setLastUpdateTime(Long lastUpdateTime) { - this.lastUpdateTime = lastUpdateTime; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public Long getType() { - return type; - } - - public void setType(Long type) { - this.type = type; - } - - public String getMetadata() { - return metadata; - } - - public void setMetadata(String metadata) { - this.metadata = metadata; - } - - public String getOid() { - return oid; - } - - public void setOid(String oid) { - this.oid = oid; - } - - public List getSubPlaces() { - return subPlaces; - } - - public void setSubPlaces(List subPlaces) { - this.subPlaces = subPlaces; - } - -} diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/generationConfig b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/generationConfig index e0d5d12..2f2dbf8 100644 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/generationConfig +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/jsonschema2pojo/getsetup/generationConfig @@ -14,4 +14,6 @@ Boxes checked: Use long integers Use double numbers Include getters and setters - Allow additional properties \ No newline at end of file + Allow additional properties + +Then manually removed all the unused methods so we have minimal json->pojo representation. \ No newline at end of file