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.dali.internal.protocol;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.dali.internal.handler.DaliException;
19 * The {@link DaliStandardCommand} represents different types of commands for
20 * controlling DALI equipment.
22 * @author Robert Schmid - Initial contribution
25 public class DaliStandardCommand extends DaliGearCommandBase {
27 private DaliStandardCommand(DaliAddress target, int cmdval, int param, boolean sendTwice) throws DaliException {
28 super(target.addToFrame(new DaliForwardFrame(16, new byte[] { 0x1, (byte) (cmdval | (param & 0b1111)) })),
32 public static DaliStandardCommand createOffCommand(DaliAddress target) throws DaliException {
33 return new DaliStandardCommand(target, 0x00, 0, false);
36 public static DaliStandardCommand createUpCommand(DaliAddress target) throws DaliException {
37 return new DaliStandardCommand(target, 0x01, 0, false);
40 public static DaliStandardCommand createDownCommand(DaliAddress target) throws DaliException {
41 return new DaliStandardCommand(target, 0x02, 0, false);
44 public static DaliStandardCommand createStepUpCommand(DaliAddress target) throws DaliException {
45 return new DaliStandardCommand(target, 0x03, 0, false);
48 public static DaliStandardCommand createStepDownCommand(DaliAddress target) throws DaliException {
49 return new DaliStandardCommand(target, 0x04, 0, false);
52 public static DaliStandardCommand createRecallMaxLevelCommand(DaliAddress target) throws DaliException {
53 return new DaliStandardCommand(target, 0x05, 0, false);
56 public static DaliStandardCommand createRecallMinLevelCommand(DaliAddress target) throws DaliException {
57 return new DaliStandardCommand(target, 0x06, 0, false);
60 public static DaliStandardCommand createStepDownAndOffCommand(DaliAddress target) throws DaliException {
61 return new DaliStandardCommand(target, 0x07, 0, false);
64 public static DaliStandardCommand createOnAndStepUpCommand(DaliAddress target) throws DaliException {
65 return new DaliStandardCommand(target, 0x08, 0, false);
68 public static DaliStandardCommand createEnableDAPCSequenceCommand(DaliAddress target) throws DaliException {
69 return new DaliStandardCommand(target, 0x09, 0, false);
72 public static DaliStandardCommand createGoToSceneCommand(DaliAddress target, int scene) throws DaliException {
73 return new DaliStandardCommand(target, 0x10, scene, false);
76 public static DaliStandardCommand createResetCommand(DaliAddress target) throws DaliException {
77 return new DaliStandardCommand(target, 0x20, 0, true);
80 public static DaliStandardCommand createQueryStatusCommand(DaliAddress target) throws DaliException {
81 return new DaliStandardCommand(target, 0x90, 0, false);
84 public static DaliStandardCommand createQueryContentDTR0Command(DaliAddress target) throws DaliException {
85 return new DaliStandardCommand(target, 0x98, 0, false);
88 public static DaliStandardCommand createQueryActualLevelCommand(DaliAddress target) throws DaliException {
89 return new DaliStandardCommand(target, 0xa0, 0, false);
92 public static DaliStandardCommand createActivateCommand(DaliAddress target) throws DaliException {
93 return new DaliStandardCommand(target, 0xe2, 0, false);
96 public static DaliStandardCommand createQueryColorValueCommand(DaliAddress target) throws DaliException {
97 return new DaliStandardCommand(target, 0xfa, 0, false);
100 // Global commands sent to special addresses
102 public static DaliStandardCommand createSetDTR0Command(int value) throws DaliException {
103 return new DaliStandardCommand(DaliAddress.createRawAddress(0xa3), value, 0, false);
106 public static DaliStandardCommand createSetDTR1Command(int value) throws DaliException {
107 return new DaliStandardCommand(DaliAddress.createRawAddress(0xc3), value, 0, false);
110 public static DaliStandardCommand createSetDTR2Command(int value) throws DaliException {
111 return new DaliStandardCommand(DaliAddress.createRawAddress(0xc5), value, 0, false);
114 public static DaliStandardCommand createSetDeviceTypeCommand(int value) throws DaliException {
115 return new DaliStandardCommand(DaliAddress.createRawAddress(0xc1), value, 0, false);
118 // DT8 (color temperature and single-channel RGB) commands
120 public static DaliStandardCommand createSetRgbDimlevelCommand(DaliAddress target) throws DaliException {
121 return new DaliStandardCommand(target, 0xeb, 0, false);
124 public static DaliStandardCommand createSetColorTemperatureCommand(DaliAddress target) throws DaliException {
125 return new DaliStandardCommand(target, 0xe7, 0, false);