]> git.basschouten.com Git - openhab-addons.git/commitdiff
Add UoM support for RSSI channel (#14319)
authorJacob Laursen <jacob-github@vindvejr.dk>
Sat, 4 Feb 2023 08:52:22 +0000 (09:52 +0100)
committerGitHub <noreply@github.com>
Sat, 4 Feb 2023 08:52:22 +0000 (09:52 +0100)
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
bundles/org.openhab.binding.unifi/README.md
bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/handler/UniFiClientThingHandler.java
bundles/org.openhab.binding.unifi/src/main/resources/OH-INF/thing/thing-types.xml

index 6eeebae1ce86e9bd232f944b8c3dca576a166271..b2c70edf7e1005cecbe099ab3cbf30bd383dbd27 100644 (file)
@@ -176,7 +176,7 @@ The `wirelessClient` information that is retrieved is available as these channel
 | guest      | Switch               | On if this is a guest client                                         | Read        |
 | ap         | String               | Access point (AP) the client is connected to                         | Read        |
 | essid      | String               | Network name (ESSID) the client is connected to                      | Read        |
-| rssi       | Number               | Received signal strength indicator (RSSI) of the client              | Read        |
+| rssi       | Number:Power         | Received signal strength indicator (RSSI) of the client              | Read        |
 | uptime     | Number:Time          | Uptime of the client (in seconds)                                    | Read        |
 | lastSeen   | DateTime             | Date and Time the client was last seen                               | Read        |
 | experience | Number:Dimensionless | Overall health indication of the client (in percentage)              | Read        |
@@ -247,17 +247,17 @@ Replace `$user`, `$password` and `$cid` accordingly.
 items/unifi.items
 
 ```
-Switch      MatthewsPhone           "Matthew's iPhone [MAP(unifi.map):%s]"             { channel="unifi:wirelessClient:home:matthewsPhone:online" }
-String      MatthewsPhoneSite       "Matthew's iPhone: Site [%s]"                      { channel="unifi:wirelessClient:home:matthewsPhone:site" }
-String      MatthewsPhoneMAC        "Matthew's iPhone: MAC [%s]"                       { channel="unifi:wirelessClient:home:matthewsPhone:macAddress" }
-String      MatthewsPhoneIP         "Matthew's iPhone: IP [%s]"                        { channel="unifi:wirelessClient:home:matthewsPhone:ipAddress" }
-String      MatthewsPhoneAP         "Matthew's iPhone: AP [%s]"                        { channel="unifi:wirelessClient:home:matthewsPhone:ap" }
-String      MatthewsPhoneESSID      "Matthew's iPhone: ESSID [%s]"                     { channel="unifi:wirelessClient:home:matthewsPhone:essid" }
-Number      MatthewsPhoneRSSI       "Matthew's iPhone: RSSI [%d]"                      { channel="unifi:wirelessClient:home:matthewsPhone:rssi" }
-Number:Time MatthewsPhoneUptime     "Matthew's iPhone: Uptime [%1$tR]"                 { channel="unifi:wirelessClient:home:matthewsPhone:uptime" }
-DateTime    MatthewsPhoneLastSeen   "Matthew's iPhone: Last Seen [%1$tH:%1$tM:%1$tS]"  { channel="unifi:wirelessClient:home:matthewsPhone:lastSeen" }
-Switch      MatthewsPhoneBlocked    "Matthew's iPhone: Blocked"                        { channel="unifi:wirelessClient:home:matthewsPhone:blocked" }
-Switch      MatthewsPhoneReconnect  "Matthew's iPhone: Reconnect"                      { channel="unifi:wirelessClient:home:matthewsPhone:reconnect" }
+Switch       MatthewsPhone           "Matthew's iPhone [MAP(unifi.map):%s]"             { channel="unifi:wirelessClient:home:matthewsPhone:online" }
+String       MatthewsPhoneSite       "Matthew's iPhone: Site [%s]"                      { channel="unifi:wirelessClient:home:matthewsPhone:site" }
+String       MatthewsPhoneMAC        "Matthew's iPhone: MAC [%s]"                       { channel="unifi:wirelessClient:home:matthewsPhone:macAddress" }
+String       MatthewsPhoneIP         "Matthew's iPhone: IP [%s]"                        { channel="unifi:wirelessClient:home:matthewsPhone:ipAddress" }
+String       MatthewsPhoneAP         "Matthew's iPhone: AP [%s]"                        { channel="unifi:wirelessClient:home:matthewsPhone:ap" }
+String       MatthewsPhoneESSID      "Matthew's iPhone: ESSID [%s]"                     { channel="unifi:wirelessClient:home:matthewsPhone:essid" }
+Number:Power MatthewsPhoneRSSI       "Matthew's iPhone: RSSI [%d dBm]"                  { channel="unifi:wirelessClient:home:matthewsPhone:rssi" }
+Number:Time  MatthewsPhoneUptime     "Matthew's iPhone: Uptime [%1$tR]"                 { channel="unifi:wirelessClient:home:matthewsPhone:uptime" }
+DateTime     MatthewsPhoneLastSeen   "Matthew's iPhone: Last Seen [%1$tH:%1$tM:%1$tS]"  { channel="unifi:wirelessClient:home:matthewsPhone:lastSeen" }
+Switch       MatthewsPhoneBlocked    "Matthew's iPhone: Blocked"                        { channel="unifi:wirelessClient:home:matthewsPhone:blocked" }
+Switch       MatthewsPhoneReconnect  "Matthew's iPhone: Reconnect"                      { channel="unifi:wirelessClient:home:matthewsPhone:reconnect" }
 ```
 
 transform/unifi.map
index cf1be9bc9c8669497c70db9ea6cb6ac46b131798..7b725657c8971483c9e83a878bd84a543ccb4573 100644 (file)
@@ -48,7 +48,6 @@ import org.openhab.binding.unifi.internal.api.dto.UniFiSite;
 import org.openhab.binding.unifi.internal.api.dto.UniFiWiredClient;
 import org.openhab.binding.unifi.internal.api.dto.UniFiWirelessClient;
 import org.openhab.core.library.types.DateTimeType;
-import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.QuantityType;
 import org.openhab.core.library.types.StringType;
@@ -286,7 +285,7 @@ public class UniFiClientThingHandler extends UniFiBaseThingHandler<UniFiClient,
             // :rssi
             case CHANNEL_RSSI:
                 if (client.getRssi() != null) {
-                    state = new DecimalType(client.getRssi());
+                    state = new QuantityType<>(client.getRssi(), Units.DECIBEL_MILLIWATTS);
                 }
                 break;
 
index bce8ac886dfd5e908d8a417a531b1380f621d1ef..1200299420df953551b8fe59d8abf32f24bd25bc 100644 (file)
        </channel-type>
 
        <channel-type id="rssi">
-               <item-type>Number</item-type>
+               <item-type>Number:Power</item-type>
                <label>Received Signal Strength Indicator</label>
                <description>Received Signal Strength Indicator (RSSI) of the wireless client</description>
-               <state readOnly="true"></state>
+               <category>QualityOfService</category>
+               <state readOnly="true" pattern="%d %unit%"></state>
        </channel-type>
 
        <channel-type id="blocked">