mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[freeboxos] Add translatable labels for discovered things (#17287)
* [freeboxos] Add translatable labels for discovered things Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
parent
5ae87b8dee
commit
3ad25d695a
@ -46,10 +46,10 @@ public class PhoneConfigurationBuilder {
|
||||
String label;
|
||||
if (Type.DECT.equals(config.type())) {
|
||||
thingUID = new ThingUID(THING_TYPE_DECT, bridgeUID, Integer.toString(config.id()));
|
||||
label = "DECT Phone";
|
||||
label = "@text/discovery.dect.label";
|
||||
} else {
|
||||
thingUID = new ThingUID(THING_TYPE_FXS, bridgeUID, Integer.toString(config.id()));
|
||||
label = "Landline Phone";
|
||||
label = "@text/discovery.fxs.label";
|
||||
}
|
||||
|
||||
logger.debug("Adding new Freebox Phone {} to inbox", thingUID);
|
||||
|
@ -48,11 +48,14 @@ import org.openhab.binding.freeboxos.internal.handler.FreeboxOsHandler;
|
||||
import org.openhab.core.config.discovery.AbstractThingHandlerDiscoveryService;
|
||||
import org.openhab.core.config.discovery.DiscoveryResult;
|
||||
import org.openhab.core.config.discovery.DiscoveryResultBuilder;
|
||||
import org.openhab.core.i18n.LocaleProvider;
|
||||
import org.openhab.core.i18n.TranslationProvider;
|
||||
import org.openhab.core.thing.Thing;
|
||||
import org.openhab.core.thing.ThingStatus;
|
||||
import org.openhab.core.thing.ThingTypeUID;
|
||||
import org.openhab.core.thing.ThingUID;
|
||||
import org.osgi.service.component.annotations.Component;
|
||||
import org.osgi.service.component.annotations.Reference;
|
||||
import org.osgi.service.component.annotations.ServiceScope;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -83,6 +86,16 @@ public class FreeboxOsDiscoveryService extends AbstractThingHandlerDiscoveryServ
|
||||
DISCOVERY_TIME_SECONDS);
|
||||
}
|
||||
|
||||
@Reference(unbind = "-")
|
||||
public void bindTranslationProvider(TranslationProvider translationProvider) {
|
||||
this.i18nProvider = translationProvider;
|
||||
}
|
||||
|
||||
@Reference(unbind = "-")
|
||||
public void bindLocaleProvider(LocaleProvider localeProvider) {
|
||||
this.localeProvider = localeProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startBackgroundDiscovery() {
|
||||
stopBackgroundDiscovery();
|
||||
@ -162,7 +175,7 @@ public class FreeboxOsDiscoveryService extends AbstractThingHandlerDiscoveryServ
|
||||
ThingUID thingUID = new ThingUID(THING_TYPE_CALL, bridgeUID, "calls");
|
||||
logger.debug("Adding new Call thing {} to inbox", thingUID);
|
||||
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withBridge(bridgeUID)
|
||||
.withLabel("Phone Calls").build();
|
||||
.withLabel("@text/discovery.call.label").build();
|
||||
thingDiscovered(discoveryResult);
|
||||
}
|
||||
}
|
||||
@ -181,7 +194,8 @@ public class FreeboxOsDiscoveryService extends AbstractThingHandlerDiscoveryServ
|
||||
bridgeUID, mac.toHexString(false));
|
||||
logger.debug("Adding new Freebox Network Host {} to inbox", thingUID);
|
||||
DiscoveryResultBuilder builder = DiscoveryResultBuilder.create(thingUID).withBridge(bridgeUID)
|
||||
.withLabel(lanHost.getPrimaryName().orElse("Network Device %s".formatted(macString)))
|
||||
.withLabel(lanHost.getPrimaryName()
|
||||
.orElse("@text/discovery.network-device.label [ \"%s\" ]".formatted(macString)))
|
||||
.withTTL(300).withProperty(Thing.PROPERTY_MAC_ADDRESS, macString)
|
||||
.withRepresentationProperty(Thing.PROPERTY_MAC_ADDRESS);
|
||||
thingDiscovered(builder.build());
|
||||
@ -201,7 +215,8 @@ public class FreeboxOsDiscoveryService extends AbstractThingHandlerDiscoveryServ
|
||||
logger.debug("Adding new VM Device {} to inbox", thingUID);
|
||||
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withBridge(bridgeUID)
|
||||
.withRepresentationProperty(Thing.PROPERTY_MAC_ADDRESS)
|
||||
.withLabel("%s (VM)".formatted(vm.name())).withProperty(ClientConfiguration.ID, vm.id())
|
||||
.withLabel("@text/discovery.vm.label [ \"%s\" ]".formatted(vm.name()))
|
||||
.withProperty(ClientConfiguration.ID, vm.id())
|
||||
.withProperty(Thing.PROPERTY_MAC_ADDRESS, mac.toColonDelimitedString()).build();
|
||||
thingDiscovered(discoveryResult);
|
||||
});
|
||||
@ -219,7 +234,7 @@ public class FreeboxOsDiscoveryService extends AbstractThingHandlerDiscoveryServ
|
||||
|
||||
ThingUID thingUID = new ThingUID(THING_TYPE_REPEATER, bridgeUID, Integer.toString(repeater.id()));
|
||||
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withBridge(bridgeUID)
|
||||
.withLabel("Repeater %s".formatted(repeater.name()))
|
||||
.withLabel("@text/discovery.repeater.label [ \"%s\" ]".formatted(repeater.name()))
|
||||
.withProperty(Thing.PROPERTY_MAC_ADDRESS, mac.toColonDelimitedString())
|
||||
.withProperty(ClientConfiguration.ID, repeater.id())
|
||||
.withRepresentationProperty(Thing.PROPERTY_MAC_ADDRESS).build();
|
||||
|
@ -385,6 +385,15 @@ info-host-not-reachable = Host is not reachable
|
||||
info-player-not-reachable = Player is not reachable
|
||||
info-vm-not-running = VM is not running
|
||||
|
||||
# discovery result
|
||||
|
||||
discovery.call.label = Phone Calls
|
||||
discovery.dect.label = DECT Phone
|
||||
discovery.fxs.label = Landline Phone
|
||||
discovery.network-device.label = Network Device {0}
|
||||
discovery.repeater.label = Repeater {0}
|
||||
discovery.vm.label = Virtual Machine {0}
|
||||
|
||||
# iconprovider
|
||||
|
||||
iconset.label = FreeboxOS Icons
|
||||
|
Loading…
Reference in New Issue
Block a user