2 * Copyright (c) 2010-2021 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.omnikinverter.internal;
15 import java.nio.ByteBuffer;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
21 * @author Hans van den Bogert - Initial contribution
25 public class OmnikInverterMessage {
27 private final byte[] bytes;
29 public OmnikInverterMessage(byte[] b) {
33 public double getPower() {
34 ByteBuffer buf = ByteBuffer.allocate(2);
35 buf.put(bytes, 59, 2);
37 return buf.getShort();
42 * @return the total energy outputted this day in kWh
44 public double getEnergyToday() {
45 ByteBuffer buf = ByteBuffer.allocate(2);
46 buf.put(bytes, 69, 2);
48 return (buf.getShort() / 100.0);
53 * @return the total energy outputted in kWh
55 public double getTotalEnergy() {
56 ByteBuffer buf = ByteBuffer.allocate(4);
57 buf.put(bytes, 71, 4);
59 return buf.getInt() / 10.0;