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.openthermgateway.internal;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.core.library.types.DecimalType;
17 import org.openhab.core.types.State;
20 * The {@link TspFhbValueDataItem} represents a transparent slave parameter or fault history buffer value.
22 * @author Arjen Korevaar - Initial contribution
25 public class TspFhbValueDataItem extends DataItem {
27 public TspFhbValueDataItem(Msg msg, String subject) {
28 super(msg, ByteType.BOTH, subject, null);
32 public String getChannelId(Message message) {
33 // With TSP or FHB values, the index is HIGHBYTE, the value is LOWBYTE
34 int index = message.getUInt(ByteType.HIGHBYTE);
35 return getChannelId(index);
38 public String getChannelId(int index) {
39 return super.getSubject() + "_" + index;
42 public String getLabel(int index) {
43 return super.getSubject() + " " + index;
47 public State createState(Message message) {
48 // With TSP or FHB values, the index is HIGHBYTE, the value is LOWBYTE
49 // TSP values are treated as Number:Dimensionless
50 return new DecimalType(message.getUInt(ByteType.LOWBYTE));