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.ism8.server;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
21 * The {@link DataPointByteValue} is the data points for byte values
23 * @author Hans-Reiner Hoffmann - Initial contribution
26 public class DataPointByteValue extends DataPointBase<@Nullable Byte> {
27 private final Logger logger = LoggerFactory.getLogger(DataPointByteValue.class);
29 public DataPointByteValue(int id, String knxDataType, String description) {
30 super(id, knxDataType, description);
34 public String getValueText() {
35 Object val = this.getValue();
36 return val != null ? val.toString() : "0";
40 public void processData(byte[] data) {
41 if (this.checkProcessData(data)) {
42 if (data[3] != 1 && data.length <= 4) {
43 logger.debug("DataPoint-ProcessData: Data size wrong for this type({}/1).", data[3]);
46 this.setValue(data[4]);
51 protected byte[] convertWriteValue(Object value) {
52 this.setValue(Byte.parseByte(value.toString()));
53 return new byte[] { this.getValue() };