]> git.basschouten.com Git - openhab-addons.git/blob
f68c115debb65c730c8bf7c84cde5e28925025af
[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.souliss.internal.handler;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.souliss.internal.SoulissBindingConstants;
17 import org.openhab.core.library.types.QuantityType;
18 import org.openhab.core.thing.ChannelUID;
19 import org.openhab.core.thing.Thing;
20 import org.openhab.core.thing.ThingStatus;
21 import org.openhab.core.types.Command;
22
23 /**
24  * The {@link SoulissT5nHandler} is responsible for handling commands, which are
25  * sent to one of the channels.
26  *
27  * @author Tonino Fazio - Initial contribution
28  * @author Luca Calcaterra - Refactor for OH3
29  */
30 @NonNullByDefault
31 public class SoulissT5nHandler extends SoulissGenericHandler {
32
33     private float fVal = 0xF;
34
35     public SoulissT5nHandler(Thing thing) {
36         super(thing);
37     }
38
39     @Override
40     public void initialize() {
41         super.initialize();
42
43         updateStatus(ThingStatus.UNKNOWN);
44     }
45
46     public void setState(QuantityType<?> state) {
47         this.updateState(SoulissBindingConstants.T5N_VALUE_CHANNEL, state);
48     }
49
50     @Override
51     public void setRawState(byte rawState) {
52         throw new UnsupportedOperationException("Not Implemented, yet.");
53     }
54
55     public void setFloatValue(float valueOf) {
56         super.setLastStatusStored();
57         if (fVal != valueOf) {
58             this.setState(QuantityType.valueOf(Float.toString(valueOf)));
59             fVal = valueOf;
60         }
61     }
62
63     @Override
64     public byte getRawState() {
65         throw new UnsupportedOperationException("Not Implemented, yet.");
66     }
67
68     public float getFloatState() {
69         return fVal;
70     }
71
72     @Override
73     public byte getExpectedRawState(byte bCommand) {
74         // Secure Send is disabled
75         return -1;
76     }
77
78     @Override
79     public void handleCommand(ChannelUID channelUID, Command command) {
80         throw new UnsupportedOperationException("Unsupported operation. Read Only");
81     }
82 }