From: Iwan Bron <44524316+itb3@users.noreply.github.com> Date: Sat, 12 Jun 2021 17:58:21 +0000 (+0200) Subject: [semsportal] Allow confiuration with thing file (#10842) X-Git-Url: https://git.basschouten.com/?a=commitdiff_plain;h=cb256f6676d85c014c74d3f7b1705a8e96d507ec;p=openhab-addons.git [semsportal] Allow confiuration with thing file (#10842) * [semsportal] Allow portal and station cofiguration with .things file Signed-off-by: Iwan Bron * Fix README.md warning Signed-off-by: Iwan Bron * Make thing type better visible in documentation Signed-off-by: Iwan Bron Co-authored-by: Iwan Bron --- diff --git a/bundles/org.openhab.binding.semsportal/README.md b/bundles/org.openhab.binding.semsportal/README.md index 1d6929a731..2bc2b5c23b 100644 --- a/bundles/org.openhab.binding.semsportal/README.md +++ b/bundles/org.openhab.binding.semsportal/README.md @@ -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 diff --git a/bundles/org.openhab.binding.semsportal/src/main/java/org/openhab/binding/semsportal/internal/PortalHandler.java b/bundles/org.openhab.binding.semsportal/src/main/java/org/openhab/binding/semsportal/internal/PortalHandler.java index a51684490e..e51c96be04 100644 --- a/bundles/org.openhab.binding.semsportal/src/main/java/org/openhab/binding/semsportal/internal/PortalHandler.java +++ b/bundles/org.openhab.binding.semsportal/src/main/java/org/openhab/binding/semsportal/internal/PortalHandler.java @@ -200,7 +200,7 @@ public class PortalHandler extends BaseBridgeHandler { } public long getUpdateInterval() { - return config.update; + return config.interval; } public List getAllStations() { diff --git a/bundles/org.openhab.binding.semsportal/src/main/java/org/openhab/binding/semsportal/internal/SEMSPortalConfiguration.java b/bundles/org.openhab.binding.semsportal/src/main/java/org/openhab/binding/semsportal/internal/SEMSPortalConfiguration.java index 4503539100..19b5d8ecf9 100644 --- a/bundles/org.openhab.binding.semsportal/src/main/java/org/openhab/binding/semsportal/internal/SEMSPortalConfiguration.java +++ b/bundles/org.openhab.binding.semsportal/src/main/java/org/openhab/binding/semsportal/internal/SEMSPortalConfiguration.java @@ -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; } diff --git a/bundles/org.openhab.binding.semsportal/src/main/java/org/openhab/binding/semsportal/internal/StationHandler.java b/bundles/org.openhab.binding.semsportal/src/main/java/org/openhab/binding/semsportal/internal/StationHandler.java index a2153276a9..9da65c8275 100644 --- a/bundles/org.openhab.binding.semsportal/src/main/java/org/openhab/binding/semsportal/internal/StationHandler.java +++ b/bundles/org.openhab.binding.semsportal/src/main/java/org/openhab/binding/semsportal/internal/StationHandler.java @@ -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; }