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.packets;
15 import static org.openhab.binding.velbus.internal.VelbusBindingConstants.COMMAND_SET_REALTIME_CLOCK;
17 import java.time.DayOfWeek;
18 import java.time.ZonedDateTime;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
23 * The {@link VelbusSetRealtimeClockPacket} represents a Velbus packet that can be used to
24 * set the clock of the given Velbus module.
26 * @author Cedric Boon - Initial contribution
29 public class VelbusSetRealtimeClockPacket extends VelbusPacket {
30 private ZonedDateTime zonedDateTime;
32 public VelbusSetRealtimeClockPacket(byte address, ZonedDateTime zonedDateTime) {
33 super(address, PRIO_LOW);
35 this.zonedDateTime = zonedDateTime;
38 public byte getHour() {
39 return (byte) this.zonedDateTime.getHour();
42 public byte getMinute() {
43 return (byte) this.zonedDateTime.getMinute();
46 public byte getWeekDay() {
47 DayOfWeek dayOfWeek = zonedDateTime.getDayOfWeek();
64 throw new IllegalArgumentException("Day " + dayOfWeek + " is not a valid weekday.");
69 protected byte[] getDataBytes() {
70 return new byte[] { COMMAND_SET_REALTIME_CLOCK, this.getWeekDay(), getHour(), getMinute() };