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.velbus.internal;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
18 * The {@link VelbusFirstGenerationDeviceModuleAddress} represents the address Velbus
19 * module of the 1st generation.
21 * @author Cedric Boon - Initial contribution
24 public class VelbusFirstGenerationDeviceModuleAddress extends VelbusModuleAddress {
26 public VelbusFirstGenerationDeviceModuleAddress(byte address) {
31 public int getChannelNumber(VelbusChannelIdentifier velbusChannelIdentifier) {
32 byte channelByte = velbusChannelIdentifier.getChannelByte();
33 if (channelByte == (byte) 0x03) {
35 } else if (channelByte == (byte) 0x0C) {
39 throw new IllegalArgumentException("The byte '" + channelByte
40 + "' does not represent a valid channel on the first generation device with address '"
41 + velbusChannelIdentifier.getAddress() + "'.");
45 public VelbusChannelIdentifier getChannelIdentifier(int channelIndex) {
46 if (channelIndex == 0) {
47 return new VelbusChannelIdentifier(getAddress(), (byte) 0x03);
48 } else if (channelIndex == 1) {
49 return new VelbusChannelIdentifier(getAddress(), (byte) 0x0C);
51 throw new IllegalArgumentException("The channel index '" + channelIndex
52 + "' is not valid for the first generation device on the address '" + getAddress() + "'.");