2 * Copyright (c) 2010-2020 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.teleinfo.internal.handler.cbemm;
15 import static org.openhab.binding.teleinfo.internal.TeleinfoBindingConstants.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemm;
19 import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractElectricityMeterHandler;
20 import org.openhab.core.library.types.DateTimeType;
21 import org.openhab.core.library.types.QuantityType;
22 import org.openhab.core.library.types.StringType;
23 import org.openhab.core.library.unit.SmartHomeUnits;
24 import org.openhab.core.thing.Thing;
25 import org.openhab.core.types.UnDefType;
28 * The {@link TeleinfoAbstractCbemmElectricityMeterHandler} class defines a skeleton for CBEMM Electricity Meters
31 * @author Nicolas SIBERIL - Initial contribution
34 public abstract class TeleinfoAbstractCbemmElectricityMeterHandler extends TeleinfoAbstractElectricityMeterHandler {
36 public TeleinfoAbstractCbemmElectricityMeterHandler(Thing thing) {
40 protected void updateStatesForCommonCbemmChannels(FrameCbemm frame) {
41 // update common channels
42 updateState(CHANNEL_CBEMM_ISOUSC, QuantityType.valueOf(frame.getIsousc(), SmartHomeUnits.AMPERE));
43 updateState(CHANNEL_CBEMM_PTEC, new StringType(frame.getPtec().name()));
44 if (frame.getImax() == null) {
45 updateState(CHANNEL_CBEMM_IMAX, UnDefType.NULL);
47 updateState(CHANNEL_CBEMM_IMAX, QuantityType.valueOf(frame.getImax(), SmartHomeUnits.AMPERE));
50 if (frame.getAdps() == null) {
51 updateState(CHANNEL_CBEMM_ADPS, UnDefType.NULL);
53 updateState(CHANNEL_CBEMM_ADPS, QuantityType.valueOf(frame.getAdps(), SmartHomeUnits.AMPERE));
55 updateState(CHANNEL_CBEMM_IINST, QuantityType.valueOf(frame.getIinst(), SmartHomeUnits.AMPERE));
57 updateState(CHANNEL_LAST_UPDATE, new DateTimeType());