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.plugwise.internal.protocol;
15 import static org.openhab.binding.plugwise.internal.protocol.field.MessageType.SCAN_PARAMETERS_SET_REQUEST;
17 import java.time.Duration;
19 import org.openhab.binding.plugwise.internal.protocol.field.MACAddress;
20 import org.openhab.binding.plugwise.internal.protocol.field.Sensitivity;
23 * Sets the Scan motion detection parameters. These parameters control when the Scan sends on/off commands.
25 * @author Wouter Born - Initial contribution
27 public class ScanParametersSetRequestMessage extends Message {
29 private Sensitivity sensitivity;
30 private boolean daylightOverride;
31 private Duration switchOffDelay;
33 public ScanParametersSetRequestMessage(MACAddress macAddress, Sensitivity sensitivity, boolean daylightOverride,
34 Duration switchOffDelay) {
35 super(SCAN_PARAMETERS_SET_REQUEST, macAddress);
36 this.sensitivity = sensitivity;
37 this.daylightOverride = daylightOverride;
38 this.switchOffDelay = switchOffDelay;
42 protected String payloadToHexString() {
43 String sensitivityHex = String.format("%02X", sensitivity.toInt());
44 String daylightOverrideHex = (daylightOverride ? "01" : "00");
45 String switchOffDelayHex = String.format("%02X", switchOffDelay.toMinutes());
46 return sensitivityHex + daylightOverrideHex + switchOffDelayHex;