]> git.basschouten.com Git - openhab-addons.git/blob
664460cf675d7e26606c503f0a6decb9e17b097f
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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.homematic.internal.communicator.virtual;
14
15 import static org.openhab.binding.homematic.internal.misc.HomematicConstants.VIRTUAL_DATAPOINT_NAME_INSTALL_MODE_DURATION;
16
17 import java.io.IOException;
18
19 import org.openhab.binding.homematic.internal.misc.HomematicClientException;
20 import org.openhab.binding.homematic.internal.model.HmDatapoint;
21 import org.openhab.binding.homematic.internal.model.HmDatapointConfig;
22 import org.openhab.binding.homematic.internal.model.HmDevice;
23 import org.openhab.binding.homematic.internal.model.HmValueType;
24
25 /**
26  * A virtual Integer datapoint to hold the duration for the install mode, default one minute.
27  *
28  * @author Gerhard Riegler - Initial contribution
29  */
30 public class InstallModeDurationVirtualDatapoint extends AbstractVirtualDatapointHandler {
31     @Override
32     public String getName() {
33         return VIRTUAL_DATAPOINT_NAME_INSTALL_MODE_DURATION;
34     }
35
36     @Override
37     public void initialize(HmDevice device) {
38         if (device.isGatewayExtras()) {
39             HmDatapoint dp = addDatapoint(device, 0, getName(), HmValueType.INTEGER, 60, false);
40             dp.setMinValue(10);
41             dp.setMaxValue(300);
42         }
43     }
44
45     @Override
46     public boolean canHandleCommand(HmDatapoint dp, Object value) {
47         return getName().equals(dp.getName());
48     }
49
50     @Override
51     public void handleCommand(VirtualGateway gateway, HmDatapoint dp, HmDatapointConfig dpConfig, Object value)
52             throws IOException, HomematicClientException {
53         dp.setValue(value);
54     }
55 }