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.handler;
16 import java.util.concurrent.TimeUnit;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.core.thing.ChannelUID;
20 import org.openhab.core.thing.Thing;
21 import org.openhab.core.thing.ThingStatus;
22 import org.openhab.core.thing.ThingStatusDetail;
25 * The {@link FreeDeviceIntf} defines some common methods for various devices (server, player, repeater) not belonging
26 * to the same class hierarchy
28 * @author Gaƫl L'hopital - Initial contribution
31 public interface FreeDeviceIntf extends ApiConsumerIntf {
32 public ChannelUID getEventChannelUID();
34 public void triggerChannel(ChannelUID channelUID, String event);
36 default long checkUptimeAndFirmware(long newUptime, long oldUptime, String firmwareVersion) {
37 if (newUptime < oldUptime) {
38 triggerChannel(getEventChannelUID(), "restarted");
39 Map<String, String> properties = editProperties();
40 if (!firmwareVersion.equals(properties.get(Thing.PROPERTY_FIRMWARE_VERSION))) {
41 properties.put(Thing.PROPERTY_FIRMWARE_VERSION, firmwareVersion);
42 updateProperties(properties);
43 triggerChannel(getEventChannelUID(), "firmware_updated");
49 default void processReboot(Runnable actualReboot) {
50 triggerChannel(getEventChannelUID(), "reboot_requested");
52 updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.DUTY_CYCLE, "System rebooting...");
54 addJob("Initialize", this::initialize, 30, TimeUnit.SECONDS);