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.souliss.internal.handler;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.souliss.internal.SoulissBindingConstants;
17 import org.openhab.binding.souliss.internal.protocol.HalfFloatUtils;
18 import org.openhab.core.library.types.DecimalType;
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.types.Command;
23 import org.openhab.core.types.PrimitiveType;
26 * The {@link SoulissT6nHandler} is responsible for handling commands, which are
27 * sent to one of the channels.
29 * @author Luca Remigio - Initial contribution
30 * @author Luca Calcaterra - Refactor for OH3
33 public class SoulissT6nHandler extends SoulissGenericHandler {
35 private float fSetPointValue = 0xFFFF;
37 public SoulissT6nHandler(Thing thing) {
42 public void handleCommand(ChannelUID channelUID, Command command) {
43 if (command instanceof DecimalType) {
44 int uu = HalfFloatUtils.fromFloat(((DecimalType) command).floatValue());
45 byte b2 = (byte) (uu >> 8);
53 public void initialize() {
56 updateStatus(ThingStatus.UNKNOWN);
59 public void setState(PrimitiveType state) {
60 this.updateState(SoulissBindingConstants.T6N_VALUE_CHANNEL, (DecimalType) state);
64 public void setRawState(byte rawState) {
65 throw new UnsupportedOperationException("Not Implemented, yet.");
68 public void setFloatValue(float valueOf) {
69 super.setLastStatusStored();
70 if (fSetPointValue != valueOf) {
71 this.setState(DecimalType.valueOf(Float.toString(valueOf)));
72 fSetPointValue = valueOf;
77 public byte getRawState() {
78 throw new UnsupportedOperationException("Not Implemented, yet.");
81 public float getFloatState() {
82 return fSetPointValue;
86 public byte getExpectedRawState(byte bCommand) {