]> git.basschouten.com Git - openhab-addons.git/blob
5dde8cba6a52939695caad0822808b7fd47ea56e
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.freeboxos.internal.handler;
14
15 import java.math.BigDecimal;
16 import java.util.Map;
17 import java.util.concurrent.TimeUnit;
18
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;
27
28 import inet.ipaddr.MACAddressString;
29 import inet.ipaddr.mac.MACAddress;
30
31 /**
32  * The {@link ApiConsumerIntf} defines some common methods for various devices (server, player, repeater) not belonging
33  * to the same class hierarchy
34  *
35  * @author GaĆ«l L'hopital - Initial contribution
36  */
37 @NonNullByDefault
38 public interface ApiConsumerIntf extends ThingHandler {
39
40     Map<String, String> editProperties();
41
42     Configuration getConfig();
43
44     void updateProperties(@Nullable Map<String, String> properties);
45
46     void updateStatus(ThingStatus status, ThingStatusDetail statusDetail, @Nullable String description);
47
48     void stopJobs();
49
50     void addJob(String name, Runnable command, long initialDelay, long delay, TimeUnit unit);
51
52     void addJob(String name, Runnable command, long delay, TimeUnit unit);
53
54     default int getClientId() {
55         return ((BigDecimal) getConfig().get(ClientConfiguration.ID)).intValue();
56     }
57
58     default MACAddress getMac() {
59         String mac = (String) getConfig().get(Thing.PROPERTY_MAC_ADDRESS);
60         return new MACAddressString(mac).getAddress();
61     }
62 }