mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[freeboxos] Add FTTH and xDSL line status (#17219)
* Adding FTTH line status, initiating the addition of xDSL line status Signed-off-by: Gaël L'hopital <gael@lhopital.org> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
795f797ab7
commit
24d1b4c06e
@ -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";
|
||||
|
@ -35,6 +35,12 @@ public class ConnectionManager extends ConfigurableRest<ConnectionManager.Status
|
||||
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,
|
||||
@ -50,7 +56,7 @@ public class ConnectionManager extends ConfigurableRest<ConnectionManager.Status
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
private enum Media {
|
||||
public enum Media {
|
||||
FTTH,
|
||||
ETHERNET,
|
||||
XDSL,
|
||||
@ -70,7 +76,71 @@ public class ConnectionManager extends ConfigurableRest<ConnectionManager.Status
|
||||
) {
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,8 @@ import org.openhab.binding.freeboxos.internal.api.FreeboxException;
|
||||
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;
|
||||
@ -75,6 +77,7 @@ public class ServerHandler extends ApiConsumerHandler implements FreeDeviceIntf
|
||||
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());
|
||||
@ -82,7 +85,13 @@ public class ServerHandler extends ApiConsumerHandler implements FreeDeviceIntf
|
||||
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) {
|
||||
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -461,4 +461,46 @@
|
||||
<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>
|
||||
|
@ -52,6 +52,34 @@
|
||||
</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>
|
||||
|
@ -20,8 +20,14 @@
|
||||
<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"/>
|
||||
@ -42,8 +48,14 @@
|
||||
<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"/>
|
||||
|
@ -26,4 +26,67 @@
|
||||
|
||||
</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>
|
||||
|
Loading…
Reference in New Issue
Block a user