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.POWER_LOG_INTERVAL_SET_REQUEST;
17 import java.time.Duration;
19 import org.openhab.binding.plugwise.internal.protocol.field.MACAddress;
22 * Sets the interval of historic power consumption and production measurements. These historic measurements are
23 * returned by the {@link PowerBufferRequestMessage}.
25 * @author Wouter Born - Initial contribution
27 public class PowerLogIntervalSetRequestMessage extends Message {
29 private Duration consumptionInterval;
30 private Duration productionInterval;
32 public PowerLogIntervalSetRequestMessage(MACAddress macAddress, Duration consumptionInterval,
33 Duration productionInterval) {
34 super(POWER_LOG_INTERVAL_SET_REQUEST, macAddress);
35 this.consumptionInterval = consumptionInterval;
36 this.productionInterval = productionInterval;
40 protected String payloadToHexString() {
41 String consumptionIntervalHex = String.format("%04X", consumptionInterval.toMinutes());
42 String productionIntervalHex = String.format("%04X", productionInterval.toMinutes());
43 return consumptionIntervalHex + productionIntervalHex;