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.homematic.internal.communicator.virtual;
15 import static org.openhab.binding.homematic.internal.misc.HomematicConstants.VIRTUAL_DATAPOINT_NAME_RELOAD_RSSI;
17 import java.io.IOException;
19 import org.openhab.binding.homematic.internal.communicator.AbstractHomematicGateway;
20 import org.openhab.binding.homematic.internal.misc.HomematicClientException;
21 import org.openhab.binding.homematic.internal.misc.MiscUtils;
22 import org.openhab.binding.homematic.internal.model.HmDatapoint;
23 import org.openhab.binding.homematic.internal.model.HmDatapointConfig;
24 import org.openhab.binding.homematic.internal.model.HmDevice;
25 import org.openhab.binding.homematic.internal.model.HmValueType;
28 * A virtual Switch datapoint which loads rssi values for all device from the gateway.
30 * @author Gerhard Riegler - Initial contribution
32 public class ReloadRssiVirtualDatapointHandler extends AbstractVirtualDatapointHandler {
34 public String getName() {
35 return VIRTUAL_DATAPOINT_NAME_RELOAD_RSSI;
39 public void initialize(HmDevice device) {
40 if (device.isGatewayExtras()) {
41 addDatapoint(device, 0, getName(), HmValueType.BOOL, Boolean.FALSE, false);
46 public boolean canHandleCommand(HmDatapoint dp, Object value) {
47 return getName().equals(dp.getName());
51 public void handleCommand(VirtualGateway gateway, HmDatapoint dp, HmDatapointConfig dpConfig, Object value)
52 throws IOException, HomematicClientException {
54 if (MiscUtils.isTrueValue(dp.getValue())) {
56 gateway.loadRssiValues();
58 gateway.disableDatapoint(dp, AbstractHomematicGateway.DEFAULT_DISABLE_DELAY);