]> git.basschouten.com Git - openhab-addons.git/commitdiff
[freeboxos] Add channels in group xdsl (#17260)
authorlolodomo <lg.hc@free.fr>
Thu, 15 Aug 2024 13:48:13 +0000 (15:48 +0200)
committerGitHub <noreply@github.com>
Thu, 15 Aug 2024 13:48:13 +0000 (15:48 +0200)
Follow-up #17219
Fixes #17073

* Category added
* Change ffth and xdsl group labels

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/FreeboxOsBindingConstants.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/ConnectionManager.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ServerHandler.java
bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/i18n/freeboxos.properties
bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/channel-types.xml
bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/server-channel-groups.xml
bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/update/instructions.xml

index 1493fcb07b72b9704d05dc6c88aea472b793369f..9c588c3343857355b2b8faf7ec0aa0aa4b36a0bd 100644 (file)
@@ -168,6 +168,12 @@ public class FreeboxOsBindingConstants {
     public static final String SFP_PWR_TX = "sfp-pwr-tx";
     public static final String SFP_PWR_RX = "sfp-pwr-rx";
 
+    // xDSL channels ids
+    public static final String XDSL_READY = "ready";
+    public static final String XDSL_STATUS = "status";
+    public static final String XDSL_MODULATION = "modulation";
+    public static final String XDSL_UPTIME = "uptime";
+
     // Home channels
     public static final String KEYFOB_ENABLE = "enable";
     public static final String NODE_BATTERY = "battery";
index 29524c489697b32df438c16040751f58366e8367..bb73b0b5ec04a0575ceb8f1ada0cb2a797c3283f 100644 (file)
@@ -107,7 +107,7 @@ public class ConnectionManager extends ConfigurableRest<ConnectionManager.Status
     ) {
     }
 
-    private enum SynchroState {
+    public enum SynchroState {
         DOWN, // unsynchronized
         TRAINING, // synchronizing step 1/4
         STARTED, // synchronizing step 2/4
@@ -118,18 +118,16 @@ public class ConnectionManager extends ConfigurableRest<ConnectionManager.Status
         UNKNOWN
     }
 
-    private enum Modulation {
+    public enum Modulation {
         ADSL,
         VDSL,
         UNKNOWN
     }
 
     public static record XdslStatus(SynchroState status, String protocol, Modulation modulation, long uptime) {
-
     }
 
     public static record XdslInfos(XdslStatus status, XdslStats down, XdslStats up) {
-
     }
 
     public ConnectionManager(FreeboxOsSession session) throws FreeboxException {
index f9de5055f2dfacbd4ea7aae7ec4cd761c01a17f9..5ba705ca7b9cae5410aa5d2e2b149c4f3327558f 100644 (file)
@@ -31,6 +31,8 @@ import org.openhab.binding.freeboxos.internal.api.rest.ConnectionManager;
 import org.openhab.binding.freeboxos.internal.api.rest.ConnectionManager.FtthStatus;
 import org.openhab.binding.freeboxos.internal.api.rest.ConnectionManager.Media;
 import org.openhab.binding.freeboxos.internal.api.rest.ConnectionManager.Status;
+import org.openhab.binding.freeboxos.internal.api.rest.ConnectionManager.SynchroState;
+import org.openhab.binding.freeboxos.internal.api.rest.ConnectionManager.XdslInfos;
 import org.openhab.binding.freeboxos.internal.api.rest.FtpManager;
 import org.openhab.binding.freeboxos.internal.api.rest.LanBrowserManager.Source;
 import org.openhab.binding.freeboxos.internal.api.rest.LanManager;
@@ -206,6 +208,13 @@ public class ServerHandler extends ApiConsumerHandler implements FreeDeviceIntf
             updateChannelQuantity(GROUP_FTTH, SFP_PWR_TX, ftthStatus.getTransmitDBM(), Units.DECIBEL_MILLIWATTS);
             updateChannelQuantity(GROUP_FTTH, SFP_PWR_RX, ftthStatus.getReceivedDBM(), Units.DECIBEL_MILLIWATTS);
         }
+        if (anyChannelLinked(GROUP_XDSL, Set.of(XDSL_READY, XDSL_STATUS, XDSL_MODULATION, XDSL_UPTIME))) {
+            XdslInfos xdslInfos = getManager(ConnectionManager.class).getXdslStatus();
+            updateChannelOnOff(GROUP_XDSL, XDSL_READY, xdslInfos.status().status() == SynchroState.SHOWTIME);
+            updateChannelString(GROUP_XDSL, XDSL_STATUS, xdslInfos.status().status());
+            updateChannelString(GROUP_XDSL, XDSL_MODULATION, xdslInfos.status().modulation());
+            updateChannelQuantity(GROUP_XDSL, XDSL_UPTIME, xdslInfos.status().uptime(), Units.SECOND);
+        }
     }
 
     private void updateRateBandwidth(long rate, long bandwidth, String orientation) {
index 85e0ed9f830c70320978210f3cbf92d1ddef58e3..33a32df880770e3557433acecc5bf9832f427eb5 100644 (file)
@@ -155,7 +155,7 @@ channel-group-type.freeboxos.connectivity.channel.last-seen.label = Last Activit
 channel-group-type.freeboxos.display.label = Front Display Panel
 channel-group-type.freeboxos.fans.label = Fans
 channel-group-type.freeboxos.file-sharing.label = File Sharing
-channel-group-type.freeboxos.ftth.label = FTTH Connection Status
+channel-group-type.freeboxos.ftth.label = FTTH Connection Details
 channel-group-type.freeboxos.ftth.channel.sfp-pwr-rx.label = RX Power
 channel-group-type.freeboxos.ftth.channel.sfp-pwr-rx.description = SFP Power in reception
 channel-group-type.freeboxos.ftth.channel.sfp-pwr-tx.label = TX Power
@@ -199,7 +199,8 @@ channel-group-type.freeboxos.wifi.channel.rate-down.label = Rx Rate
 channel-group-type.freeboxos.wifi.channel.rate-down.description = Current RX rate
 channel-group-type.freeboxos.wifi.channel.rate-up.label = Tx Rate
 channel-group-type.freeboxos.wifi.channel.rate-up.description = Current TX Rate
-channel-group-type.freeboxos.xdsl.label = xDSL Connection Status
+channel-group-type.freeboxos.xdsl.label = xDSL Connection Details
+channel-group-type.freeboxos.xdsl.channel.uptime.description = Time since last synchronization
 
 # channel types
 
@@ -364,6 +365,18 @@ channel-type.freeboxos.uptime.state.pattern = %1$tdd %1$tHh %1$tMm %1$tSs
 channel-type.freeboxos.wifi-host.label = Access Point
 channel-type.freeboxos.wifi-status.label = Wifi Enabled
 channel-type.freeboxos.wifi-status.description = Indicates whether the wifi network is enabled
+channel-type.freeboxos.xdsl-modulation.label = Modulation
+channel-type.freeboxos.xdsl-ready.label = Ready
+channel-type.freeboxos.xdsl-ready.description = ON when xDSL line connection is synchronized
+channel-type.freeboxos.xdsl-status.label = Line Status
+channel-type.freeboxos.xdsl-status.description = Status of xDSL line connection
+channel-type.freeboxos.xdsl-status.state.option.DOWN = Unsynchronized
+channel-type.freeboxos.xdsl-status.state.option.TRAINING = Synchronizing step 1/4
+channel-type.freeboxos.xdsl-status.state.option.STARTED = Synchronizing step 2/4
+channel-type.freeboxos.xdsl-status.state.option.CHAN_ANALYSIS = Synchronizing step 3/4
+channel-type.freeboxos.xdsl-status.state.option.MSG_EXCHANGE = Synchronizing step 4/4
+channel-type.freeboxos.xdsl-status.state.option.SHOWTIME = Synchronized
+channel-type.freeboxos.xdsl-status.state.option.DISABLED = Disabled
 
 # messages
 
index 6318a0874798cc360cbedb943e4d697e79753f54..65c6dd67949d7d96a58991c59c55d4386465ad1f 100644 (file)
                <state readOnly="true" pattern="%.2f dBm"/>
        </channel-type>
 
+       <channel-type id="xdsl-ready">
+               <item-type>Switch</item-type>
+               <label>Ready</label>
+               <description>ON when xDSL line connection is synchronized</description>
+               <category>Switch</category>
+               <state readOnly="true"/>
+       </channel-type>
+
+       <channel-type id="xdsl-status" advanced="true">
+               <item-type>String</item-type>
+               <label>Line Status</label>
+               <description>Status of xDSL line connection</description>
+               <state readOnly="true" pattern="%s">
+                       <options>
+                               <option value="DOWN">Unsynchronized</option>
+                               <option value="TRAINING">Synchronizing step 1/4</option>
+                               <option value="STARTED">Synchronizing step 2/4</option>
+                               <option value="CHAN_ANALYSIS">Synchronizing step 3/4</option>
+                               <option value="MSG_EXCHANGE">Synchronizing step 4/4</option>
+                               <option value="SHOWTIME">Synchronized</option>
+                               <option value="DISABLED">Disabled</option>
+                       </options>
+               </state>
+       </channel-type>
+
+       <channel-type id="xdsl-modulation" advanced="true">
+               <item-type>String</item-type>
+               <label>Modulation</label>
+               <state readOnly="true"/>
+       </channel-type>
+
 </thing:thing-descriptions>
index 718522ab00879403838366845772ec38151205f6..4d54daf1b5d2911dd8ec06d5ec861b7204cdb1b3 100644 (file)
@@ -53,7 +53,7 @@
        </channel-group-type>
 
        <channel-group-type id="ftth">
-               <label>FTTH Connection Status</label>
+               <label>FTTH Connection Details</label>
                <channels>
                        <channel id="sfp-present" typeId="sfp-present"/>
                        <channel id="sfp-alim-ok" typeId="sfp-alim-ok"/>
        </channel-group-type>
 
        <channel-group-type id="xdsl">
-               <label>xDSL Connection Status</label>
+               <label>xDSL Connection Details</label>
                <channels>
-                       <channel id="status" typeId="status"/>
-                       <!-- to be completed -->
+                       <channel id="ready" typeId="xdsl-ready"/>
+                       <channel id="status" typeId="xdsl-status"/>
+                       <channel id="modulation" typeId="xdsl-modulation"/>
+                       <channel id="uptime" typeId="uptime">
+                               <description>Time since last synchronization</description>
+                       </channel>
                </channels>
        </channel-group-type>
 
index 6c55043af4c41094d71de36993413979c0ba7048..8de3e5be224200ceb1fc5aa25ba6542d5231e482 100644 (file)
                                <label>RX Power</label>
                                <description>SFP Power in reception</description>
                        </add-channel>
+                       <add-channel id="ready" groupIds="xdsl">
+                               <type>freeboxos:xdsl-ready</type>
+                       </add-channel>
+                       <add-channel id="status" groupIds="xdsl">
+                               <type>freeboxos:xdsl-status</type>
+                       </add-channel>
+                       <add-channel id="modulation" groupIds="xdsl">
+                               <type>freeboxos:xdsl-modulation</type>
+                       </add-channel>
+                       <add-channel id="uptime" groupIds="xdsl">
+                               <type>freeboxos:uptime</type>
+                               <description>Time since last synchronization</description>
+                       </add-channel>
                </instruction-set>
 
        </thing-type>
                                <label>RX Power</label>
                                <description>SFP Power in reception</description>
                        </add-channel>
+                       <add-channel id="ready" groupIds="xdsl">
+                               <type>freeboxos:xdsl-ready</type>
+                       </add-channel>
+                       <add-channel id="status" groupIds="xdsl">
+                               <type>freeboxos:xdsl-status</type>
+                       </add-channel>
+                       <add-channel id="modulation" groupIds="xdsl">
+                               <type>freeboxos:xdsl-modulation</type>
+                       </add-channel>
+                       <add-channel id="uptime" groupIds="xdsl">
+                               <type>freeboxos:uptime</type>
+                               <description>Time since last synchronization</description>
+                       </add-channel>
                </instruction-set>
 
        </thing-type>