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.avmfritz.internal.dto;
15 import java.math.BigDecimal;
17 import javax.xml.bind.annotation.XmlAccessType;
18 import javax.xml.bind.annotation.XmlAccessorType;
19 import javax.xml.bind.annotation.XmlRootElement;
20 import javax.xml.bind.annotation.XmlType;
23 * See {@link DeviceListModel}.
25 * @author Robert Bausdorf - Initial contribution
26 * @author Christoph Weitkamp - Added channel 'voltage'
28 @XmlAccessorType(XmlAccessType.FIELD)
29 @XmlType(propOrder = { "voltage", "power", "energy" })
30 @XmlRootElement(name = "powermeter")
31 public class PowerMeterModel {
32 public static final BigDecimal VOLTAGE_FACTOR = new BigDecimal("0.001");
33 public static final BigDecimal POWER_FACTOR = new BigDecimal("0.001");
35 private BigDecimal voltage;
36 private BigDecimal power;
37 private BigDecimal energy;
39 public BigDecimal getVoltage() {
40 return voltage != null ? VOLTAGE_FACTOR.multiply(voltage) : BigDecimal.ZERO;
43 public void setVoltage(BigDecimal voltage) {
44 this.voltage = voltage;
47 public BigDecimal getPower() {
48 return power != null ? POWER_FACTOR.multiply(power) : BigDecimal.ZERO;
51 public void setPower(BigDecimal power) {
55 public BigDecimal getEnergy() {
56 return energy != null ? energy : BigDecimal.ZERO;
59 public void setEnergy(BigDecimal energy) {
64 public String toString() {
65 return new StringBuilder().append("[voltage=").append(getVoltage()).append(",power=").append(getPower())
66 .append(",energy=").append(getEnergy()).append("]").toString();