2 * Copyright (c) 2010-2024 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.freeboxos.internal.config;
15 import static org.openhab.binding.freeboxos.internal.FreeboxOsBindingConstants.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.freeboxos.internal.api.rest.PhoneManager.Status;
19 import org.openhab.binding.freeboxos.internal.api.rest.PhoneManager.Type;
20 import org.openhab.core.config.discovery.DiscoveryResultBuilder;
21 import org.openhab.core.thing.ThingUID;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
26 * The {@link PhoneConfigurationBuilder} is responsible for holding configuration informations associated the phone
27 * lines (DECT and FXS / landline)
29 * @author Gaƫl L'hopital - Initial contribution
32 public class PhoneConfigurationBuilder {
33 private static final PhoneConfigurationBuilder BUILDER_INSTANCE = new PhoneConfigurationBuilder();
35 private final Logger logger = LoggerFactory.getLogger(PhoneConfigurationBuilder.class);
37 private PhoneConfigurationBuilder() {
40 public static PhoneConfigurationBuilder getInstance() {
41 return BUILDER_INSTANCE;
44 public DiscoveryResultBuilder configure(ThingUID bridgeUID, Status config) {
47 if (Type.DECT.equals(config.type())) {
48 thingUID = new ThingUID(THING_TYPE_DECT, bridgeUID, Integer.toString(config.id()));
51 thingUID = new ThingUID(THING_TYPE_FXS, bridgeUID, Integer.toString(config.id()));
52 label = "Landline Phone";
55 logger.debug("Adding new Freebox Phone {} to inbox", thingUID);
57 return DiscoveryResultBuilder.create(thingUID).withBridge(bridgeUID)
58 .withProperty(ClientConfiguration.ID, config.id()).withLabel(label)
59 .withRepresentationProperty(ClientConfiguration.ID);