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.handler;
15 import java.math.BigDecimal;
17 import java.util.concurrent.TimeUnit;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.binding.freeboxos.internal.config.ClientConfiguration;
22 import org.openhab.core.config.core.Configuration;
23 import org.openhab.core.thing.Thing;
24 import org.openhab.core.thing.ThingStatus;
25 import org.openhab.core.thing.ThingStatusDetail;
26 import org.openhab.core.thing.binding.ThingHandler;
28 import inet.ipaddr.MACAddressString;
29 import inet.ipaddr.mac.MACAddress;
32 * The {@link ApiConsumerIntf} defines some common methods for various devices (server, player, repeater) not belonging
33 * to the same class hierarchy
35 * @author Gaƫl L'hopital - Initial contribution
38 public interface ApiConsumerIntf extends ThingHandler {
40 Map<String, String> editProperties();
42 Configuration getConfig();
44 void updateProperties(@Nullable Map<String, String> properties);
46 void updateStatus(ThingStatus status, ThingStatusDetail statusDetail, @Nullable String description);
50 void addJob(String name, Runnable command, long initialDelay, long delay, TimeUnit unit);
52 void addJob(String name, Runnable command, long delay, TimeUnit unit);
54 default int getClientId() {
55 return ((BigDecimal) getConfig().get(ClientConfiguration.ID)).intValue();
58 default MACAddress getMac() {
59 String mac = (String) getConfig().get(Thing.PROPERTY_MAC_ADDRESS);
60 return new MACAddressString(mac).getAddress();