From bb99ffcba89406d6a353bb7d6399fb3dd27291d1 Mon Sep 17 00:00:00 2001 From: lolodomo Date: Sat, 17 Aug 2024 20:03:03 +0200 Subject: [PATCH] [freeboxos] Fix phone and calls configuration (#17272) Fix #17262 Also remove the unused class LanlineConfiguration Signed-off-by: Laurent Garnier Signed-off-by: Ciprian Pascu --- .../config/LandlineConfiguration.java | 30 ------------------- .../config/PhoneConfigurationBuilder.java | 13 ++++++-- .../discovery/FreeboxOsDiscoveryService.java | 4 +-- .../resources/OH-INF/config/phone-config.xml | 8 ++--- .../OH-INF/i18n/freeboxos.properties | 12 ++++---- .../OH-INF/thing/phone-thing-type.xml | 6 ++-- 6 files changed, 25 insertions(+), 48 deletions(-) delete mode 100644 bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/config/LandlineConfiguration.java diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/config/LandlineConfiguration.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/config/LandlineConfiguration.java deleted file mode 100644 index 0fed6b0a4b1..00000000000 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/config/LandlineConfiguration.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2010-2024 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.freeboxos.internal.config; - -import org.eclipse.jdt.annotation.NonNullByDefault; - -/** - * The {@link LandlineConfiguration} is responsible for holding - * configuration informations associated to a Freebox Phone thing type - * - * @author Gaƫl L'hopital - Initial contribution - */ -@NonNullByDefault -public class LandlineConfiguration extends ApiConsumerConfiguration { - public int id = 1; - - LandlineConfiguration() { - refreshInterval = 2; - } -} diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/config/PhoneConfigurationBuilder.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/config/PhoneConfigurationBuilder.java index f46fe12cdf6..a474b4c59a3 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/config/PhoneConfigurationBuilder.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/config/PhoneConfigurationBuilder.java @@ -42,13 +42,20 @@ public class PhoneConfigurationBuilder { } public DiscoveryResultBuilder configure(ThingUID bridgeUID, Status config) { - ThingUID thingUID = new ThingUID(Type.DECT.equals(config.type()) ? THING_TYPE_DECT : THING_TYPE_FXS, bridgeUID, - Integer.toString(config.id())); + ThingUID thingUID; + String label; + if (Type.DECT.equals(config.type())) { + thingUID = new ThingUID(THING_TYPE_DECT, bridgeUID, Integer.toString(config.id())); + label = "DECT Phone"; + } else { + thingUID = new ThingUID(THING_TYPE_FXS, bridgeUID, Integer.toString(config.id())); + label = "Landline Phone"; + } logger.debug("Adding new Freebox Phone {} to inbox", thingUID); return DiscoveryResultBuilder.create(thingUID).withBridge(bridgeUID) - .withProperty(ClientConfiguration.ID, config.id()).withLabel(config.type().name()) + .withProperty(ClientConfiguration.ID, config.id()).withLabel(label) .withRepresentationProperty(ClientConfiguration.ID); } } diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/discovery/FreeboxOsDiscoveryService.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/discovery/FreeboxOsDiscoveryService.java index b9628dade0a..aa40187ff16 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/discovery/FreeboxOsDiscoveryService.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/discovery/FreeboxOsDiscoveryService.java @@ -159,10 +159,10 @@ public class FreeboxOsDiscoveryService extends AbstractThingHandlerDiscoveryServ logger.debug("Error discovering phones: {}", e.getMessage()); } if (!statuses.isEmpty()) { - ThingUID thingUID = new ThingUID(THING_TYPE_CALL, bridgeUID, "landline"); + 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("Freebox Calls").build(); + .withLabel("Phone Calls").build(); thingDiscovered(discoveryResult); } } diff --git a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/config/phone-config.xml b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/config/phone-config.xml index 430d95bb06b..c2f4aff371e 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/config/phone-config.xml +++ b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/config/phone-config.xml @@ -7,7 +7,7 @@ - + The refresh interval in seconds which is used to poll for phone state. 30 @@ -20,9 +20,9 @@ - - The refresh interval in seconds which is used to poll for phone state. - 2 + + The refresh interval in seconds which is used to poll for phone calls. + 30 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 33a32df8807..fbe6c125853 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 @@ -25,9 +25,9 @@ thing-type.freeboxos.api.label = Freebox OS Api thing-type.freeboxos.api.description = Bridge between hosts and the API rest service thing-type.freeboxos.basic-shutter.label = Freebox Home Basic Shutter thing-type.freeboxos.basic-shutter.description = The Basic Shutter (UP,DOWN,STOP) configured in your Freebox Delta Server -thing-type.freeboxos.call.label = Calls +thing-type.freeboxos.call.label = Phone Calls thing-type.freeboxos.call.description = Provides various informations regarding the phone calls -thing-type.freeboxos.dect.label = DECT +thing-type.freeboxos.dect.label = DECT Phone thing-type.freeboxos.dect.description = Provides various informations regarding the DECT state and configuration thing-type.freeboxos.dect.channel.gain-rx.label = Gain RX thing-type.freeboxos.dect.channel.gain-tx.label = Gain TX @@ -40,7 +40,7 @@ thing-type.freeboxos.freeplug.channel.rate-down.label = Rx Rate thing-type.freeboxos.freeplug.channel.rate-down.description = Current RX rate thing-type.freeboxos.freeplug.channel.rate-up.label = Tx Rate thing-type.freeboxos.freeplug.channel.rate-up.description = Current TX Rate -thing-type.freeboxos.fxs.label = Landline +thing-type.freeboxos.fxs.label = Landline Phone thing-type.freeboxos.fxs.description = Provides various informations regarding the landline state thing-type.freeboxos.host.label = Network Device thing-type.freeboxos.host.description = Provides network device reachability @@ -75,8 +75,8 @@ bridge-type.config.freeboxos.api.httpsPort.label = HTTPS port bridge-type.config.freeboxos.api.httpsPort.description = Port to use for HTTPS access to the Freebox Api bridge-type.config.freeboxos.api.wsReconnectInterval.label = Websocket Reconnect Interval bridge-type.config.freeboxos.api.wsReconnectInterval.description = Disconnection interval, in minutes- 0 disables websocket usage -thing-type.config.freeboxos.call.refreshInterval.label = State Refresh Interval -thing-type.config.freeboxos.call.refreshInterval.description = The refresh interval in seconds which is used to poll for phone state. +thing-type.config.freeboxos.call.refreshInterval.label = Refresh Interval +thing-type.config.freeboxos.call.refreshInterval.description = The refresh interval in seconds which is used to poll for phone calls. thing-type.config.freeboxos.home-node.id.label = ID thing-type.config.freeboxos.home-node.id.description = Id of the Home Node thing-type.config.freeboxos.home-node.refreshInterval.label = Refresh Interval @@ -87,7 +87,7 @@ thing-type.config.freeboxos.host.refreshInterval.label = Refresh Interval thing-type.config.freeboxos.host.refreshInterval.description = The refresh interval in seconds which is used to poll given device thing-type.config.freeboxos.phone.id.label = ID thing-type.config.freeboxos.phone.id.description = Id of the phone line -thing-type.config.freeboxos.phone.refreshInterval.label = State Refresh Interval +thing-type.config.freeboxos.phone.refreshInterval.label = Refresh Interval thing-type.config.freeboxos.phone.refreshInterval.description = The refresh interval in seconds which is used to poll for phone state. thing-type.config.freeboxos.player.acceptAllMp3.label = Accept All MP3 thing-type.config.freeboxos.player.acceptAllMp3.description = Accept any bitrate for MP3 audio or only bitrates greater than 64 kbps diff --git a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/phone-thing-type.xml b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/phone-thing-type.xml index 2a0e53b46da..1abe34c3d11 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/phone-thing-type.xml +++ b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/phone-thing-type.xml @@ -9,7 +9,7 @@ - + Provides various informations regarding the landline state @@ -29,7 +29,7 @@ - + Provides various informations regarding the DECT state and configuration @@ -56,7 +56,7 @@ - + Provides various informations regarding the phone calls