2 * Copyright (c) 2010-2023 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) {
45 ThingUID thingUID = new ThingUID(Type.DECT.equals(config.type()) ? THING_TYPE_DECT : THING_TYPE_FXS, bridgeUID,
46 Integer.toString(config.id()));
48 logger.debug("Adding new Freebox Phone {} to inbox", thingUID);
50 return DiscoveryResultBuilder.create(thingUID).withBridge(bridgeUID)
51 .withProperty(ClientConfiguration.ID, config.id()).withLabel(config.type().name())
52 .withRepresentationProperty(ClientConfiguration.ID);