diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/FreeboxOsBindingConstants.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/FreeboxOsBindingConstants.java index f9042be5c3b..1493fcb07b7 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/FreeboxOsBindingConstants.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/FreeboxOsBindingConstants.java @@ -86,7 +86,7 @@ public class FreeboxOsBindingConstants { public static final String LOCAL = "local"; public static final String FULL_DUPLEX = "fullDuplex"; - // List of all Group Channel ids + // List of all Channel Groups ids public static final String GROUP_SENSORS = "sensors"; public static final String GROUP_FANS = "fans"; public static final String GROUP_CONNECTION_STATUS = "connection-status"; @@ -99,6 +99,8 @@ public class FreeboxOsBindingConstants { public static final String GROUP_VM_STATUS = "vmstatus"; public static final String GROUP_WIFI = "wifi"; public static final String GROUP_REPEATER_MISC = "repeater-misc"; + public static final String GROUP_XDSL = "xdsl"; + public static final String GROUP_FTTH = "ftth"; // List of all Channel ids public static final String RSSI = "rssi"; @@ -157,6 +159,15 @@ public class FreeboxOsBindingConstants { public static final String LED = "led"; public static final String HOST_COUNT = "host-count"; + // FTTH channels ids + public static final String SFP_PRESENT = "sfp-present"; + public static final String SFP_ALIM = "sfp-alim-ok"; + public static final String SFP_POWER = "sfp-has-power"; + public static final String SFP_SIGNAL = "sfp-has-signal"; + public static final String SFP_LINK = "link"; + public static final String SFP_PWR_TX = "sfp-pwr-tx"; + public static final String SFP_PWR_RX = "sfp-pwr-rx"; + // Home channels public static final String KEYFOB_ENABLE = "enable"; public static final String NODE_BATTERY = "battery"; diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/ConnectionManager.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/ConnectionManager.java index a97f7c5ddfa..29524c48969 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/ConnectionManager.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/ConnectionManager.java @@ -35,6 +35,12 @@ public class ConnectionManager extends ConfigurableRest { } + private class FtthStatusResponse extends Response { + } + + private class XdslStatusResponse extends Response { + } + private enum State { GOING_UP, UP, @@ -50,7 +56,7 @@ public class ConnectionManager extends ConfigurableRest properties) throws FreeboxException { LanConfig lanConfig = getManager(LanManager.class).getConfig(); Config config = getManager(SystemManager.class).getConfig(); + properties.put(Thing.PROPERTY_SERIAL_NUMBER, config.serial()); properties.put(Thing.PROPERTY_FIRMWARE_VERSION, config.firmwareVersion()); properties.put(Thing.PROPERTY_HARDWARE_VERSION, config.modelInfo().prettyName()); @@ -82,7 +85,13 @@ public class ServerHandler extends ApiConsumerHandler implements FreeDeviceIntf properties.put(Source.UPNP.name(), lanConfig.name()); List channels = new ArrayList<>(getThing().getChannels()); - int nbInit = channels.size(); + + // Remove channels of the not active media type + Status connectionConfig = getManager(ConnectionManager.class).getConfig(); + channels.removeIf(c -> (GROUP_FTTH.equals(c.getUID().getGroupId()) && connectionConfig.media() != Media.FTTH) + || (GROUP_XDSL.equals(c.getUID().getGroupId()) && connectionConfig.media() != Media.XDSL)); + + // Add temperature sensors config.sensors().forEach(sensor -> { ChannelUID sensorId = new ChannelUID(thing.getUID(), GROUP_SENSORS, sensor.id()); if (getThing().getChannel(sensorId) == null) { @@ -96,6 +105,8 @@ public class ServerHandler extends ApiConsumerHandler implements FreeDeviceIntf .withType(new ChannelTypeUID(BINDING_ID, "temperature")).build()); } }); + + // Add fans sensors config.fans().forEach(sensor -> { ChannelUID sensorId = new ChannelUID(thing.getUID(), GROUP_FANS, sensor.id()); if (getThing().getChannel(sensorId) == null) { @@ -104,9 +115,9 @@ public class ServerHandler extends ApiConsumerHandler implements FreeDeviceIntf .build()); } }); - if (nbInit != channels.size()) { - updateThing(editThing().withChannels(channels).build()); - } + + // And finally update the thing with appropriate channels + updateThing(editThing().withChannels(channels).build()); } @Override @@ -163,7 +174,6 @@ public class ServerHandler extends ApiConsumerHandler implements FreeDeviceIntf updateChannelString(GROUP_CONNECTION_STATUS, LINE_MEDIA, status.media()); updateChannelString(GROUP_CONNECTION_STATUS, IP_ADDRESS, status.ipv4()); updateChannelString(GROUP_CONNECTION_STATUS, IPV6_ADDRESS, status.ipv6()); - updateRateBandwidth(status.rateUp(), status.bandwidthUp(), "up"); updateRateBandwidth(status.rateDown(), status.bandwidthDown(), "down"); @@ -172,6 +182,17 @@ public class ServerHandler extends ApiConsumerHandler implements FreeDeviceIntf updateChannelQuantity(GROUP_CONNECTION_STATUS, BYTES_DOWN, new QuantityType<>(status.bytesDown(), OCTET), GIBIOCTET); } + if (anyChannelLinked(GROUP_FTTH, + Set.of(SFP_PRESENT, SFP_ALIM, SFP_POWER, SFP_SIGNAL, SFP_LINK, SFP_PWR_TX, SFP_PWR_RX))) { + FtthStatus ftthStatus = getManager(ConnectionManager.class).getFtthStatus(); + updateChannelOnOff(GROUP_FTTH, SFP_PRESENT, ftthStatus.sfpPresent()); + updateChannelOnOff(GROUP_FTTH, SFP_ALIM, ftthStatus.sfpAlimOk()); + updateChannelOnOff(GROUP_FTTH, SFP_POWER, ftthStatus.sfpHasPowerReport()); + updateChannelOnOff(GROUP_FTTH, SFP_SIGNAL, ftthStatus.sfpHasSignal()); + updateChannelOnOff(GROUP_FTTH, SFP_LINK, ftthStatus.link()); + updateChannelQuantity(GROUP_FTTH, SFP_PWR_TX, ftthStatus.getTransmitDBM(), Units.DECIBEL_MILLIWATTS); + updateChannelQuantity(GROUP_FTTH, SFP_PWR_RX, ftthStatus.getReceivedDBM(), Units.DECIBEL_MILLIWATTS); + } } private void updateRateBandwidth(long rate, long bandwidth, String orientation) { diff --git a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/i18n/freeboxos.properties b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/i18n/freeboxos.properties index c03e3084de8..85e0ed9f830 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/i18n/freeboxos.properties +++ b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/i18n/freeboxos.properties @@ -155,6 +155,11 @@ 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.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 +channel-group-type.freeboxos.ftth.channel.sfp-pwr-tx.description = SFP Power in transmission channel-group-type.freeboxos.incoming.label = Incoming Call channel-group-type.freeboxos.incoming.description = Currently presented phone call channel-group-type.freeboxos.incoming.channel.name.label = Incoming Caller @@ -194,6 +199,7 @@ 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 types @@ -306,6 +312,7 @@ channel-type.freeboxos.line-type.description = Type of network line connection channel-type.freeboxos.line-type.state.option.ETHERNET = FTTH/ethernet channel-type.freeboxos.line-type.state.option.RFC2684 = xDSL (unbundled) channel-type.freeboxos.line-type.state.option.PPPOATM = xDSL +channel-type.freeboxos.link.label = Link Is Active channel-type.freeboxos.name.label = Name channel-type.freeboxos.name.description = Called name for outgoing calls. Caller name for incoming calls channel-type.freeboxos.number.label = Incoming Call @@ -329,6 +336,11 @@ channel-type.freeboxos.samba-file-status.label = Windows File Sharing channel-type.freeboxos.samba-file-status.description = Status of Windows File Sharing (Samba) channel-type.freeboxos.samba-printer-status.label = Windows Printer Sharing channel-type.freeboxos.samba-printer-status.description = Status of Windows Printer Sharing +channel-type.freeboxos.sfp-alim-ok.label = Alimentation Ok +channel-type.freeboxos.sfp-has-power.label = Power Available +channel-type.freeboxos.sfp-has-signal.label = Signal Present +channel-type.freeboxos.sfp-present.label = SFP Present +channel-type.freeboxos.sfp-signal-level.label = Signal Level channel-type.freeboxos.shutter.label = Shutter Position channel-type.freeboxos.shutter.description = Read / Write position of the shutter channel-type.freeboxos.ssid.label = SSID @@ -348,6 +360,7 @@ channel-type.freeboxos.upnpav-status.label = UPnP AV Enabled channel-type.freeboxos.upnpav-status.description = Indicates whether UPnP AV is enabled channel-type.freeboxos.uptime.label = Uptime channel-type.freeboxos.uptime.description = Time since last reboot of the equipment +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 diff --git a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/channel-types.xml b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/channel-types.xml index a6003622147..283b64aaa56 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/channel-types.xml +++ b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/channel-types.xml @@ -461,4 +461,46 @@ + + Switch + + Switch + + + + + Switch + + Switch + + + + + Switch + + Switch + + + + + Switch + + Switch + + + + + Switch + + Switch + + + + + Number:Power + + QualityOfService + + + diff --git a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/server-channel-groups.xml b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/server-channel-groups.xml index 50ed9b4a6f7..718522ab008 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/server-channel-groups.xml +++ b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/server-channel-groups.xml @@ -52,6 +52,34 @@ + + + + + + + + + + + SFP Power in transmission + + + + SFP Power in reception + + + + + + + + + + + + + diff --git a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/server-thing-type.xml b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/server-thing-type.xml index 1e5538cf3e8..d7577dcbd32 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/server-thing-type.xml +++ b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/server-thing-type.xml @@ -20,8 +20,14 @@ + + + + 1 + + macAddress @@ -42,8 +48,14 @@ + + + + 1 + + macAddress diff --git a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/update/instructions.xml b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/update/instructions.xml index 770fa5fb0b7..6c55043af4c 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/update/instructions.xml +++ b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/update/instructions.xml @@ -26,4 +26,67 @@ + + + + + freeboxos:sfp-present + + + freeboxos:sfp-alim-ok + + + freeboxos:sfp-has-power + + + freeboxos:sfp-has-signal + + + freeboxos:link + + + freeboxos:sfp-signal-level + + SFP Power in transmission + + + freeboxos:sfp-signal-level + + SFP Power in reception + + + + + + + + + + freeboxos:sfp-present + + + freeboxos:sfp-alim-ok + + + freeboxos:sfp-has-power + + + freeboxos:sfp-has-signal + + + freeboxos:link + + + freeboxos:sfp-signal-level + + SFP Power in transmission + + + freeboxos:sfp-signal-level + + SFP Power in reception + + + +