]> git.basschouten.com Git - openhab-addons.git/commitdiff
[semsportal] Allow confiuration with thing file (#10842)
authorIwan Bron <44524316+itb3@users.noreply.github.com>
Sat, 12 Jun 2021 17:58:21 +0000 (19:58 +0200)
committerGitHub <noreply@github.com>
Sat, 12 Jun 2021 17:58:21 +0000 (19:58 +0200)
* [semsportal] Allow portal and station cofiguration with .things file

Signed-off-by: Iwan Bron <bron@olisa.eu>
* Fix README.md warning

Signed-off-by: Iwan Bron <bron@olisa.eu>
* Make thing type better visible in documentation

Signed-off-by: Iwan Bron <bron@olisa.eu>
Co-authored-by: Iwan Bron <bron@olisa.eu>
bundles/org.openhab.binding.semsportal/README.md
bundles/org.openhab.binding.semsportal/src/main/java/org/openhab/binding/semsportal/internal/PortalHandler.java
bundles/org.openhab.binding.semsportal/src/main/java/org/openhab/binding/semsportal/internal/SEMSPortalConfiguration.java
bundles/org.openhab.binding.semsportal/src/main/java/org/openhab/binding/semsportal/internal/StationHandler.java

index 1d6929a731cb6acb36f408295ebae957922c637e..2bc2b5c23b05c6bdba03e9743b80d0d774e490b7 100644 (file)
@@ -8,8 +8,8 @@ It requires a power station that is connected through the internet to the SEMS p
 ## Supported Things
 
 This binding provides two Thing types: a bridge to the SEMS Portal, and the Power Stations which are found at the Portal.
-The Portal (semsportal:portal) represents your account in the SEMS portal. 
-The Power Station (semsportal:station) is an installation of a Power Station or inverter that reports to the SEMS portal and is available to your account.
+The Portal (``semsportal:portal``) represents your account in the SEMS portal. 
+The Power Station (``semsportal:station``) is an installation of a Power Station or inverter that reports to the SEMS portal and is available to your account.
 
 ## Discovery
 
@@ -29,6 +29,24 @@ The default is 5 minutes.
 
 Power Stations have no settings and will be auto discovered when you add a Portal Bridge.
 
+If you prefer manual configuration of things in thing files, you need to supply the power station UUID.
+It can be found in the SEMS portal URL after you have logged in. 
+The URL will look like this:
+
+```
+https://www.semsportal.com/PowerStation/PowerStatusSnMin/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
+```
+
+Where the part after the last / character is the UUID to be used.
+
+Example portal configuration with a station:
+
+```
+Bridge semsportal:portal:myPortal [ username="my@username.com", password="MyPassword" ] {
+    station solarPanels "Solar Panels" [ stationUUID="xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ]
+}
+```
+
 ## Channels
 
 The Portal(Bridge) has no channels.
@@ -46,14 +64,21 @@ The Power Station Thing has the following channels:
 
 ## Parameters
 
-The PowerStation Thing has no parameters.
-Only the Bridge has the following configuration parameters:
+The Power Station Thing has no configuration parameters when auto discovered.
+When using thing files you need to provide the station UUID.
+
+
+| Parameter   | Required? | Description                                                                                                |
+| ----------- |:---------:| ---------------------------------------------------------------------------------------------------------- |
+| stationUUID | X         | UUID of the station. Can be found on the SEMS portal URL (see description above)                           |
+
+The Bridge has the following configuration parameters:
 
 | Parameter   | Required? | Description                                                                                                |
 | ----------- |:---------:| ---------------------------------------------------------------------------------------------------------- |
-| username    | X         | Account name (email address) at the SEMS portal. Account must have been used at least once to log in.       |
+| username    | X         | Account name (email address) at the SEMS portal. Account must have been used at least once to log in.      |
 | password    | X         | Password of the SEMS portal                                                                                |
-| update      |           | Number of minutes between two updates. Between 1 and 60 minutes, defaults to 5 minutes                     |
+| interval    |           | Number of minutes between two updates. Between 1 and 60 minutes, defaults to 5 minutes                     |
 
 ## Credits
 
index a51684490ef2e388c7d4ac2302fde1e7842f71f4..e51c96be046d47976bed7d40f63d2110449ac7db 100644 (file)
@@ -200,7 +200,7 @@ public class PortalHandler extends BaseBridgeHandler {
     }
 
     public long getUpdateInterval() {
-        return config.update;
+        return config.interval;
     }
 
     public List<Station> getAllStations() {
index 45035391007fadfa6d794daeb983e30cd627f621..19b5d8ecf9a235e58dbac69c5f3d1e50745e4bbc 100644 (file)
@@ -32,5 +32,5 @@ public class SEMSPortalConfiguration {
      */
     public String username = "";
     public String password = "";
-    public int update = SEMSPortalBindingConstants.DEFAULT_UPDATE_INTERVAL_MINUTES;
+    public int interval = SEMSPortalBindingConstants.DEFAULT_UPDATE_INTERVAL_MINUTES;
 }
index a2153276a94317f916b4081b2c81453b7eddbe0b..9da65c82752bf5619f13c375ae6eb6c97a3c2585 100644 (file)
@@ -156,6 +156,12 @@ public class StationHandler extends BaseThingHandler {
 
     private String getStationUUID() {
         String uuid = getThing().getProperties().get(STATION_UUID);
+        if (uuid == null) {
+            Object uuidObj = getThing().getConfiguration().get(STATION_UUID);
+            if (uuidObj instanceof String) {
+                uuid = (String) uuidObj;
+            }
+        }
         return uuid == null ? "" : uuid;
     }