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";
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";
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";
protected static class StatusResponse extends Response<Status> {
}
+ private class FtthStatusResponse extends Response<FtthStatus> {
+ }
+
+ private class XdslStatusResponse extends Response<XdslInfos> {
+ }
+
private enum State {
GOING_UP,
UP,
UNKNOWN
}
- private enum Media {
+ public enum Media {
FTTH,
ETHERNET,
XDSL,
) {
}
+ public static record FtthStatus(boolean sfpPresent, boolean sfpAlimOk, boolean sfpHasPowerReport,
+ boolean sfpHasSignal, boolean link, String sfpSerial, String sfpModel, String sfpVendor, //
+ int sfpPwrTx, // scaled by 100 (in dBm)
+ int sfpPwrRx // scaled by 100 (in dBm)
+ ) {
+ public double getReceivedDBM() {
+ return 1d * sfpPwrRx / 100;
+ }
+
+ public double getTransmitDBM() {
+ return 1d * sfpPwrTx / 100;
+ }
+ }
+
+ public static record XdslStats( //
+ int maxrate, // ATM max rate in kbit/s
+ int rate, // ATM rate in kbit/s
+ int snr, // in dB
+ int attn, // in dB
+ int snr10, // in dB/10
+ int attn10, // in dB/10
+ int fec, int crc, int hec, int es, int ses, boolean phyr, boolean ginp, boolean nitro, //
+ int rxmt, // only available when phyr is on
+ int rxmtCorr, // only available when phyr is on
+ int rxmtUncorr, // only available when phyr is on
+ int rtxTx, // only available when ginp is on
+ int rtxC, // only available when ginp is on
+ int rtxUc// only available when ginp is on
+ ) {
+ }
+
+ private enum SynchroState {
+ DOWN, // unsynchronized
+ TRAINING, // synchronizing step 1/4
+ STARTED, // synchronizing step 2/4
+ CHAN_ANALYSIS, // synchronizing step 3/4
+ MSG_EXCHANGE, // synchronizing step 4/4
+ SHOWTIME, // Ready
+ DISABLED, // Disabled
+ UNKNOWN
+ }
+
+ private 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 {
super(session, LoginManager.Permission.NONE, StatusResponse.class, session.getUriBuilder().path(PATH), null);
}
+
+ public FtthStatus getFtthStatus() throws FreeboxException {
+ return super.getSingle(FtthStatusResponse.class, "ftth");
+ }
+
+ public XdslInfos getXdslStatus() throws FreeboxException {
+ return super.getSingle(XdslStatusResponse.class, "xdsl");
+ }
}
import org.openhab.binding.freeboxos.internal.api.rest.AfpManager;
import org.openhab.binding.freeboxos.internal.api.rest.AirMediaManager;
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.FtpManager;
import org.openhab.binding.freeboxos.internal.api.rest.LanBrowserManager.Source;
void initializeProperties(Map<String, String> 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());
properties.put(Source.UPNP.name(), lanConfig.name());
List<Channel> 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) {
.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) {
.build());
}
});
- if (nbInit != channels.size()) {
- updateThing(editThing().withChannels(channels).build());
- }
+
+ // And finally update the thing with appropriate channels
+ updateThing(editThing().withChannels(channels).build());
}
@Override
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");
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) {
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
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
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
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
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
<state pattern="%s"/>
</channel-type>
+ <channel-type id="sfp-present">
+ <item-type>Switch</item-type>
+ <label>SFP Present</label>
+ <category>Switch</category>
+ <state readOnly="true"/>
+ </channel-type>
+
+ <channel-type id="sfp-alim-ok">
+ <item-type>Switch</item-type>
+ <label>Alimentation Ok</label>
+ <category>Switch</category>
+ <state readOnly="true"/>
+ </channel-type>
+
+ <channel-type id="sfp-has-power">
+ <item-type>Switch</item-type>
+ <label>Power Available</label>
+ <category>Switch</category>
+ <state readOnly="true"/>
+ </channel-type>
+
+ <channel-type id="sfp-has-signal">
+ <item-type>Switch</item-type>
+ <label>Signal Present</label>
+ <category>Switch</category>
+ <state readOnly="true"/>
+ </channel-type>
+
+ <channel-type id="link">
+ <item-type>Switch</item-type>
+ <label>Link Is Active</label>
+ <category>Switch</category>
+ <state readOnly="true"/>
+ </channel-type>
+
+ <channel-type id="sfp-signal-level">
+ <item-type unitHint="dBm">Number:Power</item-type>
+ <label>Signal Level</label>
+ <category>QualityOfService</category>
+ <state readOnly="true" pattern="%.2f dBm"/>
+ </channel-type>
+
</thing:thing-descriptions>
</channels>
</channel-group-type>
+ <channel-group-type id="ftth">
+ <label>FTTH Connection Status</label>
+ <channels>
+ <channel id="sfp-present" typeId="sfp-present"/>
+ <channel id="sfp-alim-ok" typeId="sfp-alim-ok"/>
+ <channel id="sfp-has-power" typeId="sfp-has-power"/>
+ <channel id="sfp-has-signal" typeId="sfp-has-signal"/>
+ <channel id="link" typeId="link"/>
+ <channel id="sfp-pwr-tx" typeId="sfp-signal-level">
+ <label>TX Power</label>
+ <description>SFP Power in transmission</description>
+ </channel>
+ <channel id="sfp-pwr-rx" typeId="sfp-signal-level">
+ <label>RX Power</label>
+ <description>SFP Power in reception</description>
+ </channel>
+ </channels>
+ </channel-group-type>
+
+ <channel-group-type id="xdsl">
+ <label>xDSL Connection Status</label>
+ <channels>
+ <channel id="status" typeId="status"/>
+ <!-- to be completed -->
+ </channels>
+ </channel-group-type>
+
+
<channel-group-type id="connection-status">
<label>Connection Status Details</label>
<channels>
<channel-group typeId="sysinfo" id="sysinfo"/>
<channel-group typeId="actions" id="actions"/>
<channel-group typeId="connection-status" id="connection-status"/>
+ <channel-group typeId="ftth" id="ftth"/>
+ <channel-group typeId="xdsl" id="xdsl"/>
</channel-groups>
+ <properties>
+ <property name="thingTypeVersion">1</property>
+ </properties>
+
<representation-property>macAddress</representation-property>
<config-description-ref uri="thing-type:freeboxos:server"/>
<channel-group typeId="sysinfo" id="sysinfo"/>
<channel-group typeId="actions" id="actions"/>
<channel-group typeId="connection-status" id="connection-status"/>
+ <channel-group typeId="ftth" id="ftth"/>
+ <channel-group typeId="xdsl" id="xdsl"/>
</channel-groups>
+ <properties>
+ <property name="thingTypeVersion">1</property>
+ </properties>
+
<representation-property>macAddress</representation-property>
<config-description-ref uri="thing-type:freeboxos:server"/>
</thing-type>
+ <thing-type uid="freeboxos:delta">
+
+ <instruction-set targetVersion="1">
+ <add-channel id="sfp-present" groupIds="ftth">
+ <type>freeboxos:sfp-present</type>
+ </add-channel>
+ <add-channel id="sfp-alim-ok" groupIds="ftth">
+ <type>freeboxos:sfp-alim-ok</type>
+ </add-channel>
+ <add-channel id="sfp-has-power" groupIds="ftth">
+ <type>freeboxos:sfp-has-power</type>
+ </add-channel>
+ <add-channel id="sfp-has-signal" groupIds="ftth">
+ <type>freeboxos:sfp-has-signal</type>
+ </add-channel>
+ <add-channel id="link" groupIds="ftth">
+ <type>freeboxos:link</type>
+ </add-channel>
+ <add-channel id="sfp-pwr-tx" groupIds="ftth">
+ <type>freeboxos:sfp-signal-level</type>
+ <label>TX Power</label>
+ <description>SFP Power in transmission</description>
+ </add-channel>
+ <add-channel id="sfp-pwr-rx" groupIds="ftth">
+ <type>freeboxos:sfp-signal-level</type>
+ <label>RX Power</label>
+ <description>SFP Power in reception</description>
+ </add-channel>
+ </instruction-set>
+
+ </thing-type>
+
+ <thing-type uid="freeboxos:revolution">
+
+ <instruction-set targetVersion="1">
+ <add-channel id="sfp-present" groupIds="ftth">
+ <type>freeboxos:sfp-present</type>
+ </add-channel>
+ <add-channel id="sfp-alim-ok" groupIds="ftth">
+ <type>freeboxos:sfp-alim-ok</type>
+ </add-channel>
+ <add-channel id="sfp-has-power" groupIds="ftth">
+ <type>freeboxos:sfp-has-power</type>
+ </add-channel>
+ <add-channel id="sfp-has-signal" groupIds="ftth">
+ <type>freeboxos:sfp-has-signal</type>
+ </add-channel>
+ <add-channel id="link" groupIds="ftth">
+ <type>freeboxos:link</type>
+ </add-channel>
+ <add-channel id="sfp-pwr-tx" groupIds="ftth">
+ <type>freeboxos:sfp-signal-level</type>
+ <label>TX Power</label>
+ <description>SFP Power in transmission</description>
+ </add-channel>
+ <add-channel id="sfp-pwr-rx" groupIds="ftth">
+ <type>freeboxos:sfp-signal-level</type>
+ <label>RX Power</label>
+ <description>SFP Power in reception</description>
+ </add-channel>
+ </instruction-set>
+
+ </thing-type>
</update:update-descriptions>