added migrated 2.x add-ons

Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
Kai Kreuzer
2020-09-21 01:58:32 +02:00
parent bbf1a7fd29
commit 6df6783b60
11662 changed files with 1302875 additions and 11 deletions

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.openhab.binding.teleinfo</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,13 @@
This content is produced and maintained by the openHAB project.
* Project home: https://www.openhab.org
== Declared Project Licenses
This program and the accompanying materials are made available under the terms
of the Eclipse Public License 2.0 which is available at
https://www.eclipse.org/legal/epl-2.0/.
== Source Code
https://github.com/openhab/openhab2-addons

View File

@@ -0,0 +1,121 @@
# Teleinfo Binding
The Teleinfo binding supports an interface to ENEDIS/ERDF [Teleinfo protocol](http://www.linuxembarque.free.fr/electro/compt_energie/specifications_techniques_edf_teleinfo.pdf) for (French) Electricity Meter. This binding works with a Teleinfo modem plugged to the I1 and I2 terminals of your electricity meter. Teleinfo modems can be ordered (see the [list of tested hardware](#tested-hardware) below) or build by yourself (see [this example](http://bernard.lefrancois.free.fr)).
Teleinfo is a protocol to read many electrical statistics of your electricity meter: instantaneous power consumption, current price period, meter reading...
These values can be used to
- send your meter reading to your electricity provider with a simple copy/paste,
- improve your rules and minimize electricity costs,
- check if your subscription is relevant for your needs,
- monitor your electricity consumption,
## Supported Things
The Teleinfo binding provides support for both single phase and three phase connection, ICC evolution and the following pricing modes:
- HCHP mode
- Base mode
- Tempo mode
- EJP mode
| Thing type | Connection | Pricing mode | ICC evolution |
|--------------------------------------------|--------------|--------------|---------------|
| cbemm_base_electricitymeter | single-phase | Base | |
| cbemm_ejp_electricitymeter | single-phase | EJP | |
| cbemm_hc_electricitymeter | single-phase | HCHP | |
| cbemm_tempo_electricitymeter | single-phase | Tempo | |
| cbemm_evolution_icc_base_electricitymeter | single-phase | Base | [x] |
| cbemm_evolution_icc_ejp_electricitymeter | single-phase | EJP | [x] |
| cbemm_evolution_icc_hc_electricitymeter | single-phase | HCHP | [x] |
| cbemm_evolution_icc_tempo_electricitymeter | single-phase | Tempo | [x] |
| cbetm_base_electricitymeter | three-phase | Base | |
| cbetm_ejp_electricitymeter | three-phase | EJP | |
| cbetm_hc_electricitymeter | three-phase | HCHP | |
| cbetm_tempo_electricitymeter | three-phase | Tempo | |
## Discovery
Before the binding can be used, a serial controller must be added. This needs to be done manually. Select __Teleinfo Serial Controller__ and enter the serial port. Once the serial controller added, electricity meters will automatically appear when trying to add a new thing, with default label __Teleinfo ADCO #adco__ where __#adco__ is your electricity meter identifier.
## Thing Configuration
| Thing type | Parameter | Meaning | Possible values |
|----------------------|--------------|---------------------------------------|------------------|
| `serialcontroller` | `serialport` | Path to the serial controller | /dev/ttyXXXX |
| `*_electricitymeter` | `adco` | Electricity meter identifier | 12 digits number |
## Channels
Channel availability depends on the electricity connection (single or three phase) and on the pricing mode (Base, HCHP, EJP or Tempo).
| Channel | Type | Description | Phase | Mode |
|----------|---------------------------|----------------------------------------------------------|--------|-------|
| isousc | `Number:ElectricCurrent` | Subscribed electric current | All | All |
| ptec | `String` | Current pricing period | All | All |
| imax | `Number:ElectricCurrent` | Maximum consumed electric current | Single | All |
| imax1 | `Number:ElectricCurrent` | Maximum consumed electric current on phase 1 | Three | All |
| imax2 | `Number:ElectricCurrent` | Maximum consumed electric current on phase 2 | Three | All |
| imax3 | `Number:ElectricCurrent` | Maximum consumed electric current on phase 3 | Three | All |
| adps | `Number:ElectricCurrent` | Excess electric current warning | Single | All |
| adir1 | `Number:ElectricCurrent` | Excess electric current on phase 1 warning | Three | All |
| adir2 | `Number:ElectricCurrent` | Excess electric current on phase 2 warning | Three | All |
| adir3 | `Number:ElectricCurrent` | Excess electric current on phase 3 warning | Three | All |
| iinst | `Number:ElectricCurrent` | Instantaneous electric current | Single | All |
| iinst1 | `Number:ElectricCurrent` | Instantaneous electric current on phase 1 | Three | All |
| iinst2 | `Number:ElectricCurrent` | Instantaneous electric current on phase 2 | Three | All |
| iinst3 | `Number:ElectricCurrent` | Instantaneous electric current on phase 3 | Three | All |
| ppot | `String` | Electrical potential presence | Three | All |
| pmax | `Number:Energy` | Maximum consumed electric power on all phases | Three | All |
| papp | `Number` | Instantaneous apparent power (Unit: `VA`) | Three, single (ICC evolution only) | All |
| hhphc | `String` | Pricing schedule group | All | HCHP |
| hchc | `Number:Energy` | Total consumed energy at low rate pricing | All | HCHP |
| hchp | `Number:Energy` | Total consumed energy at high rate pricing | All | HCHP |
| base | `Number:Energy` | Total consumed energy | All | Base |
| ejphn | `Number:Energy` | Total consumed energy at low rate pricing | All | EJP |
| ejphpm | `Number:Energy` | Total consumed energy at high rate pricing | All | EJP |
| bbrhcjb | `Number:Energy` | Total consumed energy at low rate pricing on blue days | All | Tempo |
| bbrhpjb | `Number:Energy` | Total consumed energy at high rate pricing on blue days | All | Tempo |
| bbrhcjw | `Number:Energy` | Total consumed energy at low rate pricing on white days | All | Tempo |
| bbrhpjw | `Number:Energy` | Total consumed energy at high rate pricing on white days | All | Tempo |
| bbrhcjr | `Number:Energy` | Total consumed energy at low rate pricing on red days | All | Tempo |
| bbrhpjr | `Number:Energy` | Total consumed energy at high rate pricing on red days | All | Tempo |
| pejp | `Number:Duration` | Prior notice to EJP start | All | EJP |
| demain | `String` | Following day color | All | Tempo |
## Full Example
The following `things` file declare a serial USB controller on `/dev/ttyUSB0` for a Single-phase Electricity meter with HC/HP option - CBEMM Evolution ICC and adco `031528042289` :
```
Bridge teleinfo:serialcontroller:teleinfoUSB [ serialport="/dev/ttyUSB0" ]{
Thing cbemm_evolution_icc_hc_electricitymeter myElectricityMeter [ adco="031528042289"]
}
```
`adco` is a 12 digit number writen on the electricity meter (There might be two additional digits on the electricity meter, in this case the two last digits must be omitted to obtain 12 digits). The first 6 digits of `adco` can also be retrieved by pushing 6 times the `selection` button of your electricity meter, and the last 6 digits by pushing the `defilement` button.
This `items` file links some supported channels to items:
```
Number TLInfoEDF_PAPP "PAPP" <energy> {channel="teleinfo:cbemm_evolution_icc_hc_electricitymeter:teleinfoUSB:myElectricityMeter:papp"}
Number:ElectricCurrent TLInfoEDF_ISOUSC "ISOUSC" <energy> {channel="teleinfo:cbemm_evolution_icc_hc_electricitymeter:teleinfoUSB:myElectricityMeter:isousc"}
String TLInfoEDF_PTEC "PTEC" <energy> {channel="teleinfo:cbemm_evolution_icc_hc_electricitymeter:teleinfoUSB:myElectricityMeter:ptec"}
Number:ElectricCurrent TLInfoEDF_IMAX "IMAX" <energy> {channel="teleinfo:cbemm_evolution_icc_hc_electricitymeter:teleinfoUSB:myElectricityMeter:imax"}
Number:ElectricCurrent TLInfoEDF_ADPS "ADPS" <energy> {channel="teleinfo:cbemm_evolution_icc_hc_electricitymeter:teleinfoUSB:myElectricityMeter:adps"}
Number:ElectricCurrent TLInfoEDF_IINST "IINST" <energy> {channel="teleinfo:cbemm_evolution_icc_hc_electricitymeter:teleinfoUSB:myElectricityMeter:iinst"}
Number:Energy TLInfoEDF_HCHC "HCHC" <energy> {channel="teleinfo:cbemm_evolution_icc_hc_electricitymeter:teleinfoUSB:myElectricityMeter:hchc"}
Number:Energy TLInfoEDF_HCHP "HCHP" <energy> {channel="teleinfo:cbemm_evolution_icc_hc_electricitymeter:teleinfoUSB:myElectricityMeter:hchp"}
String TLInfoEDF_HHPHC "HHPHC" <energy> {channel="teleinfo:cbemm_evolution_icc_hc_electricitymeter:teleinfoUSB:myElectricityMeter:hhphc"}
```
## Tested hardwares
The Teleinfo binding has been successfully validated with below hardware configuration:
| Serial interface | Power Energy Meter model | Mode(s) |
|----------|--------|------------------------------|
| GCE Electronics USB Teleinfo module [(more details)](http://gce-electronics.com/fr/usb/655-module-teleinfo-usb.html) | Actaris A14C5 | - Single-phase HCHP & Base |
| Cartelectronic USB Teleinfo modem [(more details)](https://www.cartelectronic.fr/teleinfo-compteur-enedis/17-teleinfo-1-compteur-usb-rail-din-3760313520028.html) | Sagem S10C4 | Single-phase HCHP |

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.openhab.binding.teleinfo</artifactId>
<name>openHAB Add-ons :: Bundles :: Teleinfo Binding</name>
</project>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.teleinfo-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository>
<feature name="openhab-binding-teleinfo" description="Teleinfo Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<feature>openhab-transport-serial</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.teleinfo/${project.version}</bundle>
</feature>
</features>

View File

@@ -0,0 +1,127 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingTypeUID;
/**
* The {@link TeleinfoBindingConstants} class defines common constants, which are
* used across the whole binding.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public class TeleinfoBindingConstants {
private static final String BINDING_ID = "teleinfo";
// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_SERIAL_CONTROLLER = new ThingTypeUID(BINDING_ID, "serialcontroller");
public static final String THING_SERIAL_CONTROLLER_CHANNEL_INVALID_FRAME_COUNTER = "invalidFrameCounter";
// List of commons channel ids
public static final String CHANNEL_LAST_UPDATE = "lastUpdate";
// List of HC frames channel ids
public static final String CHANNEL_HC_FRAME_HCHC = "hchc";
public static final String CHANNEL_HC_FRAME_HCHP = "hchp";
public static final String CHANNEL_HC_FRAME_HHPHC = "hhphc";
// List of BASE frames channel ids
public static final String CHANNEL_BASE_FRAME_BASE = "base";
// List of TEMPO frames channel ids
public static final String CHANNEL_TEMPO_FRAME_BBRHPJR = "bbrhpjr";
public static final String CHANNEL_TEMPO_FRAME_BBRHCJR = "bbrhcjr";
public static final String CHANNEL_TEMPO_FRAME_BBRHPJW = "bbrhpjw";
public static final String CHANNEL_TEMPO_FRAME_BBRHCJW = "bbrhcjw";
public static final String CHANNEL_TEMPO_FRAME_BBRHPJB = "bbrhpjb";
public static final String CHANNEL_TEMPO_FRAME_BBRHCJB = "bbrhcjb";
public static final String CHANNEL_TEMPO_FRAME_DEMAIN = "demain";
public static final String CHANNEL_TEMPO_FRAME_HHPHC = "hhphc";
public static final String CHANNEL_TEMPO_FRAME_PROGRAMME_CIRCUIT_1 = "programmeCircuit1";
public static final String CHANNEL_TEMPO_FRAME_PROGRAMME_CIRCUIT_2 = "programmeCircuit2";
// List of EJP frames channel ids
public static final String CHANNEL_EJP_FRAME_PEJP = "pejp";
public static final String CHANNEL_EJP_FRAME_EJPHPM = "ejphpm";
public static final String CHANNEL_EJP_FRAME_EJPHN = "ejphn";
// List of CBEMM Channel ids
public static final String CHANNEL_CBEMM_ISOUSC = "isousc";
public static final String CHANNEL_CBEMM_PTEC = "ptec";
public static final String CHANNEL_CBEMM_IMAX = "imax";
public static final String CHANNEL_CBEMM_ADPS = "adps";
public static final String CHANNEL_CBEMM_IINST = "iinst";
public static final String CHANNEL_CBEMM_MOTDETAT = "motdetat";
// List of CBEMM EVOLUTION ICC Channel ids
public static final String CHANNEL_CBEMM_EVOLUTION_ICC_PAPP = "papp";
// List of CBETM Channel ids
public static final String CHANNEL_CBETM_IINST1 = "iinst1";
public static final String CHANNEL_CBETM_IINST2 = "iinst2";
public static final String CHANNEL_CBETM_IINST3 = "iinst3";
public static final String CHANNEL_CBETM_FRAME_TYPE = "frameType";
public static final String CHANNEL_CBETM_LONG_ISOUSC = "isousc";
public static final String CHANNEL_CBETM_LONG_IMAX1 = "imax1";
public static final String CHANNEL_CBETM_LONG_IMAX2 = "imax2";
public static final String CHANNEL_CBETM_LONG_IMAX3 = "imax3";
public static final String CHANNEL_CBETM_LONG_PTEC = "ptec";
public static final String CHANNEL_CBETM_LONG_PMAX = "pmax";
public static final String CHANNEL_CBETM_LONG_PAPP = "papp";
public static final String CHANNEL_CBETM_LONG_MOTDETAT = "motdetat";
public static final String CHANNEL_CBETM_LONG_PPOT = "ppot";
public static final String CHANNEL_CBETM_SHORT_ADIR1 = "adir1";
public static final String CHANNEL_CBETM_SHORT_ADIR2 = "adir2";
public static final String CHANNEL_CBETM_SHORT_ADIR3 = "adir3";
public static final String THING_ELECTRICITY_METER_PROPERTY_ADCO = "adco";
public static final ThingTypeUID THING_HC_CBEMM_ELECTRICITY_METER_TYPE_UID = new ThingTypeUID(BINDING_ID,
"cbemm_hc_electricitymeter");
public static final ThingTypeUID THING_BASE_CBEMM_ELECTRICITY_METER_TYPE_UID = new ThingTypeUID(BINDING_ID,
"cbemm_base_electricitymeter");
public static final ThingTypeUID THING_EJP_CBEMM_ELECTRICITY_METER_TYPE_UID = new ThingTypeUID(BINDING_ID,
"cbemm_ejp_electricitymeter");
public static final ThingTypeUID THING_TEMPO_CBEMM_ELECTRICITY_METER_TYPE_UID = new ThingTypeUID(BINDING_ID,
"cbemm_tempo_electricitymeter");
public static final ThingTypeUID THING_HC_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID = new ThingTypeUID(BINDING_ID,
"cbemm_evolution_icc_hc_electricitymeter");
public static final ThingTypeUID THING_BASE_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID = new ThingTypeUID(BINDING_ID,
"cbemm_evolution_icc_base_electricitymeter");
public static final ThingTypeUID THING_EJP_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID = new ThingTypeUID(BINDING_ID,
"cbemm_evolution_icc_ejp_electricitymeter");
public static final ThingTypeUID THING_TEMPO_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID = new ThingTypeUID(BINDING_ID,
"cbemm_evolution_icc_tempo_electricitymeter");
public static final ThingTypeUID THING_HC_CBETM_ELECTRICITY_METER_TYPE_UID = new ThingTypeUID(BINDING_ID,
"cbetm_hc_electricitymeter");
public static final ThingTypeUID THING_BASE_CBETM_ELECTRICITY_METER_TYPE_UID = new ThingTypeUID(BINDING_ID,
"cbetm_base_electricitymeter");
public static final ThingTypeUID THING_EJP_CBETM_ELECTRICITY_METER_TYPE_UID = new ThingTypeUID(BINDING_ID,
"cbetm_ejp_electricitymeter");
public static final ThingTypeUID THING_TEMPO_CBETM_ELECTRICITY_METER_TYPE_UID = new ThingTypeUID(BINDING_ID,
"cbetm_tempo_electricitymeter");
public static final String ERROR_OFFLINE_SERIAL_NOT_FOUND = "@text/teleinfo.thingstate.serial_notfound";
public static final String ERROR_OFFLINE_SERIAL_INUSE = "@text/teleinfo.thingstate.serial_inuse";
public static final String ERROR_OFFLINE_SERIAL_UNSUPPORTED = "@text/teleinfo.thingstate.serial_unsupported";
public static final String ERROR_OFFLINE_SERIAL_LISTENERS = "@text/teleinfo.thingstate.serial_listeners";
public static final String ERROR_OFFLINE_CONTROLLER_OFFLINE = "@text/teleinfo.thingstate.controller_offline";
public static final String ERROR_UNKNOWN_RETRY_IN_PROGRESS = "@text/teleinfo.thingstate.controller_unknown_retry_inprogress";
}

View File

@@ -0,0 +1,231 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal;
import static org.openhab.binding.teleinfo.internal.TeleinfoBindingConstants.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.teleinfo.internal.dto.Frame;
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmBaseOption;
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmEjpOption;
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmHcOption;
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmTempoOption;
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccBaseOption;
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccEjpOption;
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccHcOption;
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccTempoOption;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongBaseOption;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongEjpOption;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongHcOption;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongTempoOption;
import org.openhab.binding.teleinfo.internal.dto.common.FrameAdco;
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
import org.openhab.binding.teleinfo.internal.handler.TeleinfoControllerHandlerListener;
import org.openhab.core.config.discovery.AbstractDiscoveryService;
import org.openhab.core.config.discovery.DiscoveryResult;
import org.openhab.core.config.discovery.DiscoveryResultBuilder;
import org.openhab.core.config.discovery.DiscoveryService;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.ThingUID;
import org.openhab.core.thing.binding.ThingHandler;
import org.openhab.core.thing.binding.ThingHandlerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The {@link TeleinfoDiscoveryService} class is the service to discover a skeleton for controller handlers.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public class TeleinfoDiscoveryService extends AbstractDiscoveryService
implements TeleinfoControllerHandlerListener, ThingHandlerService, DiscoveryService {
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Stream.of(THING_HC_CBEMM_ELECTRICITY_METER_TYPE_UID,
THING_BASE_CBEMM_ELECTRICITY_METER_TYPE_UID, THING_TEMPO_CBEMM_ELECTRICITY_METER_TYPE_UID,
THING_EJP_CBEMM_ELECTRICITY_METER_TYPE_UID, THING_HC_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID,
THING_BASE_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID, THING_TEMPO_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID,
THING_EJP_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID, THING_HC_CBETM_ELECTRICITY_METER_TYPE_UID,
THING_BASE_CBETM_ELECTRICITY_METER_TYPE_UID, THING_TEMPO_CBETM_ELECTRICITY_METER_TYPE_UID,
THING_EJP_CBETM_ELECTRICITY_METER_TYPE_UID).collect(Collectors.toSet());
private static final int SCAN_DURATION_IN_S = 60;
private final Logger logger = LoggerFactory.getLogger(TeleinfoDiscoveryService.class);
private @Nullable TeleinfoAbstractControllerHandler controllerHandler;
public TeleinfoDiscoveryService() {
super(SCAN_DURATION_IN_S);
}
public TeleinfoDiscoveryService(TeleinfoAbstractControllerHandler controllerHandler) {
super(SCAN_DURATION_IN_S);
this.controllerHandler = controllerHandler;
}
@Override
public Set<ThingTypeUID> getSupportedThingTypes() {
return SUPPORTED_THING_TYPES;
}
public void activate() {
TeleinfoAbstractControllerHandler controllerHandlerRef = controllerHandler;
if (controllerHandlerRef != null) {
logger.debug("Teleinfo discovery: Activate {}", controllerHandlerRef.getThing().getUID());
} else {
logNullControllerHandler();
}
}
@Override
public void deactivate() {
TeleinfoAbstractControllerHandler controllerHandlerRef = controllerHandler;
if (controllerHandlerRef != null) {
logger.debug("Teleinfo discovery: Deactivate {}", controllerHandlerRef.getThing().getUID());
} else {
logNullControllerHandler();
}
}
@Override
protected void startScan() {
TeleinfoAbstractControllerHandler controllerHandlerRef = controllerHandler;
if (controllerHandlerRef != null) {
logger.debug("Teleinfo discovery: Start {}", controllerHandlerRef.getThing().getUID());
// Start the search for new devices
controllerHandlerRef.addListener(this);
} else {
logNullControllerHandler();
}
}
@Override
public synchronized void abortScan() {
TeleinfoAbstractControllerHandler controllerHandlerRef = controllerHandler;
if (controllerHandlerRef != null) {
logger.debug("Teleinfo discovery: Abort {}", controllerHandlerRef.getThing().getUID());
controllerHandlerRef.removeListener(this);
super.abortScan();
} else {
logNullControllerHandler();
}
}
@Override
protected synchronized void stopScan() {
TeleinfoAbstractControllerHandler controllerHandlerRef = controllerHandler;
if (controllerHandlerRef != null) {
logger.debug("Teleinfo discovery: Stop {}", controllerHandlerRef.getThing().getUID());
controllerHandlerRef.removeListener(this);
super.stopScan();
} else {
logNullControllerHandler();
}
}
@Override
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
detectNewElectricityMeterFromReceivedFrame(frame);
}
private void detectNewElectricityMeterFromReceivedFrame(final Frame frameSample) {
TeleinfoAbstractControllerHandler controllerHandlerRef = controllerHandler;
if (controllerHandlerRef != null) {
logger.debug("New eletricity meter detection from frame {}", frameSample.getId());
if (!(frameSample instanceof FrameAdco)) {
throw new IllegalStateException("Teleinfo frame type not supported: " + frameSample.getClass());
}
final FrameAdco frameAdco = (FrameAdco) frameSample;
ThingUID thingUID = new ThingUID(getThingTypeUID(frameAdco), frameAdco.getAdco(),
controllerHandlerRef.getThing().getUID().getId());
final Map<String, Object> properties = getThingProperties(frameAdco);
final String representationProperty = THING_ELECTRICITY_METER_PROPERTY_ADCO;
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties)
.withLabel("Teleinfo ADCO " + frameAdco.getAdco()).withThingType(getThingTypeUID(frameAdco))
.withBridge(controllerHandlerRef.getThing().getUID())
.withRepresentationProperty(representationProperty).build();
thingDiscovered(discoveryResult);
} else {
logNullControllerHandler();
}
}
private ThingTypeUID getThingTypeUID(final Frame teleinfoFrame) {
if (teleinfoFrame instanceof FrameCbemmHcOption) {
return THING_HC_CBEMM_ELECTRICITY_METER_TYPE_UID;
} else if (teleinfoFrame instanceof FrameCbemmBaseOption) {
return THING_BASE_CBEMM_ELECTRICITY_METER_TYPE_UID;
} else if (teleinfoFrame instanceof FrameCbemmEjpOption) {
return THING_EJP_CBEMM_ELECTRICITY_METER_TYPE_UID;
} else if (teleinfoFrame instanceof FrameCbemmTempoOption) {
return THING_TEMPO_CBEMM_ELECTRICITY_METER_TYPE_UID;
} else if (teleinfoFrame instanceof FrameCbemmEvolutionIccHcOption) {
return THING_HC_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID;
} else if (teleinfoFrame instanceof FrameCbemmEvolutionIccBaseOption) {
return THING_BASE_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID;
} else if (teleinfoFrame instanceof FrameCbemmEvolutionIccEjpOption) {
return THING_EJP_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID;
} else if (teleinfoFrame instanceof FrameCbemmEvolutionIccTempoOption) {
return THING_TEMPO_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID;
} else if (teleinfoFrame instanceof FrameCbetmLongHcOption) {
return THING_HC_CBETM_ELECTRICITY_METER_TYPE_UID;
} else if (teleinfoFrame instanceof FrameCbetmLongBaseOption) {
return THING_BASE_CBETM_ELECTRICITY_METER_TYPE_UID;
} else if (teleinfoFrame instanceof FrameCbetmLongEjpOption) {
return THING_EJP_CBETM_ELECTRICITY_METER_TYPE_UID;
} else if (teleinfoFrame instanceof FrameCbetmLongTempoOption) {
return THING_TEMPO_CBETM_ELECTRICITY_METER_TYPE_UID;
} else {
throw new IllegalStateException("Teleinfo frame type not supported: " + teleinfoFrame.getClass());
}
}
private Map<String, Object> getThingProperties(final Frame teleinfoFrame) {
Map<String, Object> properties = new HashMap<String, Object>();
if (teleinfoFrame instanceof FrameAdco) {
final FrameAdco frameAdco = (FrameAdco) teleinfoFrame;
properties.put(THING_ELECTRICITY_METER_PROPERTY_ADCO, frameAdco.getAdco());
return properties;
}
throw new IllegalStateException("Teleinfo frame type not supported: " + teleinfoFrame.getClass());
}
@Override
public void setThingHandler(@Nullable ThingHandler handler) {
if (handler instanceof TeleinfoAbstractControllerHandler) {
controllerHandler = (TeleinfoAbstractControllerHandler) handler;
}
}
@Override
public @Nullable ThingHandler getThingHandler() {
return controllerHandler;
}
private void logNullControllerHandler() {
logger.warn("Null controller handler");
}
}

View File

@@ -0,0 +1,50 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.UUID;
/**
* The {@link Frame} class defines common attributes for any Teleinfo frames.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public abstract class Frame implements Serializable {
private static final long serialVersionUID = -1934715078822532494L;
private UUID id;
private LocalDate timestamp; // UTC timestamp
public Frame() {
// default constructor
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public LocalDate getTimestamp() {
return timestamp;
}
public void setTimestamp(LocalDate timestamp) {
this.timestamp = timestamp;
}
}

View File

@@ -0,0 +1,85 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.cbemm;
import org.openhab.binding.teleinfo.internal.dto.common.FrameAdco;
import org.openhab.binding.teleinfo.internal.dto.common.Ptec;
/**
* The {@link FrameCbemm} class defines common attributes for CBEMM Teleinfo frames.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public abstract class FrameCbemm extends FrameAdco {
private static final long serialVersionUID = -8500010131430582841L;
private int isousc;
private int iinst; // ampères
private Integer adps; // ampères
private Integer imax; // ampères
private Ptec ptec;
private String motdetat;
public FrameCbemm() {
// default constructor
}
public int getIsousc() {
return isousc;
}
public void setIsousc(int isousc) {
this.isousc = isousc;
}
public int getIinst() {
return iinst;
}
public void setIinst(int iinst) {
this.iinst = iinst;
}
public Integer getAdps() {
return adps;
}
public void setAdps(Integer adps) {
this.adps = adps;
}
public Integer getImax() {
return imax;
}
public void setImax(Integer imax) {
this.imax = imax;
}
public Ptec getPtec() {
return ptec;
}
public void setPtec(Ptec ptec) {
this.ptec = ptec;
}
public String getMotdetat() {
return motdetat;
}
public void setMotdetat(String motdetat) {
this.motdetat = motdetat;
}
}

View File

@@ -0,0 +1,41 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.cbemm;
import org.openhab.binding.teleinfo.internal.dto.common.FrameBaseOption;
/**
* The {@link FrameCbemmBaseOption} class defines a CBEMM Teleinfo frame with Base option.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public class FrameCbemmBaseOption extends FrameCbemm implements FrameBaseOption {
private static final long serialVersionUID = 5560141193379363335L;
private int base;
public FrameCbemmBaseOption() {
// default constructor
}
@Override
public int getBase() {
return base;
}
@Override
public void setBase(int base) {
this.base = base;
}
}

View File

@@ -0,0 +1,63 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.cbemm;
import org.openhab.binding.teleinfo.internal.dto.common.FrameEjpOption;
/**
* The {@link FrameCbemmEjpOption} class defines a CBEMM Teleinfo frame with EJP option.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public class FrameCbemmEjpOption extends FrameCbemm implements FrameEjpOption {
private static final long serialVersionUID = -1934715078822532494L;
private int ejphpm;
private int ejphn;
private Integer pejp;
public FrameCbemmEjpOption() {
// default constructor
}
@Override
public int getEjphpm() {
return ejphpm;
}
@Override
public int getEjphn() {
return ejphn;
}
@Override
public Integer getPejp() {
return pejp;
}
@Override
public void setEjphpm(int ejphpm) {
this.ejphpm = ejphpm;
}
@Override
public void setEjphn(int ejphn) {
this.ejphn = ejphn;
}
@Override
public void setPejp(Integer pejp) {
this.pejp = pejp;
}
}

View File

@@ -0,0 +1,64 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.cbemm;
import org.openhab.binding.teleinfo.internal.dto.common.FrameHcOption;
import org.openhab.binding.teleinfo.internal.dto.common.Hhphc;
/**
* The {@link FrameCbemmHcOption} class defines a CBEMM Teleinfo frame with HC/HP option.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public class FrameCbemmHcOption extends FrameCbemm implements FrameHcOption {
private static final long serialVersionUID = -1934715078822532494L;
private int hchc;
private int hchp;
private Hhphc hhphc;
public FrameCbemmHcOption() {
// default constructor
}
@Override
public int getHchc() {
return hchc;
}
@Override
public void setHchc(int hchc) {
this.hchc = hchc;
}
@Override
public int getHchp() {
return hchp;
}
@Override
public void setHchp(int hchp) {
this.hchp = hchp;
}
@Override
public Hhphc getHhphc() {
return hhphc;
}
@Override
public void setHhphc(Hhphc hhphc) {
this.hhphc = hhphc;
}
}

View File

@@ -0,0 +1,141 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.cbemm;
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption;
import org.openhab.binding.teleinfo.internal.dto.common.Hhphc;
/**
* The {@link FrameCbemmTempoOption} class defines a CBEMM Teleinfo frame with Tempo option.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public class FrameCbemmTempoOption extends FrameCbemm implements FrameTempoOption {
private static final long serialVersionUID = 6423861816467362730L;
private int bbrhpjr;
private int bbrhcjr;
private int bbrhpjw;
private int bbrhcjw;
private int bbrhpjb;
private int bbrhcjb;
private CouleurDemain demain;
private Hhphc hhphc;
private ProgrammeCircuit1 programmeCircuit1;
private ProgrammeCircuit2 programmeCircuit2;
public FrameCbemmTempoOption() {
// default constructor
}
@Override
public int getBbrhpjr() {
return bbrhpjr;
}
@Override
public int getBbrhcjr() {
return bbrhcjr;
}
@Override
public int getBbrhpjw() {
return bbrhpjw;
}
@Override
public int getBbrhcjw() {
return bbrhcjw;
}
@Override
public int getBbrhpjb() {
return bbrhpjb;
}
@Override
public int getBbrhcjb() {
return bbrhcjb;
}
@Override
public CouleurDemain getDemain() {
return demain;
}
@Override
public void setBbrhpjr(int bbrhpjr) {
this.bbrhpjr = bbrhpjr;
}
@Override
public void setBbrhcjr(int bbrhcjr) {
this.bbrhcjr = bbrhcjr;
}
@Override
public void setBbrhpjw(int bbrhpjw) {
this.bbrhpjw = bbrhpjw;
}
@Override
public void setBbrhcjw(int bbrhcjw) {
this.bbrhcjw = bbrhcjw;
}
@Override
public void setBbrhpjb(int bbrhpjb) {
this.bbrhpjb = bbrhpjb;
}
@Override
public void setBbrhcjb(int bbrhcjb) {
this.bbrhcjb = bbrhcjb;
}
@Override
public void setDemain(CouleurDemain demain) {
this.demain = demain;
}
@Override
public Hhphc getHhphc() {
return hhphc;
}
@Override
public void setHhphc(Hhphc hhphc) {
this.hhphc = hhphc;
}
@Override
public ProgrammeCircuit1 getProgrammeCircuit1() {
return programmeCircuit1;
}
@Override
public void setProgrammeCircuit1(ProgrammeCircuit1 programmeCircuit1) {
this.programmeCircuit1 = programmeCircuit1;
}
@Override
public ProgrammeCircuit2 getProgrammeCircuit2() {
return programmeCircuit2;
}
@Override
public void setProgrammeCircuit2(ProgrammeCircuit2 programmeCircuit2) {
this.programmeCircuit2 = programmeCircuit2;
}
}

View File

@@ -0,0 +1,39 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc;
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemm;
/**
* The {@link FrameCbemmEvolutionIcc} class defines CBEMM Evolution ICC Teleinfo frames.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public abstract class FrameCbemmEvolutionIcc extends FrameCbemm {
private static final long serialVersionUID = 5532008316299149750L;
private int papp; // Volt.ampères
public FrameCbemmEvolutionIcc() {
// default constructor
}
public int getPapp() {
return papp;
}
public void setPapp(int papp) {
this.papp = papp;
}
}

View File

@@ -0,0 +1,41 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc;
import org.openhab.binding.teleinfo.internal.dto.common.FrameBaseOption;
/**
* The {@link FrameCbemmEvolutionIccBaseOption} class defines a CBEMM Evolution ICC Teleinfo frame with Base option.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public class FrameCbemmEvolutionIccBaseOption extends FrameCbemmEvolutionIcc implements FrameBaseOption {
private static final long serialVersionUID = 1623781914779495089L;
private int base;
public FrameCbemmEvolutionIccBaseOption() {
// default constructor
}
@Override
public int getBase() {
return base;
}
@Override
public void setBase(int base) {
this.base = base;
}
}

View File

@@ -0,0 +1,63 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc;
import org.openhab.binding.teleinfo.internal.dto.common.FrameEjpOption;
/**
* The {@link FrameCbemmEvolutionIccEjpOption} class defines a CBEMM Evolution ICC Teleinfo frame with EJP option.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public class FrameCbemmEvolutionIccEjpOption extends FrameCbemmEvolutionIcc implements FrameEjpOption {
private static final long serialVersionUID = -5053572570767309239L;
private int ejphpm;
private int ejphn;
private Integer pejp;
public FrameCbemmEvolutionIccEjpOption() {
// default constructor
}
@Override
public int getEjphpm() {
return ejphpm;
}
@Override
public int getEjphn() {
return ejphn;
}
@Override
public Integer getPejp() {
return pejp;
}
@Override
public void setEjphpm(int ejphpm) {
this.ejphpm = ejphpm;
}
@Override
public void setEjphn(int ejphn) {
this.ejphn = ejphn;
}
@Override
public void setPejp(Integer pejp) {
this.pejp = pejp;
}
}

View File

@@ -0,0 +1,64 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc;
import org.openhab.binding.teleinfo.internal.dto.common.FrameHcOption;
import org.openhab.binding.teleinfo.internal.dto.common.Hhphc;
/**
* The {@link FrameCbemmEvolutionIccHcOption} class defines a CBEMM Evolution ICC Teleinfo frame with HC option.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public class FrameCbemmEvolutionIccHcOption extends FrameCbemmEvolutionIcc implements FrameHcOption {
private static final long serialVersionUID = 3133144820515675037L;
private int hchc;
private int hchp;
private Hhphc hhphc;
public FrameCbemmEvolutionIccHcOption() {
// default constructor
}
@Override
public int getHchc() {
return hchc;
}
@Override
public void setHchc(int hchc) {
this.hchc = hchc;
}
@Override
public int getHchp() {
return hchp;
}
@Override
public void setHchp(int hchp) {
this.hchp = hchp;
}
@Override
public Hhphc getHhphc() {
return hhphc;
}
@Override
public void setHhphc(Hhphc hhphc) {
this.hhphc = hhphc;
}
}

View File

@@ -0,0 +1,141 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc;
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption;
import org.openhab.binding.teleinfo.internal.dto.common.Hhphc;
/**
* The {@link FrameCbemmEvolutionIccTempoOption} class defines a CBEMM Evolution ICC Teleinfo frame with Tempo option.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public class FrameCbemmEvolutionIccTempoOption extends FrameCbemmEvolutionIcc implements FrameTempoOption {
private static final long serialVersionUID = -1606685089266015480L;
private int bbrhpjr;
private int bbrhcjr;
private int bbrhpjw;
private int bbrhcjw;
private int bbrhpjb;
private int bbrhcjb;
private CouleurDemain demain;
private Hhphc hhphc;
private ProgrammeCircuit1 programmeCircuit1;
private ProgrammeCircuit2 programmeCircuit2;
public FrameCbemmEvolutionIccTempoOption() {
// default constructor
}
@Override
public int getBbrhpjr() {
return bbrhpjr;
}
@Override
public int getBbrhcjr() {
return bbrhcjr;
}
@Override
public int getBbrhpjw() {
return bbrhpjw;
}
@Override
public int getBbrhcjw() {
return bbrhcjw;
}
@Override
public int getBbrhpjb() {
return bbrhpjb;
}
@Override
public int getBbrhcjb() {
return bbrhcjb;
}
@Override
public CouleurDemain getDemain() {
return demain;
}
@Override
public void setBbrhpjr(int bbrhpjr) {
this.bbrhpjr = bbrhpjr;
}
@Override
public void setBbrhcjr(int bbrhcjr) {
this.bbrhcjr = bbrhcjr;
}
@Override
public void setBbrhpjw(int bbrhpjw) {
this.bbrhpjw = bbrhpjw;
}
@Override
public void setBbrhcjw(int bbrhcjw) {
this.bbrhcjw = bbrhcjw;
}
@Override
public void setBbrhpjb(int bbrhpjb) {
this.bbrhpjb = bbrhpjb;
}
@Override
public void setBbrhcjb(int bbrhcjb) {
this.bbrhcjb = bbrhcjb;
}
@Override
public void setDemain(CouleurDemain demain) {
this.demain = demain;
}
@Override
public Hhphc getHhphc() {
return hhphc;
}
@Override
public void setHhphc(Hhphc hhphc) {
this.hhphc = hhphc;
}
@Override
public ProgrammeCircuit1 getProgrammeCircuit1() {
return programmeCircuit1;
}
@Override
public void setProgrammeCircuit1(ProgrammeCircuit1 programmeCircuit1) {
this.programmeCircuit1 = programmeCircuit1;
}
@Override
public ProgrammeCircuit2 getProgrammeCircuit2() {
return programmeCircuit2;
}
@Override
public void setProgrammeCircuit2(ProgrammeCircuit2 programmeCircuit2) {
this.programmeCircuit2 = programmeCircuit2;
}
}

View File

@@ -0,0 +1,57 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.cbetm;
import org.openhab.binding.teleinfo.internal.dto.common.FrameAdco;
/**
* The {@link FrameCbetm} class defines common attributes for CBETM Teleinfo frames.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public abstract class FrameCbetm extends FrameAdco {
private static final long serialVersionUID = 2083723009359732507L;
private int iinst1; // ampères
private int iinst2; // ampères
private int iinst3; // ampères
public FrameCbetm() {
// default constructor
}
public int getIinst1() {
return iinst1;
}
public void setIinst1(int iinst1) {
this.iinst1 = iinst1;
}
public int getIinst2() {
return iinst2;
}
public void setIinst2(int iinst2) {
this.iinst2 = iinst2;
}
public int getIinst3() {
return iinst3;
}
public void setIinst3(int iinst3) {
this.iinst3 = iinst3;
}
}

View File

@@ -0,0 +1,111 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.cbetm;
import org.openhab.binding.teleinfo.internal.dto.common.Ptec;
/**
* The {@link FrameCbetmLong} class defines common attributes for CBETM Long Teleinfo frames.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public abstract class FrameCbetmLong extends FrameCbetm {
private static final long serialVersionUID = -2527584397688316017L;
private int isousc;
private Integer imax1; // ampères
private Integer imax2; // ampères
private Integer imax3; // ampères
private Ptec ptec;
private int pmax; // W
private int papp; // Volt.ampères
private String motdetat;
private String ppot;
public FrameCbetmLong() {
// default constructor
}
public int getIsousc() {
return isousc;
}
public void setIsousc(int isousc) {
this.isousc = isousc;
}
public Integer getImax1() {
return imax1;
}
public void setImax1(Integer imax1) {
this.imax1 = imax1;
}
public Integer getImax2() {
return imax2;
}
public void setImax2(Integer imax2) {
this.imax2 = imax2;
}
public Integer getImax3() {
return imax3;
}
public void setImax3(Integer imax3) {
this.imax3 = imax3;
}
public Ptec getPtec() {
return ptec;
}
public void setPtec(Ptec ptec) {
this.ptec = ptec;
}
public int getPmax() {
return pmax;
}
public void setPmax(int pmax) {
this.pmax = pmax;
}
public int getPapp() {
return papp;
}
public void setPapp(int papp) {
this.papp = papp;
}
public String getMotdetat() {
return motdetat;
}
public void setMotdetat(String motdetat) {
this.motdetat = motdetat;
}
public String getPpot() {
return ppot;
}
public void setPpot(String ppot) {
this.ppot = ppot;
}
}

View File

@@ -0,0 +1,41 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.cbetm;
import org.openhab.binding.teleinfo.internal.dto.common.FrameBaseOption;
/**
* The {@link FrameCbetmLongBaseOption} class defines a CBETM Teleinfo frame with Base option.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public class FrameCbetmLongBaseOption extends FrameCbetmLong implements FrameBaseOption {
private static final long serialVersionUID = 7248276012515193856L;
private int base;
public FrameCbetmLongBaseOption() {
// default constructor
}
@Override
public int getBase() {
return base;
}
@Override
public void setBase(int base) {
this.base = base;
}
}

View File

@@ -0,0 +1,63 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.cbetm;
import org.openhab.binding.teleinfo.internal.dto.common.FrameEjpOption;
/**
* The {@link FrameCbetmLongEjpOption} class defines a CBETM Teleinfo frame with EJP option.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public class FrameCbetmLongEjpOption extends FrameCbetmLong implements FrameEjpOption {
private static final long serialVersionUID = 1104569000621483323L;
private int ejphpm;
private int ejphn;
private Integer pejp;
public FrameCbetmLongEjpOption() {
// default constructor
}
@Override
public int getEjphpm() {
return ejphpm;
}
@Override
public int getEjphn() {
return ejphn;
}
@Override
public Integer getPejp() {
return pejp;
}
@Override
public void setEjphpm(int ejphpm) {
this.ejphpm = ejphpm;
}
@Override
public void setEjphn(int ejphn) {
this.ejphn = ejphn;
}
@Override
public void setPejp(Integer pejp) {
this.pejp = pejp;
}
}

View File

@@ -0,0 +1,64 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.cbetm;
import org.openhab.binding.teleinfo.internal.dto.common.FrameHcOption;
import org.openhab.binding.teleinfo.internal.dto.common.Hhphc;
/**
* The {@link FrameCbetmLongHcOption} class defines a CBETM Teleinfo frame with HC/HP option.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public class FrameCbetmLongHcOption extends FrameCbetmLong implements FrameHcOption {
private static final long serialVersionUID = -590729310348196198L;
private int hchc;
private int hchp;
private Hhphc hhphc;
public FrameCbetmLongHcOption() {
// default constructor
}
@Override
public int getHchc() {
return hchc;
}
@Override
public void setHchc(int hchc) {
this.hchc = hchc;
}
@Override
public int getHchp() {
return hchp;
}
@Override
public void setHchp(int hchp) {
this.hchp = hchp;
}
@Override
public Hhphc getHhphc() {
return hhphc;
}
@Override
public void setHhphc(Hhphc hhphc) {
this.hhphc = hhphc;
}
}

View File

@@ -0,0 +1,141 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.cbetm;
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption;
import org.openhab.binding.teleinfo.internal.dto.common.Hhphc;
/**
* The {@link FrameCbetmLongTempoOption} class defines a CBETM Teleinfo frame with Tempo option.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public class FrameCbetmLongTempoOption extends FrameCbetmLong implements FrameTempoOption {
private static final long serialVersionUID = 333018110121838463L;
private int bbrhpjr;
private int bbrhcjr;
private int bbrhpjw;
private int bbrhcjw;
private int bbrhpjb;
private int bbrhcjb;
private CouleurDemain demain;
private Hhphc hhphc;
private ProgrammeCircuit1 programmeCircuit1;
private ProgrammeCircuit2 programmeCircuit2;
public FrameCbetmLongTempoOption() {
// default constructor
}
@Override
public int getBbrhpjr() {
return bbrhpjr;
}
@Override
public int getBbrhcjr() {
return bbrhcjr;
}
@Override
public int getBbrhpjw() {
return bbrhpjw;
}
@Override
public int getBbrhcjw() {
return bbrhcjw;
}
@Override
public int getBbrhpjb() {
return bbrhpjb;
}
@Override
public int getBbrhcjb() {
return bbrhcjb;
}
@Override
public CouleurDemain getDemain() {
return demain;
}
@Override
public void setBbrhpjr(int bbrhpjr) {
this.bbrhpjr = bbrhpjr;
}
@Override
public void setBbrhcjr(int bbrhcjr) {
this.bbrhcjr = bbrhcjr;
}
@Override
public void setBbrhpjw(int bbrhpjw) {
this.bbrhpjw = bbrhpjw;
}
@Override
public void setBbrhcjw(int bbrhcjw) {
this.bbrhcjw = bbrhcjw;
}
@Override
public void setBbrhpjb(int bbrhpjb) {
this.bbrhpjb = bbrhpjb;
}
@Override
public void setBbrhcjb(int bbrhcjb) {
this.bbrhcjb = bbrhcjb;
}
@Override
public void setDemain(CouleurDemain demain) {
this.demain = demain;
}
@Override
public Hhphc getHhphc() {
return hhphc;
}
@Override
public void setHhphc(Hhphc hhphc) {
this.hhphc = hhphc;
}
@Override
public ProgrammeCircuit1 getProgrammeCircuit1() {
return programmeCircuit1;
}
@Override
public void setProgrammeCircuit1(ProgrammeCircuit1 programmeCircuit1) {
this.programmeCircuit1 = programmeCircuit1;
}
@Override
public ProgrammeCircuit2 getProgrammeCircuit2() {
return programmeCircuit2;
}
@Override
public void setProgrammeCircuit2(ProgrammeCircuit2 programmeCircuit2) {
this.programmeCircuit2 = programmeCircuit2;
}
}

View File

@@ -0,0 +1,55 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.cbetm;
/**
* The {@link FrameCbetmShort} class defines a CBETM Short Teleinfo frames.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public class FrameCbetmShort extends FrameCbetm {
private static final long serialVersionUID = 4269743289079544119L;
private Integer adir1; // ampères
private Integer adir2; // ampères
private Integer adir3; // ampères
public FrameCbetmShort() {
// default constructor
}
public Integer getAdir1() {
return adir1;
}
public void setAdir1(Integer adir1) {
this.adir1 = adir1;
}
public Integer getAdir2() {
return adir2;
}
public void setAdir2(Integer adir2) {
this.adir2 = adir2;
}
public Integer getAdir3() {
return adir3;
}
public void setAdir3(Integer adir3) {
this.adir3 = adir3;
}
}

View File

@@ -0,0 +1,39 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.common;
import org.openhab.binding.teleinfo.internal.dto.Frame;
/**
* The {@link FrameAdco} class defines common attributes for CBEMM and CBETM Teleinfo frames.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public abstract class FrameAdco extends Frame {
private static final long serialVersionUID = 1384731471611580773L;
private String adco;
public FrameAdco() {
// default constructor
}
public String getAdco() {
return adco;
}
public void setAdco(String adco) {
this.adco = adco;
}
}

View File

@@ -0,0 +1,25 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.common;
/**
* The {@link FrameBaseOption} interface defines common attributes for Base option.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public interface FrameBaseOption {
int getBase();
void setBase(int base);
}

View File

@@ -0,0 +1,33 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.common;
/**
* The {@link FrameEjpOption} interface defines common attributes for EJP option.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public interface FrameEjpOption {
int getEjphpm();
void setEjphpm(int ejphpm);
int getEjphn();
void setEjphn(int ejphn);
Integer getPejp();
void setPejp(Integer pejp);
}

View File

@@ -0,0 +1,33 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.common;
/**
* The {@link FrameHcOption} interface defines common attributes for HC option.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public interface FrameHcOption {
int getHchc();
void setHchc(int hchc);
int getHchp();
void setHchp(int hchp);
Hhphc getHhphc();
void setHhphc(Hhphc hhphc);
}

View File

@@ -0,0 +1,84 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.common;
/**
* The {@link FrameTempoOption} interface defines common attributes for Tempo option.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public interface FrameTempoOption {
public static enum CouleurDemain {
Bleu,
Blanc,
Rouge
}
public static enum ProgrammeCircuit1 {
A,
B,
C
}
public static enum ProgrammeCircuit2 {
P0,
P1,
P2,
P3,
P4,
P5,
P6,
P7
}
int getBbrhpjr();
void setBbrhpjr(int bbrhpjr);
int getBbrhcjr();
void setBbrhcjr(int bbrhcjr);
int getBbrhpjw();
void setBbrhpjw(int bbrhpjw);
int getBbrhcjw();
void setBbrhcjw(int bbrhcjw);
int getBbrhpjb();
void setBbrhpjb(int bbrhpjb);
int getBbrhcjb();
void setBbrhcjb(int bbrhcjb);
CouleurDemain getDemain();
void setDemain(CouleurDemain couleurDemain);
Hhphc getHhphc();
void setHhphc(Hhphc hhphc);
ProgrammeCircuit1 getProgrammeCircuit1();
void setProgrammeCircuit1(ProgrammeCircuit1 programmeCircuit1);
ProgrammeCircuit2 getProgrammeCircuit2();
void setProgrammeCircuit2(ProgrammeCircuit2 programmeCircuit2);
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.common;
/**
* The {@link Hhphc} enumeration defines all HHPHC values.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public enum Hhphc {
A,
C,
D,
E,
Y
}

View File

@@ -0,0 +1,32 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.dto.common;
/**
* The {@link Ptec} enumeration defines all PTEC values.
*
* @author Nicolas SIBERIL - Initial contribution
*/
public enum Ptec {
TH,
HC,
HP,
HN,
PM,
HCJB,
HCJW,
HCJR,
HPJB,
HPJW,
HPJR
}

View File

@@ -0,0 +1,57 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.handler;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.teleinfo.internal.TeleinfoDiscoveryService;
import org.openhab.binding.teleinfo.internal.dto.Frame;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.binding.BaseBridgeHandler;
import org.openhab.core.thing.binding.ThingHandlerService;
/**
* The {@link TeleinfoAbstractControllerHandler} class defines a skeleton for controller handlers.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public abstract class TeleinfoAbstractControllerHandler extends BaseBridgeHandler {
private List<TeleinfoControllerHandlerListener> listeners = Collections.synchronizedList(new ArrayList<>());
public TeleinfoAbstractControllerHandler(Bridge bridge) {
super(bridge);
}
public void addListener(final TeleinfoControllerHandlerListener listener) {
listeners.add(listener);
}
public void removeListener(final TeleinfoControllerHandlerListener listener) {
listeners.remove(listener);
}
protected void fireOnFrameReceivedEvent(final Frame frame) {
listeners.forEach(l -> l.onFrameReceived(this, frame));
}
@Override
public Collection<Class<? extends ThingHandlerService>> getServices() {
return Collections.singleton(TeleinfoDiscoveryService.class);
}
}

View File

@@ -0,0 +1,159 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.handler;
import static org.openhab.binding.teleinfo.internal.TeleinfoBindingConstants.*;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.teleinfo.internal.dto.common.FrameBaseOption;
import org.openhab.binding.teleinfo.internal.dto.common.FrameEjpOption;
import org.openhab.binding.teleinfo.internal.dto.common.FrameHcOption;
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.Channel;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.ThingStatusDetail;
import org.openhab.core.thing.ThingStatusInfo;
import org.openhab.core.thing.binding.BaseThingHandler;
import org.openhab.core.types.Command;
import org.openhab.core.types.UnDefType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The {@link TeleinfoAbstractElectricityMeterHandler} class defines a skeleton for Electricity Meters handlers.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public abstract class TeleinfoAbstractElectricityMeterHandler extends BaseThingHandler
implements TeleinfoControllerHandlerListener {
private final Logger logger = LoggerFactory.getLogger(TeleinfoAbstractElectricityMeterHandler.class);
protected TeleinfoElectricityMeterConfiguration configuration = new TeleinfoElectricityMeterConfiguration();
public TeleinfoAbstractElectricityMeterHandler(Thing thing) {
super(thing);
}
@Override
public void initialize() {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, ERROR_OFFLINE_CONTROLLER_OFFLINE);
Bridge bridge = getBridge();
logger.debug("bridge = {}", bridge);
if (bridge != null) {
bridgeStatusChanged(bridge.getStatusInfo());
}
configuration = getConfigAs(TeleinfoElectricityMeterConfiguration.class);
}
@Override
public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) {
if (bridgeStatusInfo.getStatus() != ThingStatus.ONLINE) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, ERROR_OFFLINE_CONTROLLER_OFFLINE);
return;
}
Bridge bridge = getBridge();
if (bridge != null) {
TeleinfoAbstractControllerHandler controllerHandler = (TeleinfoAbstractControllerHandler) bridge
.getHandler();
if (controllerHandler != null) {
controllerHandler.addListener(this);
updateStatus(ThingStatus.ONLINE);
}
}
}
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
// no commands supported
}
protected void updateStatesForBaseFrameOption(FrameBaseOption frameBaseOption) {
updateState(CHANNEL_BASE_FRAME_BASE, QuantityType.valueOf(frameBaseOption.getBase(), SmartHomeUnits.WATT_HOUR));
}
protected void updateStatesForHcFrameOption(FrameHcOption frameHcOption) {
updateState(CHANNEL_HC_FRAME_HCHC, QuantityType.valueOf(frameHcOption.getHchc(), SmartHomeUnits.WATT_HOUR));
updateState(CHANNEL_HC_FRAME_HCHP, QuantityType.valueOf(frameHcOption.getHchp(), SmartHomeUnits.WATT_HOUR));
updateState(CHANNEL_HC_FRAME_HHPHC, new StringType(frameHcOption.getHhphc().name()));
}
protected void updateStatesForTempoFrameOption(FrameTempoOption frameTempoOption) {
updateState(CHANNEL_TEMPO_FRAME_BBRHPJR,
QuantityType.valueOf(frameTempoOption.getBbrhpjr(), SmartHomeUnits.WATT_HOUR));
updateState(CHANNEL_TEMPO_FRAME_BBRHCJR,
QuantityType.valueOf(frameTempoOption.getBbrhcjr(), SmartHomeUnits.WATT_HOUR));
updateState(CHANNEL_TEMPO_FRAME_BBRHPJW,
QuantityType.valueOf(frameTempoOption.getBbrhpjw(), SmartHomeUnits.WATT_HOUR));
updateState(CHANNEL_TEMPO_FRAME_BBRHCJW,
QuantityType.valueOf(frameTempoOption.getBbrhcjw(), SmartHomeUnits.WATT_HOUR));
updateState(CHANNEL_TEMPO_FRAME_BBRHPJB,
QuantityType.valueOf(frameTempoOption.getBbrhpjb(), SmartHomeUnits.WATT_HOUR));
updateState(CHANNEL_TEMPO_FRAME_BBRHCJB,
QuantityType.valueOf(frameTempoOption.getBbrhcjb(), SmartHomeUnits.WATT_HOUR));
updateState(CHANNEL_TEMPO_FRAME_HHPHC, new StringType(frameTempoOption.getHhphc().name()));
updateState(CHANNEL_TEMPO_FRAME_PROGRAMME_CIRCUIT_1,
new StringType(frameTempoOption.getProgrammeCircuit1().name()));
updateState(CHANNEL_TEMPO_FRAME_PROGRAMME_CIRCUIT_2,
new StringType(frameTempoOption.getProgrammeCircuit2().name()));
if (frameTempoOption.getDemain() == null) {
updateState(CHANNEL_TEMPO_FRAME_DEMAIN, UnDefType.NULL);
} else {
updateState(CHANNEL_TEMPO_FRAME_DEMAIN, new StringType(frameTempoOption.getDemain().name()));
}
}
protected void updateStatesForEjpFrameOption(FrameEjpOption frameEjpOption) {
updateState(CHANNEL_EJP_FRAME_EJPHN, QuantityType.valueOf(frameEjpOption.getEjphn(), SmartHomeUnits.WATT_HOUR));
updateState(CHANNEL_EJP_FRAME_EJPHPM,
QuantityType.valueOf(frameEjpOption.getEjphpm(), SmartHomeUnits.WATT_HOUR));
if (frameEjpOption.getPejp() == null) {
updateState(CHANNEL_EJP_FRAME_PEJP, UnDefType.NULL);
} else {
updateState(CHANNEL_EJP_FRAME_PEJP, QuantityType.valueOf(frameEjpOption.getPejp(), SmartHomeUnits.MINUTE));
}
}
@Override
protected void updateStatus(ThingStatus status, ThingStatusDetail statusDetail, @Nullable String description) {
super.updateStatus(status, statusDetail, description);
if (!(ThingStatus.ONLINE.equals(status))) {
for (Channel channel : getThing().getChannels()) {
if (!CHANNEL_LAST_UPDATE.equals(channel.getUID().getId())) {
updateState(channel.getUID(), UnDefType.UNDEF);
}
}
}
}
@Override
protected void updateStatus(ThingStatus status, ThingStatusDetail statusDetail) {
this.updateStatus(status, statusDetail, null);
}
@Override
protected void updateStatus(ThingStatus status) {
this.updateStatus(status, ThingStatusDetail.NONE, null);
}
}

View File

@@ -0,0 +1,28 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.handler;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.teleinfo.internal.dto.Frame;
/**
* The {@link TeleinfoControllerHandlerListener} interface defines all events pushed by a
* {@link TeleinfoAbstractControllerHandler}.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public interface TeleinfoControllerHandlerListener {
void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, final Frame frame);
}

View File

@@ -0,0 +1,34 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.handler;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
* The {@link TeleinfoElectricityMeterConfiguration} class stores electricity meter thing configuration
*
* @author Olivier MARCEAU - Initial contribution
*/
@NonNullByDefault
public class TeleinfoElectricityMeterConfiguration {
private String adco = "";
public String getAdco() {
return adco;
}
public void setAdco(String adco) {
this.adco = adco;
}
}

View File

@@ -0,0 +1,114 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.handler;
import static org.openhab.binding.teleinfo.internal.TeleinfoBindingConstants.*;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.teleinfo.internal.handler.cbemm.TeleinfoBaseCbemmElectricityMeterHandler;
import org.openhab.binding.teleinfo.internal.handler.cbemm.TeleinfoEjpCbemmElectricityMeterHandler;
import org.openhab.binding.teleinfo.internal.handler.cbemm.TeleinfoHcCbemmElectricityMeterHandler;
import org.openhab.binding.teleinfo.internal.handler.cbemm.TeleinfoTempoCbemmElectricityMeterHandler;
import org.openhab.binding.teleinfo.internal.handler.cbemm.evoicc.TeleinfoBaseCbemmEvoIccElectricityMeterHandler;
import org.openhab.binding.teleinfo.internal.handler.cbemm.evoicc.TeleinfoEjpCbemmEvoIccElectricityMeterHandler;
import org.openhab.binding.teleinfo.internal.handler.cbemm.evoicc.TeleinfoHcCbemmEvoIccElectricityMeterHandler;
import org.openhab.binding.teleinfo.internal.handler.cbemm.evoicc.TeleinfoTempoCbemmEvoIccElectricityMeterHandler;
import org.openhab.binding.teleinfo.internal.handler.cbetm.TeleinfoBaseCbetmLongElectricityMeterHandler;
import org.openhab.binding.teleinfo.internal.handler.cbetm.TeleinfoEjpCbetmLongElectricityMeterHandler;
import org.openhab.binding.teleinfo.internal.handler.cbetm.TeleinfoHcCbetmLongElectricityMeterHandler;
import org.openhab.binding.teleinfo.internal.handler.cbetm.TeleinfoTempoCbetmLongElectricityMeterHandler;
import org.openhab.binding.teleinfo.internal.serial.TeleinfoSerialControllerHandler;
import org.openhab.core.io.transport.serial.SerialPortManager;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.binding.BaseThingHandlerFactory;
import org.openhab.core.thing.binding.ThingHandler;
import org.openhab.core.thing.binding.ThingHandlerFactory;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
/**
* The {@link TeleinfoThingHandlerFactory} is responsible for creating things and thing
* handlers.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
@Component(configurationPid = "binding.teleinfo", service = ThingHandlerFactory.class)
public class TeleinfoThingHandlerFactory extends BaseThingHandlerFactory {
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Stream.of(THING_TYPE_SERIAL_CONTROLLER,
THING_HC_CBEMM_ELECTRICITY_METER_TYPE_UID, THING_BASE_CBEMM_ELECTRICITY_METER_TYPE_UID,
THING_TEMPO_CBEMM_ELECTRICITY_METER_TYPE_UID, THING_EJP_CBEMM_ELECTRICITY_METER_TYPE_UID,
THING_HC_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID, THING_BASE_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID,
THING_TEMPO_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID, THING_EJP_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID,
THING_HC_CBETM_ELECTRICITY_METER_TYPE_UID, THING_BASE_CBETM_ELECTRICITY_METER_TYPE_UID,
THING_TEMPO_CBETM_ELECTRICITY_METER_TYPE_UID, THING_EJP_CBETM_ELECTRICITY_METER_TYPE_UID)
.collect(Collectors.toSet());
private final SerialPortManager serialPortManager;
@Activate
public TeleinfoThingHandlerFactory(@Reference SerialPortManager serialPortManager) {
this.serialPortManager = serialPortManager;
}
@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
}
@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
if (THING_TYPE_SERIAL_CONTROLLER.equals(thingTypeUID)) {
return new TeleinfoSerialControllerHandler((Bridge) thing, serialPortManager);
}
if (THING_BASE_CBEMM_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
return new TeleinfoBaseCbemmElectricityMeterHandler(thing);
} else if (THING_HC_CBEMM_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
return new TeleinfoHcCbemmElectricityMeterHandler(thing);
} else if (THING_TEMPO_CBEMM_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
return new TeleinfoTempoCbemmElectricityMeterHandler(thing);
} else if (THING_EJP_CBEMM_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
return new TeleinfoEjpCbemmElectricityMeterHandler(thing);
} else if (THING_BASE_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
return new TeleinfoBaseCbemmEvoIccElectricityMeterHandler(thing);
} else if (THING_HC_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
return new TeleinfoHcCbemmEvoIccElectricityMeterHandler(thing);
} else if (THING_TEMPO_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
return new TeleinfoTempoCbemmEvoIccElectricityMeterHandler(thing);
} else if (THING_EJP_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
return new TeleinfoEjpCbemmEvoIccElectricityMeterHandler(thing);
} else if (THING_BASE_CBETM_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
return new TeleinfoBaseCbetmLongElectricityMeterHandler(thing);
} else if (THING_HC_CBETM_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
return new TeleinfoHcCbetmLongElectricityMeterHandler(thing);
} else if (THING_TEMPO_CBETM_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
return new TeleinfoTempoCbetmLongElectricityMeterHandler(thing);
} else if (THING_EJP_CBETM_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
return new TeleinfoEjpCbetmLongElectricityMeterHandler(thing);
} else {
throw new IllegalStateException("Teleinfo frame type not supported: " + thing.getThingTypeUID());
}
}
}

View File

@@ -0,0 +1,59 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.handler.cbemm;
import static org.openhab.binding.teleinfo.internal.TeleinfoBindingConstants.*;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemm;
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractElectricityMeterHandler;
import org.openhab.core.library.types.DateTimeType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.thing.Thing;
import org.openhab.core.types.UnDefType;
/**
* The {@link TeleinfoAbstractCbemmElectricityMeterHandler} class defines a skeleton for CBEMM Electricity Meters
* handlers.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public abstract class TeleinfoAbstractCbemmElectricityMeterHandler extends TeleinfoAbstractElectricityMeterHandler {
public TeleinfoAbstractCbemmElectricityMeterHandler(Thing thing) {
super(thing);
}
protected void updateStatesForCommonCbemmChannels(FrameCbemm frame) {
// update common channels
updateState(CHANNEL_CBEMM_ISOUSC, QuantityType.valueOf(frame.getIsousc(), SmartHomeUnits.AMPERE));
updateState(CHANNEL_CBEMM_PTEC, new StringType(frame.getPtec().name()));
if (frame.getImax() == null) {
updateState(CHANNEL_CBEMM_IMAX, UnDefType.NULL);
} else {
updateState(CHANNEL_CBEMM_IMAX, QuantityType.valueOf(frame.getImax(), SmartHomeUnits.AMPERE));
}
if (frame.getAdps() == null) {
updateState(CHANNEL_CBEMM_ADPS, UnDefType.NULL);
} else {
updateState(CHANNEL_CBEMM_ADPS, QuantityType.valueOf(frame.getAdps(), SmartHomeUnits.AMPERE));
}
updateState(CHANNEL_CBEMM_IINST, QuantityType.valueOf(frame.getIinst(), SmartHomeUnits.AMPERE));
updateState(CHANNEL_LAST_UPDATE, new DateTimeType());
}
}

View File

@@ -0,0 +1,45 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.handler.cbemm;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.teleinfo.internal.dto.Frame;
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmBaseOption;
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
import org.openhab.core.thing.Thing;
/**
* The {@link TeleinfoBaseCbemmElectricityMeterHandler} class defines a handler for a BASE CBEMM Electricity Meters
* thing.
*
* @author Nicolas SIBERIL - Initial contribution
* @author Olivier MARCEAU - Change ADCO property to parameter
*/
@NonNullByDefault
public class TeleinfoBaseCbemmElectricityMeterHandler extends TeleinfoAbstractCbemmElectricityMeterHandler {
public TeleinfoBaseCbemmElectricityMeterHandler(Thing thing) {
super(thing);
}
@Override
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
final FrameCbemmBaseOption frameCbemmBaseOption = (FrameCbemmBaseOption) frame;
String adco = configuration.getAdco();
if (frameCbemmBaseOption.getAdco().equalsIgnoreCase(adco)) {
updateStatesForCommonCbemmChannels(frameCbemmBaseOption);
updateStatesForBaseFrameOption(frameCbemmBaseOption);
}
}
}

View File

@@ -0,0 +1,45 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.handler.cbemm;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.teleinfo.internal.dto.Frame;
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmEjpOption;
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
import org.openhab.core.thing.Thing;
/**
* The {@link TeleinfoEjpCbemmElectricityMeterHandler} class defines a handler for a EJB CBEMM Electricity Meters
* thing.
*
* @author Nicolas SIBERIL - Initial contribution
* @author Olivier MARCEAU - Change ADCO property to parameter
*/
@NonNullByDefault
public class TeleinfoEjpCbemmElectricityMeterHandler extends TeleinfoAbstractCbemmElectricityMeterHandler {
public TeleinfoEjpCbemmElectricityMeterHandler(Thing thing) {
super(thing);
}
@Override
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
final FrameCbemmEjpOption frameCbemmEjpOption = (FrameCbemmEjpOption) frame;
String adco = configuration.getAdco();
if (frameCbemmEjpOption.getAdco().equalsIgnoreCase(adco)) {
updateStatesForCommonCbemmChannels(frameCbemmEjpOption);
updateStatesForEjpFrameOption(frameCbemmEjpOption);
}
}
}

View File

@@ -0,0 +1,44 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.handler.cbemm;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.teleinfo.internal.dto.Frame;
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmHcOption;
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
import org.openhab.core.thing.Thing;
/**
* The {@link TeleinfoHcCbemmElectricityMeterHandler} class defines a handler for a HC CBEMM Electricity Meters thing.
*
* @author Nicolas SIBERIL - Initial contribution
* @author Olivier MARCEAU - Change ADCO property to parameter
*/
@NonNullByDefault
public class TeleinfoHcCbemmElectricityMeterHandler extends TeleinfoAbstractCbemmElectricityMeterHandler {
public TeleinfoHcCbemmElectricityMeterHandler(Thing thing) {
super(thing);
}
@Override
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
final FrameCbemmHcOption frameCbemmHcOption = (FrameCbemmHcOption) frame;
String adco = configuration.getAdco();
if (frameCbemmHcOption.getAdco().equalsIgnoreCase(adco)) {
updateStatesForCommonCbemmChannels(frameCbemmHcOption);
updateStatesForHcFrameOption(frameCbemmHcOption);
}
}
}

View File

@@ -0,0 +1,45 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.handler.cbemm;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.teleinfo.internal.dto.Frame;
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmTempoOption;
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
import org.openhab.core.thing.Thing;
/**
* The {@link TeleinfoTempoCbemmElectricityMeterHandler} class defines a handler for a TEMPO CBEMM Electricity Meters
* thing.
*
* @author Nicolas SIBERIL - Initial contribution
* @author Olivier MARCEAU - Change ADCO property to parameter
*/
@NonNullByDefault
public class TeleinfoTempoCbemmElectricityMeterHandler extends TeleinfoAbstractCbemmElectricityMeterHandler {
public TeleinfoTempoCbemmElectricityMeterHandler(Thing thing) {
super(thing);
}
@Override
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
final FrameCbemmTempoOption frameCbemmTempoOption = (FrameCbemmTempoOption) frame;
String adco = configuration.getAdco();
if (frameCbemmTempoOption.getAdco().equalsIgnoreCase(adco)) {
updateStatesForCommonCbemmChannels(frameCbemmTempoOption);
updateStatesForTempoFrameOption(frameCbemmTempoOption);
}
}
}

View File

@@ -0,0 +1,43 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.handler.cbemm.evoicc;
import static org.openhab.binding.teleinfo.internal.TeleinfoBindingConstants.CHANNEL_CBEMM_EVOLUTION_ICC_PAPP;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIcc;
import org.openhab.binding.teleinfo.internal.handler.cbemm.TeleinfoAbstractCbemmElectricityMeterHandler;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.thing.Thing;
/**
* The {@link TeleinfoAbstractCbemmEvoIccElectricityMeterHandler} class defines a skeleton for CBEMM Evolution ICC
* Electricity Meters
* handlers.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public abstract class TeleinfoAbstractCbemmEvoIccElectricityMeterHandler
extends TeleinfoAbstractCbemmElectricityMeterHandler {
public TeleinfoAbstractCbemmEvoIccElectricityMeterHandler(Thing thing) {
super(thing);
}
protected void updateStatesForCommonCbemmEvolutionIccChannels(FrameCbemmEvolutionIcc frame) {
updateStatesForCommonCbemmChannels(frame);
updateState(CHANNEL_CBEMM_EVOLUTION_ICC_PAPP, QuantityType.valueOf(frame.getPapp(), SmartHomeUnits.WATT));
}
}

View File

@@ -0,0 +1,45 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.handler.cbemm.evoicc;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.teleinfo.internal.dto.Frame;
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccBaseOption;
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
import org.openhab.core.thing.Thing;
/**
* The {@link TeleinfoBaseCbemmEvoIccElectricityMeterHandler} class defines a handler for a BASE CBEMM Evolution ICC
* Electricity Meters thing.
*
* @author Nicolas SIBERIL - Initial contribution
* @author Olivier MARCEAU - Change ADCO property to parameter
*/
@NonNullByDefault
public class TeleinfoBaseCbemmEvoIccElectricityMeterHandler extends TeleinfoAbstractCbemmEvoIccElectricityMeterHandler {
public TeleinfoBaseCbemmEvoIccElectricityMeterHandler(Thing thing) {
super(thing);
}
@Override
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
final FrameCbemmEvolutionIccBaseOption frameCbemmEvoIccBaseOption = (FrameCbemmEvolutionIccBaseOption) frame;
String adco = configuration.getAdco();
if (frameCbemmEvoIccBaseOption.getAdco().equalsIgnoreCase(adco)) {
updateStatesForCommonCbemmEvolutionIccChannels(frameCbemmEvoIccBaseOption);
updateStatesForBaseFrameOption(frameCbemmEvoIccBaseOption);
}
}
}

View File

@@ -0,0 +1,45 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.handler.cbemm.evoicc;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.teleinfo.internal.dto.Frame;
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccEjpOption;
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
import org.openhab.core.thing.Thing;
/**
* The {@link TeleinfoEjpCbemmEvoIccElectricityMeterHandler} class defines a handler for a EJP CBEMM Evolution ICC
* Electricity Meters thing.
*
* @author Nicolas SIBERIL - Initial contribution
* @author Olivier MARCEAU - Change ADCO property to parameter
*/
@NonNullByDefault
public class TeleinfoEjpCbemmEvoIccElectricityMeterHandler extends TeleinfoAbstractCbemmEvoIccElectricityMeterHandler {
public TeleinfoEjpCbemmEvoIccElectricityMeterHandler(Thing thing) {
super(thing);
}
@Override
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
final FrameCbemmEvolutionIccEjpOption frameCbemmEvoIccEjpOption = (FrameCbemmEvolutionIccEjpOption) frame;
String adco = configuration.getAdco();
if (frameCbemmEvoIccEjpOption.getAdco().equalsIgnoreCase(adco)) {
updateStatesForCommonCbemmEvolutionIccChannels(frameCbemmEvoIccEjpOption);
updateStatesForEjpFrameOption(frameCbemmEvoIccEjpOption);
}
}
}

View File

@@ -0,0 +1,45 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.handler.cbemm.evoicc;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.teleinfo.internal.dto.Frame;
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccHcOption;
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
import org.openhab.core.thing.Thing;
/**
* The {@link TeleinfoHcCbemmEvoIccElectricityMeterHandler} class defines a handler for a HC CBEMM Evolution ICC
* Electricity Meters thing.
*
* @author Nicolas SIBERIL - Initial contribution
* @author Olivier MARCEAU - Change ADCO property to parameter
*/
@NonNullByDefault
public class TeleinfoHcCbemmEvoIccElectricityMeterHandler extends TeleinfoAbstractCbemmEvoIccElectricityMeterHandler {
public TeleinfoHcCbemmEvoIccElectricityMeterHandler(Thing thing) {
super(thing);
}
@Override
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
final FrameCbemmEvolutionIccHcOption frameCbemmEvoIccHcOption = (FrameCbemmEvolutionIccHcOption) frame;
String adco = configuration.getAdco();
if (frameCbemmEvoIccHcOption.getAdco().equalsIgnoreCase(adco)) {
updateStatesForCommonCbemmEvolutionIccChannels(frameCbemmEvoIccHcOption);
updateStatesForHcFrameOption(frameCbemmEvoIccHcOption);
}
}
}

View File

@@ -0,0 +1,46 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.handler.cbemm.evoicc;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.teleinfo.internal.dto.Frame;
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccTempoOption;
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
import org.openhab.core.thing.Thing;
/**
* The {@link TeleinfoTempoCbemmEvoIccElectricityMeterHandler} class defines a handler for a TEMPO CBEMM Evolution ICC
* Electricity Meters thing.
*
* @author Nicolas SIBERIL - Initial contribution
* @author Olivier MARCEAU - Change ADCO property to parameter
*/
@NonNullByDefault
public class TeleinfoTempoCbemmEvoIccElectricityMeterHandler
extends TeleinfoAbstractCbemmEvoIccElectricityMeterHandler {
public TeleinfoTempoCbemmEvoIccElectricityMeterHandler(Thing thing) {
super(thing);
}
@Override
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
final FrameCbemmEvolutionIccTempoOption frameCbemmEvoIccTempoOption = (FrameCbemmEvolutionIccTempoOption) frame;
String adco = configuration.getAdco();
if (frameCbemmEvoIccTempoOption.getAdco().equalsIgnoreCase(adco)) {
updateStatesForCommonCbemmEvolutionIccChannels(frameCbemmEvoIccTempoOption);
updateStatesForTempoFrameOption(frameCbemmEvoIccTempoOption);
}
}
}

View File

@@ -0,0 +1,119 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.handler.cbetm;
import static org.openhab.binding.teleinfo.internal.TeleinfoBindingConstants.*;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetm;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLong;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmShort;
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractElectricityMeterHandler;
import org.openhab.core.library.types.DateTimeType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.thing.Thing;
import org.openhab.core.types.UnDefType;
/**
* The {@link TeleinfoAbstractCbetmElectricityMeterHandler} class defines a skeleton for CBETM Electricity Meters
* handlers.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public abstract class TeleinfoAbstractCbetmElectricityMeterHandler extends TeleinfoAbstractElectricityMeterHandler {
public TeleinfoAbstractCbetmElectricityMeterHandler(Thing thing) {
super(thing);
}
protected void updateStatesForCommonCbetmChannels(FrameCbetm frameCbetm) {
updateState(CHANNEL_CBETM_IINST1, QuantityType.valueOf(frameCbetm.getIinst1(), SmartHomeUnits.AMPERE));
updateState(CHANNEL_CBETM_IINST2, QuantityType.valueOf(frameCbetm.getIinst2(), SmartHomeUnits.AMPERE));
updateState(CHANNEL_CBETM_IINST3, QuantityType.valueOf(frameCbetm.getIinst3(), SmartHomeUnits.AMPERE));
if (frameCbetm instanceof FrameCbetmLong) {
FrameCbetmLong frameCbetmLong = (FrameCbetmLong) frameCbetm;
updateState(CHANNEL_CBETM_FRAME_TYPE, new StringType("LONG"));
updateState(CHANNEL_CBETM_LONG_ISOUSC,
QuantityType.valueOf(frameCbetmLong.getIsousc(), SmartHomeUnits.AMPERE));
updateState(CHANNEL_CBETM_LONG_PTEC, new StringType(frameCbetmLong.getPtec().name()));
if (frameCbetmLong.getImax1() == null) {
updateState(CHANNEL_CBETM_LONG_IMAX1, UnDefType.NULL);
} else {
updateState(CHANNEL_CBETM_LONG_IMAX1,
QuantityType.valueOf(frameCbetmLong.getImax1(), SmartHomeUnits.AMPERE));
}
if (frameCbetmLong.getImax2() == null) {
updateState(CHANNEL_CBETM_LONG_IMAX2, UnDefType.NULL);
} else {
updateState(CHANNEL_CBETM_LONG_IMAX2,
QuantityType.valueOf(frameCbetmLong.getImax2(), SmartHomeUnits.AMPERE));
}
if (frameCbetmLong.getImax3() == null) {
updateState(CHANNEL_CBETM_LONG_IMAX3, UnDefType.NULL);
} else {
updateState(CHANNEL_CBETM_LONG_IMAX3,
QuantityType.valueOf(frameCbetmLong.getImax3(), SmartHomeUnits.AMPERE));
}
updateState(CHANNEL_CBETM_LONG_PMAX, QuantityType.valueOf(frameCbetmLong.getPmax(), SmartHomeUnits.WATT));
updateState(CHANNEL_CBETM_LONG_PAPP, QuantityType.valueOf(frameCbetmLong.getPapp(), SmartHomeUnits.WATT));
updateState(CHANNEL_CBETM_LONG_PPOT, new StringType(frameCbetmLong.getPpot()));
updateState(CHANNEL_CBETM_SHORT_ADIR1, UnDefType.NULL);
updateState(CHANNEL_CBETM_SHORT_ADIR2, UnDefType.NULL);
updateState(CHANNEL_CBETM_SHORT_ADIR3, UnDefType.NULL);
} else { // FrameCbetmShort
FrameCbetmShort frameCbetmShort = (FrameCbetmShort) frameCbetm;
updateState(CHANNEL_CBETM_FRAME_TYPE, new StringType("SHORT"));
if (frameCbetmShort.getAdir1() == null) {
updateState(CHANNEL_CBETM_SHORT_ADIR1, UnDefType.NULL);
} else {
updateState(CHANNEL_CBETM_SHORT_ADIR1,
QuantityType.valueOf(frameCbetmShort.getAdir1(), SmartHomeUnits.AMPERE));
}
if (frameCbetmShort.getAdir2() == null) {
updateState(CHANNEL_CBETM_SHORT_ADIR2, UnDefType.NULL);
} else {
updateState(CHANNEL_CBETM_SHORT_ADIR2,
QuantityType.valueOf(frameCbetmShort.getAdir2(), SmartHomeUnits.AMPERE));
}
if (frameCbetmShort.getAdir3() == null) {
updateState(CHANNEL_CBETM_SHORT_ADIR3, UnDefType.NULL);
} else {
updateState(CHANNEL_CBETM_SHORT_ADIR3,
QuantityType.valueOf(frameCbetmShort.getAdir3(), SmartHomeUnits.AMPERE));
}
updateState(CHANNEL_CBETM_LONG_ISOUSC, UnDefType.NULL);
updateState(CHANNEL_CBETM_LONG_PTEC, UnDefType.NULL);
updateState(CHANNEL_CBETM_LONG_IMAX1, UnDefType.NULL);
updateState(CHANNEL_CBETM_LONG_IMAX2, UnDefType.NULL);
updateState(CHANNEL_CBETM_LONG_IMAX3, UnDefType.NULL);
updateState(CHANNEL_CBETM_LONG_PMAX, UnDefType.NULL);
updateState(CHANNEL_CBETM_LONG_PAPP, UnDefType.NULL);
updateState(CHANNEL_CBETM_LONG_PPOT, UnDefType.NULL);
}
updateState(CHANNEL_LAST_UPDATE, new DateTimeType());
}
}

View File

@@ -0,0 +1,48 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.handler.cbetm;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.teleinfo.internal.dto.Frame;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetm;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongBaseOption;
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
import org.openhab.core.thing.Thing;
/**
* The {@link TeleinfoBaseCbetmLongElectricityMeterHandler} class defines a handler for a BASE CBETM Electricity Meters
* thing.
*
* @author Nicolas SIBERIL - Initial contribution
* @author Olivier MARCEAU - Change ADCO property to parameter
*/
@NonNullByDefault
public class TeleinfoBaseCbetmLongElectricityMeterHandler extends TeleinfoAbstractCbetmElectricityMeterHandler {
public TeleinfoBaseCbetmLongElectricityMeterHandler(Thing thing) {
super(thing);
}
@Override
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
final FrameCbetm frameCbetm = (FrameCbetm) frame;
String adco = configuration.getAdco();
if (frameCbetm.getAdco().equalsIgnoreCase(adco)) {
updateStatesForCommonCbetmChannels(frameCbetm);
if (frameCbetm instanceof FrameCbetmLongBaseOption) {
updateStatesForBaseFrameOption((FrameCbetmLongBaseOption) frameCbetm);
}
}
}
}

View File

@@ -0,0 +1,48 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.handler.cbetm;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.teleinfo.internal.dto.Frame;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetm;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongEjpOption;
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
import org.openhab.core.thing.Thing;
/**
* The {@link TeleinfoEjpCbetmLongElectricityMeterHandler} class defines a handler for a EJP CBETM Electricity Meters
* thing.
*
* @author Nicolas SIBERIL - Initial contribution
* @author Olivier MARCEAU - Change ADCO property to parameter
*/
@NonNullByDefault
public class TeleinfoEjpCbetmLongElectricityMeterHandler extends TeleinfoAbstractCbetmElectricityMeterHandler {
public TeleinfoEjpCbetmLongElectricityMeterHandler(Thing thing) {
super(thing);
}
@Override
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
final FrameCbetm frameCbetm = (FrameCbetm) frame;
String adco = configuration.getAdco();
if (frameCbetm.getAdco().equalsIgnoreCase(adco)) {
updateStatesForCommonCbetmChannels(frameCbetm);
if (frameCbetm instanceof FrameCbetmLongEjpOption) {
updateStatesForEjpFrameOption((FrameCbetmLongEjpOption) frameCbetm);
}
}
}
}

View File

@@ -0,0 +1,49 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.handler.cbetm;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.teleinfo.internal.dto.Frame;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetm;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongHcOption;
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
import org.openhab.core.thing.Thing;
/**
* The {@link TeleinfoHcCbetmLongElectricityMeterHandler} class defines a handler for a HC CBETM Electricity Meters
* thing.
*
* @author Nicolas SIBERIL - Initial contribution
* @author Olivier MARCEAU - Change ADCO property to parameter
*/
@NonNullByDefault
public class TeleinfoHcCbetmLongElectricityMeterHandler extends TeleinfoAbstractCbetmElectricityMeterHandler {
public TeleinfoHcCbetmLongElectricityMeterHandler(Thing thing) {
super(thing);
}
@Override
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
final FrameCbetm frameCbetm = (FrameCbetm) frame;
String adco = configuration.getAdco();
if (frameCbetm.getAdco().equalsIgnoreCase(adco)) {
updateStatesForCommonCbetmChannels(frameCbetm);
if (frameCbetm instanceof FrameCbetmLongHcOption) {
updateStatesForHcFrameOption((FrameCbetmLongHcOption) frameCbetm);
}
}
}
}

View File

@@ -0,0 +1,50 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.handler.cbetm;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.teleinfo.internal.dto.Frame;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetm;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongTempoOption;
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
import org.openhab.core.thing.Thing;
/**
* The {@link TeleinfoTempoCbetmLongElectricityMeterHandler} class defines a handler for a TEMPO CBETM Electricity
* Meters
* thing.
*
* @author Nicolas SIBERIL - Initial contribution
* @author Olivier MARCEAU - Change ADCO property to parameter
*/
@NonNullByDefault
public class TeleinfoTempoCbetmLongElectricityMeterHandler extends TeleinfoAbstractCbetmElectricityMeterHandler {
public TeleinfoTempoCbetmLongElectricityMeterHandler(Thing thing) {
super(thing);
}
@Override
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
final FrameCbetm frameCbetm = (FrameCbetm) frame;
String adco = configuration.getAdco();
if (frameCbetm.getAdco().equalsIgnoreCase(adco)) {
updateStatesForCommonCbetmChannels(frameCbetm);
if (frameCbetm instanceof FrameCbetmLongTempoOption) {
updateStatesForTempoFrameOption((FrameCbetmLongTempoOption) frameCbetm);
}
}
}
}

View File

@@ -0,0 +1,33 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.reader;
import java.io.Closeable;
import java.io.IOException;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
* The {@link TeleinfoReader} interface defines a mechanism to read Teleinfo frames.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public interface TeleinfoReader extends Closeable {
void open() throws IOException;
void addListener(final TeleinfoReaderListener listener);
void removeListener(final TeleinfoReaderListener listener);
}

View File

@@ -0,0 +1,75 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.reader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.teleinfo.internal.dto.Frame;
/**
* The {@link TeleinfoReaderAdaptor} class defines an adaptor at {@link TeleinfoReader} interface.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public abstract class TeleinfoReaderAdaptor implements TeleinfoReader {
private List<TeleinfoReaderListener> listeners = new ArrayList<>();
@Override
public void addListener(final TeleinfoReaderListener listener) {
listeners.add(listener);
}
@Override
public void removeListener(final TeleinfoReaderListener listener) {
listeners.remove(listener);
}
protected void fireOnFrameReceivedEvent(final Frame frame) {
for (TeleinfoReaderListener listener : listeners) {
listener.onFrameReceived(this, frame);
}
}
protected void fireOnOpeningEvent() {
for (TeleinfoReaderListener listener : listeners) {
listener.onOpening(this);
}
}
protected void fireOnOpenedEvent() {
for (TeleinfoReaderListener listener : listeners) {
listener.onOpened(this);
}
}
protected void fireOnClosingEvent() {
for (TeleinfoReaderListener listener : listeners) {
listener.onClosing(this);
}
}
protected void fireOnClosedEvent() {
for (TeleinfoReaderListener listener : listeners) {
listener.onClosed(this);
}
}
public List<TeleinfoReaderListener> getListeners() {
return Collections.unmodifiableList(listeners);
}
}

View File

@@ -0,0 +1,45 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.reader;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.teleinfo.internal.dto.Frame;
/**
* The {@link TeleinfoReaderListener} interface defines all events pushed by a {@link TeleinfoReader}.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public interface TeleinfoReaderListener {
default void onFrameReceived(final TeleinfoReader reader, final Frame frame) {
// NOP
}
default void onOpening(final TeleinfoReader reader) {
// NOP
}
default void onOpened(final TeleinfoReader reader) {
// NOP
}
default void onClosing(final TeleinfoReader reader) {
// NOP
}
default void onClosed(final TeleinfoReader reader) {
// NOP
}
}

View File

@@ -0,0 +1,690 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.reader.io;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.teleinfo.internal.dto.Frame;
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemm;
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmBaseOption;
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmEjpOption;
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmHcOption;
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmTempoOption;
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIcc;
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccBaseOption;
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccEjpOption;
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccHcOption;
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccTempoOption;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLong;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongBaseOption;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongEjpOption;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongHcOption;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongTempoOption;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmShort;
import org.openhab.binding.teleinfo.internal.dto.common.FrameBaseOption;
import org.openhab.binding.teleinfo.internal.dto.common.FrameEjpOption;
import org.openhab.binding.teleinfo.internal.dto.common.FrameHcOption;
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption;
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption.CouleurDemain;
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption.ProgrammeCircuit1;
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption.ProgrammeCircuit2;
import org.openhab.binding.teleinfo.internal.dto.common.Hhphc;
import org.openhab.binding.teleinfo.internal.dto.common.Ptec;
import org.openhab.binding.teleinfo.internal.reader.io.serialport.ConversionException;
import org.openhab.binding.teleinfo.internal.reader.io.serialport.FrameUtil;
import org.openhab.binding.teleinfo.internal.reader.io.serialport.InvalidFrameException;
import org.openhab.binding.teleinfo.internal.reader.io.serialport.Label;
import org.openhab.binding.teleinfo.internal.reader.io.serialport.converter.Converter;
import org.openhab.binding.teleinfo.internal.reader.io.serialport.converter.CouleurDemainConverter;
import org.openhab.binding.teleinfo.internal.reader.io.serialport.converter.FloatConverter;
import org.openhab.binding.teleinfo.internal.reader.io.serialport.converter.HhphcConverter;
import org.openhab.binding.teleinfo.internal.reader.io.serialport.converter.IntegerConverter;
import org.openhab.binding.teleinfo.internal.reader.io.serialport.converter.PtecConverter;
import org.openhab.binding.teleinfo.internal.reader.io.serialport.converter.StringConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* InputStream for Teleinfo {@link Frame} in serial port format.
*/
/**
* The {@link TeleinfoInputStream} class is an {@link InputStream} to decode/read Teleinfo frames.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public class TeleinfoInputStream extends InputStream {
public static final long DEFAULT_TIMEOUT_NEXT_HEADER_FRAME_US = 33400;
public static final long DEFAULT_TIMEOUT_READING_FRAME_US = 33400;
private final Logger logger = LoggerFactory.getLogger(TeleinfoInputStream.class);
private static final Map<Class<?>, Converter> LABEL_VALUE_CONVERTERS;
private BufferedReader bufferedReader;
private @Nullable String groupLine;
private ExecutorService executorService;
private long waitNextHeaderFrameTimeoutInUs;
private long readingFrameTimeoutInUs;
private boolean autoRepairInvalidADPSgroupLine;
private boolean useOwnScheduler;
static {
LABEL_VALUE_CONVERTERS = new HashMap<>();
LABEL_VALUE_CONVERTERS.put(Integer.class, new IntegerConverter());
LABEL_VALUE_CONVERTERS.put(String.class, new StringConverter());
LABEL_VALUE_CONVERTERS.put(Float.class, new FloatConverter());
LABEL_VALUE_CONVERTERS.put(Ptec.class, new PtecConverter());
LABEL_VALUE_CONVERTERS.put(Hhphc.class, new HhphcConverter());
LABEL_VALUE_CONVERTERS.put(CouleurDemain.class, new CouleurDemainConverter());
}
public TeleinfoInputStream(final InputStream teleinfoInputStream) {
this(teleinfoInputStream, DEFAULT_TIMEOUT_NEXT_HEADER_FRAME_US, DEFAULT_TIMEOUT_READING_FRAME_US, false);
}
public TeleinfoInputStream(final InputStream teleinfoInputStream, boolean autoRepairInvalidADPSgroupLine) {
this(teleinfoInputStream, DEFAULT_TIMEOUT_NEXT_HEADER_FRAME_US, DEFAULT_TIMEOUT_READING_FRAME_US,
autoRepairInvalidADPSgroupLine);
}
public TeleinfoInputStream(final @Nullable InputStream teleinfoInputStream, long waitNextHeaderFrameTimeoutInUs,
long readingFrameTimeoutInUs, boolean autoRepairInvalidADPSgroupLine) {
this(teleinfoInputStream, waitNextHeaderFrameTimeoutInUs, readingFrameTimeoutInUs,
autoRepairInvalidADPSgroupLine, null);
}
public TeleinfoInputStream(final @Nullable InputStream teleinfoInputStream, long waitNextHeaderFrameTimeoutInUs,
long readingFrameTimeoutInUs, boolean autoRepairInvalidADPSgroupLine,
@Nullable ExecutorService executorService) {
if (teleinfoInputStream == null) {
throw new IllegalArgumentException("Teleinfo inputStream is null");
}
this.waitNextHeaderFrameTimeoutInUs = waitNextHeaderFrameTimeoutInUs;
this.readingFrameTimeoutInUs = readingFrameTimeoutInUs;
this.autoRepairInvalidADPSgroupLine = autoRepairInvalidADPSgroupLine;
if (executorService == null) {
this.executorService = Executors.newFixedThreadPool(2);
this.useOwnScheduler = true;
} else {
this.executorService = executorService;
this.useOwnScheduler = false;
}
this.bufferedReader = new BufferedReader(new InputStreamReader(teleinfoInputStream, StandardCharsets.US_ASCII));
groupLine = null;
}
@Override
public void close() throws IOException {
logger.debug("close() [start]");
bufferedReader.close();
if (useOwnScheduler) {
executorService.shutdownNow();
}
super.close();
logger.debug("close() [end]");
}
/**
* Returns the next frame.
*
* @return the next frame or null if end of stream
* @throws TimeoutException
* @throws IOException
* @throws InvalidFrameException
* @throws Exception
*/
public synchronized @Nullable Frame readNextFrame() throws TimeoutException, InvalidFrameException, IOException {
// seek the next header frame
Future<@Nullable Void> seekNextHeaderFrameTask = executorService.submit(() -> {
while (!isHeaderFrame(groupLine)) {
groupLine = bufferedReader.readLine();
if (logger.isTraceEnabled()) {
logger.trace("groupLine = {}", groupLine);
}
if (groupLine == null) { // end of stream
logger.trace("end of stream reached !");
return null;
}
}
logger.trace("header frame found !");
return null;
});
try {
logger.debug("seeking the next header frame...");
logger.trace("waitNextHeaderFrameTimeoutInUs = {}", waitNextHeaderFrameTimeoutInUs);
seekNextHeaderFrameTask.get(waitNextHeaderFrameTimeoutInUs, TimeUnit.MICROSECONDS);
if (groupLine == null) { // end of stream
return null;
}
} catch (InterruptedException e) {
logger.debug("Got interrupted exception", e);
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
rethrowTaskExecutionException(e);
}
Future<Map<Label, Object>> nextFrameFuture = executorService.submit(new Callable<Map<Label, Object>>() {
@Override
public Map<Label, Object> call() throws Exception {
// read label values
Map<Label, Object> frameValues = new HashMap<>();
while ((groupLine = bufferedReader.readLine()) != null && !isHeaderFrame(groupLine)) {
logger.trace("groupLine = {}", groupLine);
String groupLineRef = groupLine;
if (groupLineRef != null) {
String[] groupLineTokens = groupLineRef.split("\\s");
if (groupLineTokens.length != 2 && groupLineTokens.length != 3) {
final String error = String.format("The groupLine '%1$s' is incomplete", groupLineRef);
throw new InvalidFrameException(error);
}
String labelStr = groupLineTokens[0];
String valueString = groupLineTokens[1];
// verify integrity (through checksum)
char checksum = (groupLineTokens.length == 3 ? groupLineTokens[2].charAt(0) : ' ');
char computedChecksum = FrameUtil.computeGroupLineChecksum(labelStr, valueString);
if (computedChecksum != checksum) {
logger.trace("computedChecksum = {}", computedChecksum);
logger.trace("checksum = {}", checksum);
final String error = String.format(
"The groupLine '%s' is corrupted (integrity not checked). Actual checksum: '%s' / Expected checksum: '%s'",
groupLineRef, checksum, computedChecksum);
throw new InvalidFrameException(error);
}
Label label;
try {
label = Label.valueOf(labelStr);
} catch (IllegalArgumentException e) {
if (autoRepairInvalidADPSgroupLine && labelStr.startsWith(Label.ADPS.name())) {
// in this hardware issue, label variable is composed by label name and value. E.g:
// ADPS032
logger.warn("Try to auto repair malformed ADPS groupLine '{}'", labelStr);
label = Label.ADPS;
valueString = labelStr.substring(Label.ADPS.name().length());
} else {
final String error = String.format("The label '%s' is unknown", labelStr);
throw new InvalidFrameException(error);
}
}
Class<?> labelType = label.getType();
Converter converter = LABEL_VALUE_CONVERTERS.get(labelType);
try {
Object value = converter.convert(valueString);
if (value != null) {
frameValues.put(label, value);
}
} catch (ConversionException e) {
final String error = String.format("An error occurred during '%s' value conversion",
valueString);
throw new InvalidFrameException(error, e);
}
}
}
return frameValues;
}
});
try {
logger.debug("reading data frame...");
logger.trace("readingFrameTimeoutInUs = {}", readingFrameTimeoutInUs);
Map<Label, Object> frameValues = nextFrameFuture.get(readingFrameTimeoutInUs, TimeUnit.MICROSECONDS);
// build the frame from map values
final Frame frame = buildFrame(frameValues);
frame.setTimestamp(LocalDate.now());
frame.setId(UUID.randomUUID());
return frame;
} catch (InterruptedException e) {
logger.debug("Got interrupted exception", e);
Thread.currentThread().interrupt();
throw new IllegalStateException(e);
} catch (ExecutionException e) {
rethrowTaskExecutionException(e);
}
return null;
}
public long getWaitNextHeaderFrameTimeoutInUs() {
return waitNextHeaderFrameTimeoutInUs;
}
public void setWaitNextHeaderFrameTimeoutInUs(long waitNextHeaderFrameTimeoutInUs) {
this.waitNextHeaderFrameTimeoutInUs = waitNextHeaderFrameTimeoutInUs;
}
public long getReadingFrameTimeoutInUs() {
return readingFrameTimeoutInUs;
}
public void setReadingFrameTimeoutInUs(long readingFrameTimeoutInUs) {
this.readingFrameTimeoutInUs = readingFrameTimeoutInUs;
}
public boolean isAutoRepairInvalidADPSgroupLine() {
return autoRepairInvalidADPSgroupLine;
}
public void setAutoRepairInvalidADPSgroupLine(boolean autoRepairInvalidADPSgroupLine) {
this.autoRepairInvalidADPSgroupLine = autoRepairInvalidADPSgroupLine;
}
@Override
public int read() throws IOException {
throw new UnsupportedOperationException("The 'read()' is not supported");
}
private boolean isHeaderFrame(final @Nullable String line) {
// A new teleinfo trame begin with '3' and '2' bytes (END OF TEXT et START OF TEXT)
return (line != null && line.length() > 1 && line.codePointAt(0) == 3 && line.codePointAt(1) == 2);
}
private Frame buildFrame(final Map<Label, Object> frameValues) throws InvalidFrameException {
if (frameValues.containsKey(Label.IINST1)) {
if (frameValues.containsKey(Label.IMAX1)) {
return buildFrameCbetmLong(frameValues);
} else {
return buildFrameCbetmShort(frameValues);
}
} else if (frameValues.containsKey(Label.PAPP)) {
return buildFrameCbemmEvolutionIcc(frameValues);
} else {
return buildFrameCbemm(frameValues);
}
}
private FrameCbetmLong buildFrameCbetmLong(final Map<Label, Object> frameValues) throws InvalidFrameException {
logger.trace("buildFrameCbetmLong(Map<Label, Object>) [start]");
final FrameCbetmLong frameCbetm;
String optionTarif = getRequiredLabelValue(Label.OPTARIF, frameValues);
if ("BASE".equals(optionTarif)) {
frameCbetm = buildFrameCbetmLongBaseOption(frameValues);
} else if ("HC..".equals(optionTarif)) {
frameCbetm = buildFrameCbetmLongHcOption(frameValues);
} else if ("EJP.".equals(optionTarif)) {
frameCbetm = buildFrameCbetmLongEjpOption(frameValues);
} else if (optionTarif.startsWith("BBR") && optionTarif.length() == 4) {
ProgrammeCircuit1 prgCircuit1 = convertProgrammeCircuit1(optionTarif.charAt(3));
ProgrammeCircuit2 prgCircuit2 = convertProgrammeCircuit2(optionTarif.charAt(3));
frameCbetm = buildFrameCbetmLongTempoOption(frameValues, prgCircuit1, prgCircuit2);
} else {
final String error = String.format("The option Tarif '%s' is not supported", optionTarif);
throw new InvalidFrameException(error);
}
logger.trace("buildFrameCbetmLong(Map<Label, Object>) [end]");
return frameCbetm;
}
private void setCbetmCommonFrameFields(final FrameCbetmLong frame, final Map<Label, Object> frameValues)
throws InvalidFrameException {
logger.trace("setCbetmCommonFrameFields(Frame, Map<Label, Object>) [start]");
frame.setAdco(getRequiredLabelValue(Label.ADCO, frameValues));
frame.setIsousc(getRequiredLabelValue(Label.ISOUSC, frameValues));
frame.setIinst1(getRequiredLabelValue(Label.IINST1, frameValues));
frame.setIinst2(getRequiredLabelValue(Label.IINST2, frameValues));
frame.setIinst3(getRequiredLabelValue(Label.IINST3, frameValues));
frame.setImax1(getRequiredLabelValue(Label.IMAX1, frameValues));
frame.setImax2(getRequiredLabelValue(Label.IMAX2, frameValues));
frame.setImax3(getRequiredLabelValue(Label.IMAX3, frameValues));
frame.setPtec(getRequiredLabelValue(Label.PTEC, frameValues));
frame.setPmax(getRequiredLabelValue(Label.PMAX, frameValues));
frame.setPapp(getRequiredLabelValue(Label.PAPP, frameValues));
frame.setMotdetat(getRequiredLabelValue(Label.MOTDETAT, frameValues));
frame.setPpot(getRequiredLabelValue(Label.PPOT, frameValues));
logger.trace("setCbetmCommonFrameFields(Frame, Map<Label, Object>) [end]");
}
private FrameCbetmLongBaseOption buildFrameCbetmLongBaseOption(final Map<Label, Object> frameValues)
throws InvalidFrameException {
logger.trace("buildFrameCbetmBaseOption(Map<Label, Object>) [start]");
FrameCbetmLongBaseOption frame = new FrameCbetmLongBaseOption();
setCbetmCommonFrameFields(frame, frameValues);
setFrameBaseOptionFields(frame, frameValues);
logger.trace("buildFrameCbetmBaseOption(Map<Label, Object>) [end]");
return frame;
}
private FrameCbetmLongHcOption buildFrameCbetmLongHcOption(final Map<Label, Object> frameValues)
throws InvalidFrameException {
logger.trace("buildFrameCbetmHcOption(Map<Label, Object>) [start]");
FrameCbetmLongHcOption frame = new FrameCbetmLongHcOption();
setCbetmCommonFrameFields(frame, frameValues);
setFrameHcOptionFields(frame, frameValues);
logger.trace("buildFrameCbetmHcOption(Map<Label, Object>) [end]");
return frame;
}
private FrameCbetmLongEjpOption buildFrameCbetmLongEjpOption(final Map<Label, Object> frameValues)
throws InvalidFrameException {
logger.trace("buildFrameCbetmEjpOption(Map<Label, Object>) [start]");
FrameCbetmLongEjpOption frame = new FrameCbetmLongEjpOption();
setCbetmCommonFrameFields(frame, frameValues);
setFrameEjpOptionFields(frame, frameValues);
logger.trace("buildFrameCbetmEjpOption(Map<Label, Object>) [end]");
return frame;
}
private FrameCbetmLongTempoOption buildFrameCbetmLongTempoOption(final Map<Label, Object> frameValues,
ProgrammeCircuit1 prgCircuit1, ProgrammeCircuit2 prgCircuit2) throws InvalidFrameException {
logger.trace("buildFrameCbetmTempoOption(Map<Label, Object>) [start]");
FrameCbetmLongTempoOption frame = new FrameCbetmLongTempoOption();
setCbetmCommonFrameFields(frame, frameValues);
setFrameTempoOptionFields(frame, frameValues, prgCircuit1, prgCircuit2);
logger.trace("buildFrameCbetmTempoOption(Map<Label, Object>) [end]");
return frame;
}
private FrameCbetmShort buildFrameCbetmShort(final Map<Label, Object> frameValues) throws InvalidFrameException {
logger.trace("buildFrameCbetmShort(Map<Label, Object>) [start]");
FrameCbetmShort frame = new FrameCbetmShort();
frame.setAdco(getRequiredLabelValue(Label.ADCO, frameValues));
frame.setIinst1(getRequiredLabelValue(Label.IINST1, frameValues));
frame.setIinst2(getRequiredLabelValue(Label.IINST2, frameValues));
frame.setIinst3(getRequiredLabelValue(Label.IINST3, frameValues));
frame.setAdir1(getOptionalLabelValue(Label.ADIR1, frameValues));
frame.setAdir2(getOptionalLabelValue(Label.ADIR2, frameValues));
frame.setAdir3(getOptionalLabelValue(Label.ADIR3, frameValues));
logger.trace("buildFrameCbetmShort(Map<Label, Object>) [end]");
return frame;
}
private FrameCbemm buildFrameCbemm(final Map<Label, Object> frameValues) throws InvalidFrameException {
logger.trace("buildFrameCbemm(Map<Label, Object>) [start]");
final FrameCbemm frameCbemm;
String optionTarif = getRequiredLabelValue(Label.OPTARIF, frameValues);
if ("BASE".equals(optionTarif)) {
frameCbemm = buildFrameCbemmBaseOption(frameValues);
} else if ("HC..".equals(optionTarif)) {
frameCbemm = buildFrameCbemmHcOption(frameValues);
} else if ("EJP.".equals(optionTarif)) {
frameCbemm = buildFrameCbemmEjpOption(frameValues);
} else if (optionTarif.startsWith("BBR") && optionTarif.length() == 4) {
ProgrammeCircuit1 prgCircuit1 = convertProgrammeCircuit1(optionTarif.charAt(3));
ProgrammeCircuit2 prgCircuit2 = convertProgrammeCircuit2(optionTarif.charAt(3));
frameCbemm = buildFrameCbemmTempoOption(frameValues, prgCircuit1, prgCircuit2);
} else {
final String error = String.format("The option Tarif '%s' is not supported", optionTarif);
throw new InvalidFrameException(error);
}
logger.trace("buildFrameCbemm(Map<Label, Object>) [end]");
return frameCbemm;
}
private void setCbemmCommonFrameFields(final FrameCbemm frame, final Map<Label, Object> frameValues)
throws InvalidFrameException {
logger.trace("setCbemmCommonFrameFields(Frame, Map<Label, Object>) [start]");
frame.setAdco(getRequiredLabelValue(Label.ADCO, frameValues));
frame.setIsousc(getRequiredLabelValue(Label.ISOUSC, frameValues));
frame.setIinst(getRequiredLabelValue(Label.IINST, frameValues));
frame.setImax(getOptionalLabelValue(Label.IMAX, frameValues));
frame.setPtec(getRequiredLabelValue(Label.PTEC, frameValues));
frame.setAdps(getOptionalLabelValue(Label.ADPS, frameValues));
frame.setMotdetat(getRequiredLabelValue(Label.MOTDETAT, frameValues));
logger.trace("setCbemmCommonFrameFields(Frame, Map<Label, Object>) [end]");
}
private FrameCbemmBaseOption buildFrameCbemmBaseOption(final Map<Label, Object> frameValues)
throws InvalidFrameException {
logger.trace("buildFrameCbemmBaseOption(Map<Label, Object>) [start]");
FrameCbemmBaseOption frame = new FrameCbemmBaseOption();
setCbemmCommonFrameFields(frame, frameValues);
setFrameBaseOptionFields(frame, frameValues);
logger.trace("buildFrameCbemmBaseOption(Map<Label, Object>) [end]");
return frame;
}
private FrameCbemmHcOption buildFrameCbemmHcOption(final Map<Label, Object> frameValues)
throws InvalidFrameException {
logger.trace("buildFrameCbemmHcOption(Map<Label, Object>) [start]");
FrameCbemmHcOption frame = new FrameCbemmHcOption();
setCbemmCommonFrameFields(frame, frameValues);
setFrameHcOptionFields(frame, frameValues);
logger.trace("buildFrameCbemmHcOption(Map<Label, Object>) [end]");
return frame;
}
private FrameCbemmEjpOption buildFrameCbemmEjpOption(final Map<Label, Object> frameValues)
throws InvalidFrameException {
logger.trace("buildFrameCbemmEjpOption(Map<Label, Object>) [start]");
FrameCbemmEjpOption frame = new FrameCbemmEjpOption();
setCbemmCommonFrameFields(frame, frameValues);
setFrameEjpOptionFields(frame, frameValues);
logger.trace("buildFrameCbemmEjpOption(Map<Label, Object>) [end]");
return frame;
}
private FrameCbemmTempoOption buildFrameCbemmTempoOption(final Map<Label, Object> frameValues,
ProgrammeCircuit1 prgCircuit1, ProgrammeCircuit2 prgCircuit2) throws InvalidFrameException {
logger.trace("buildFrameCbemmTempoOption(Map<Label, Object>) [start]");
FrameCbemmTempoOption frame = new FrameCbemmTempoOption();
setCbemmCommonFrameFields(frame, frameValues);
setFrameTempoOptionFields(frame, frameValues, prgCircuit1, prgCircuit2);
logger.trace("buildFrameCbemmTempoOption(Map<Label, Object>) [end]");
return frame;
}
private FrameCbemmEvolutionIcc buildFrameCbemmEvolutionIcc(final Map<Label, Object> frameValues)
throws InvalidFrameException {
logger.trace("buildFrameCbemmEvolutionIcc(Map<Label, Object>) [start]");
final FrameCbemmEvolutionIcc frameCbemmEvoIcc;
String optionTarif = getRequiredLabelValue(Label.OPTARIF, frameValues);
if ("BASE".equals(optionTarif)) {
frameCbemmEvoIcc = buildFrameCbemmEvolutionIccBaseOption(frameValues);
} else if ("HC..".equals(optionTarif)) {
frameCbemmEvoIcc = buildFrameCbemmEvolutionIccHcOption(frameValues);
} else if ("EJP.".equals(optionTarif)) {
frameCbemmEvoIcc = buildFrameCbemmEvolutionIccEjpOption(frameValues);
} else if (optionTarif.startsWith("BBR") && optionTarif.length() == 4) {
ProgrammeCircuit1 prgCircuit1 = convertProgrammeCircuit1(optionTarif.charAt(3));
ProgrammeCircuit2 prgCircuit2 = convertProgrammeCircuit2(optionTarif.charAt(3));
frameCbemmEvoIcc = buildFrameCbemmEvolutionIccTempoOption(frameValues, prgCircuit1, prgCircuit2);
} else {
final String error = String.format("The option Tarif '%s' is not supported", optionTarif);
throw new InvalidFrameException(error);
}
logger.trace("buildFrameCbemmEvolutionIcc(Map<Label, Object>) [end]");
return frameCbemmEvoIcc;
}
private void setCbemmEvolutionIccCommonFrameFields(final FrameCbemmEvolutionIcc frame,
final Map<Label, Object> frameValues) throws InvalidFrameException {
logger.trace("setCbemmEvolutionIccCommonFrameFields(Frame, Map<Label, Object>) [start]");
setCbemmCommonFrameFields(frame, frameValues);
frame.setPapp(getRequiredLabelValue(Label.PAPP, frameValues));
logger.trace("setCbemmEvolutionIccCommonFrameFields(Frame, Map<Label, Object>) [end]");
}
private FrameCbemmEvolutionIccBaseOption buildFrameCbemmEvolutionIccBaseOption(final Map<Label, Object> frameValues)
throws InvalidFrameException {
logger.trace("buildFrameCbemmEvolutionIccBaseOption(Map<Label, Object>) [start]");
FrameCbemmEvolutionIccBaseOption frame = new FrameCbemmEvolutionIccBaseOption();
setCbemmEvolutionIccCommonFrameFields(frame, frameValues);
setFrameBaseOptionFields(frame, frameValues);
logger.trace("buildFrameCbemmEvolutionIccBaseOption(Map<Label, Object>) [end]");
return frame;
}
private FrameCbemmEvolutionIccHcOption buildFrameCbemmEvolutionIccHcOption(final Map<Label, Object> frameValues)
throws InvalidFrameException {
logger.trace("buildFrameCbemmEvolutionIccHcOption(Map<Label, Object>) [start]");
FrameCbemmEvolutionIccHcOption frame = new FrameCbemmEvolutionIccHcOption();
setCbemmEvolutionIccCommonFrameFields(frame, frameValues);
setFrameHcOptionFields(frame, frameValues);
logger.trace("buildFrameCbemmEvolutionIccHcOption(Map<Label, Object>) [end]");
return frame;
}
private FrameCbemmEvolutionIccTempoOption buildFrameCbemmEvolutionIccTempoOption(
final Map<Label, Object> frameValues, ProgrammeCircuit1 prgCircuit1, ProgrammeCircuit2 prgCircuit2)
throws InvalidFrameException {
logger.trace("buildFrameCbemmEvolutionIccTempoOption(Map<Label, Object>) [start]");
FrameCbemmEvolutionIccTempoOption frame = new FrameCbemmEvolutionIccTempoOption();
setCbemmEvolutionIccCommonFrameFields(frame, frameValues);
setFrameTempoOptionFields(frame, frameValues, prgCircuit1, prgCircuit2);
logger.trace("buildFrameCbemmEvolutionIccTempoOption(Map<Label, Object>) [end]");
return frame;
}
private FrameCbemmEvolutionIccEjpOption buildFrameCbemmEvolutionIccEjpOption(final Map<Label, Object> frameValues)
throws InvalidFrameException {
logger.trace("buildFrameCbemmEvolutionIccEjpOption(Map<Label, Object>) [start]");
FrameCbemmEvolutionIccEjpOption frame = new FrameCbemmEvolutionIccEjpOption();
setCbemmEvolutionIccCommonFrameFields(frame, frameValues);
setFrameEjpOptionFields(frame, frameValues);
logger.trace("buildFrameCbemmEvolutionIccEjpOption(Map<Label, Object>) [end]");
return frame;
}
private void setFrameBaseOptionFields(final FrameBaseOption frameBaseOption, final Map<Label, Object> frameValues)
throws InvalidFrameException {
logger.trace("setFrameBaseOptionFields(FrameBaseOption) [start]");
frameBaseOption.setBase(getRequiredLabelValue(Label.BASE, frameValues));
logger.trace("setFrameBaseOptionFields(FrameBaseOption) [end]");
}
private void setFrameHcOptionFields(final FrameHcOption frameHcOption, final Map<Label, Object> frameValues)
throws InvalidFrameException {
logger.trace("setFrameHcOptionFields(FrameHcOption) [start]");
frameHcOption.setHchc(getRequiredLabelValue(Label.HCHC, frameValues));
frameHcOption.setHchp(getRequiredLabelValue(Label.HCHP, frameValues));
frameHcOption.setHhphc(getRequiredLabelValue(Label.HHPHC, frameValues));
logger.trace("setFrameHcOptionFields(FrameHcOption) [end]");
}
private void setFrameEjpOptionFields(final FrameEjpOption frameEjpOption, final Map<Label, Object> frameValues)
throws InvalidFrameException {
logger.trace("setFrameEjpOptionFields(FrameEjpOption) [start]");
frameEjpOption.setEjphn(getRequiredLabelValue(Label.EJPHN, frameValues));
frameEjpOption.setEjphpm(getRequiredLabelValue(Label.EJPHPM, frameValues));
frameEjpOption.setPejp(getOptionalLabelValue(Label.PEJP, frameValues));
logger.trace("setFrameEjpOptionFields(FrameEjpOption) [end]");
}
private void setFrameTempoOptionFields(final FrameTempoOption frameTempoOption,
final Map<Label, Object> frameValues, ProgrammeCircuit1 prgCircuit1, ProgrammeCircuit2 prgCircuit2)
throws InvalidFrameException {
logger.trace("setFrameTempoOptionFields(FrameTempoOption) [start]");
frameTempoOption.setBbrhpjr(getRequiredLabelValue(Label.BBRHPJR, frameValues));
frameTempoOption.setBbrhcjr(getRequiredLabelValue(Label.BBRHCJR, frameValues));
frameTempoOption.setBbrhpjw(getRequiredLabelValue(Label.BBRHPJW, frameValues));
frameTempoOption.setBbrhcjw(getRequiredLabelValue(Label.BBRHCJW, frameValues));
frameTempoOption.setBbrhpjb(getRequiredLabelValue(Label.BBRHPJB, frameValues));
frameTempoOption.setBbrhcjb(getRequiredLabelValue(Label.BBRHCJB, frameValues));
frameTempoOption.setDemain(getOptionalLabelValue(Label.DEMAIN, frameValues));
frameTempoOption.setHhphc(getRequiredLabelValue(Label.HHPHC, frameValues));
frameTempoOption.setProgrammeCircuit1(prgCircuit1);
frameTempoOption.setProgrammeCircuit2(prgCircuit2);
logger.trace("setFrameTempoOptionFields(FrameTempoOption) [end]");
}
@SuppressWarnings("unchecked")
private <T> T getRequiredLabelValue(Label label, final Map<Label, Object> frameValues)
throws InvalidFrameException {
if (!frameValues.containsKey(label)) {
final String error = String.format("The required label '%1$s' is missing in frame", label);
throw new InvalidFrameException(error);
}
return (T) frameValues.get(label);
}
@SuppressWarnings("unchecked")
private <T> T getOptionalLabelValue(Label label, final Map<Label, Object> frameValues) {
return (T) frameValues.get(label);
}
private ProgrammeCircuit1 convertProgrammeCircuit1(char value) {
String prgCircuit1 = computeProgrammeCircuitBinaryValue(value).substring(3, 5);
switch (prgCircuit1) {
case "01":
return ProgrammeCircuit1.A;
case "10":
return ProgrammeCircuit1.B;
case "11":
return ProgrammeCircuit1.C;
default:
final String error = String.format("Programme circuit 1 '%s' is unknown", prgCircuit1);
throw new IllegalStateException(error);
}
}
private ProgrammeCircuit2 convertProgrammeCircuit2(char value) {
String prgCircuit2 = computeProgrammeCircuitBinaryValue(value).substring(5, 8);
switch (prgCircuit2) {
case "000":
return ProgrammeCircuit2.P0;
case "001":
return ProgrammeCircuit2.P1;
case "010":
return ProgrammeCircuit2.P2;
case "011":
return ProgrammeCircuit2.P3;
case "100":
return ProgrammeCircuit2.P4;
case "101":
return ProgrammeCircuit2.P5;
case "110":
return ProgrammeCircuit2.P6;
case "111":
return ProgrammeCircuit2.P7;
default:
final String error = String.format("Programme circuit 2 '%s' is unknown", prgCircuit2);
throw new IllegalStateException(error);
}
}
private String computeProgrammeCircuitBinaryValue(char value) {
return String.format("%8s", Integer.toBinaryString(value)).replace(' ', '0');
}
private void rethrowTaskExecutionException(ExecutionException e)
throws InvalidFrameException, IOException, TimeoutException {
Throwable cause = e.getCause();
if (cause instanceof InvalidFrameException) {
throw (InvalidFrameException) cause;
} else if (cause instanceof IOException) {
throw (IOException) cause;
} else if (cause instanceof TimeoutException) {
throw (TimeoutException) cause;
} else {
throw new IllegalStateException(e);
}
}
}

View File

@@ -0,0 +1,43 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.reader.io.serialport;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
/**
* The {@link ConversionException} class defines a conversion exception.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public class ConversionException extends Exception {
private static final long serialVersionUID = -1109821041874271681L;
private static final String ERROR_MESSAGE = "Unable to convert '%1$s' value";
private String valueToConvert;
public ConversionException(String valueToConvert) {
this(valueToConvert, null);
}
public ConversionException(String valueToConvert, @Nullable Throwable cause) {
super(String.format(ERROR_MESSAGE, valueToConvert), cause);
this.valueToConvert = valueToConvert;
}
public String getValueToConvert() {
return valueToConvert;
}
}

View File

@@ -0,0 +1,46 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.reader.io.serialport;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
* The {@link FrameUtil} class defines a utility class for {@link FrameCbetmLong}.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public class FrameUtil {
private FrameUtil() {
// private constructor (utility class)
}
/**
* Compute the checksum of the given group line.
*
* @param groupLine group line ("etiquette" <SPACE> "valeur"). Note: the SPACE before the checksum of the group line
* must not include in checksum computation.
* @return the checksum of the given group line.
*/
public static char computeGroupLineChecksum(final String label, final String value) {
final String groupLine = label + " " + value;
int sum = 0;
for (int i = 0; i < groupLine.length(); i++) {
sum = sum + groupLine.codePointAt(i);
}
sum = (sum & 0x3F) + 0x20;
return (char) sum;
}
}

View File

@@ -0,0 +1,48 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.reader.io.serialport;
import java.util.Date;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
* The {@link InvalidFrameException} class defines an exception for invalid frames.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public class InvalidFrameException extends Exception {
private static final long serialVersionUID = 4729529258857792922L;
private Date timestamp;
public InvalidFrameException() {
timestamp = new Date();
}
public InvalidFrameException(String message) {
super(message, null);
timestamp = new Date();
}
public InvalidFrameException(String message, Throwable cause) {
super(message, cause);
timestamp = new Date();
}
public Date getTimestamp() {
return timestamp;
}
}

View File

@@ -0,0 +1,80 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.reader.io.serialport;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption.CouleurDemain;
import org.openhab.binding.teleinfo.internal.dto.common.Hhphc;
import org.openhab.binding.teleinfo.internal.dto.common.Ptec;
/**
* The {@link Label} enum defines all Teleinfo labels and their format.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public enum Label {
ADCO(String.class, 12),
OPTARIF(String.class, 4),
BASE(Integer.class, 9),
HCHC(Integer.class, 9),
HCHP(Integer.class, 9),
EJPHN(Integer.class, 9),
EJPHPM(Integer.class, 9),
GAZ(Integer.class, 7),
AUTRE(Integer.class, 7),
PTEC(Ptec.class, 4),
MOTDETAT(String.class, 6),
ISOUSC(Integer.class, 2),
IINST(Integer.class, 3),
IINST1(Integer.class, 3),
IINST2(Integer.class, 3),
IINST3(Integer.class, 3),
ADIR1(Integer.class, 3),
ADIR2(Integer.class, 3),
ADIR3(Integer.class, 3),
ADPS(Integer.class, 3),
IMAX(Integer.class, 3),
IMAX1(Integer.class, 3),
IMAX2(Integer.class, 3),
IMAX3(Integer.class, 3),
PMAX(Integer.class, 5),
PPOT(String.class, 2),
HHPHC(Hhphc.class, 1),
PAPP(Integer.class, 5),
BBRHCJB(Integer.class, 9),
BBRHPJB(Integer.class, 9),
BBRHCJW(Integer.class, 9),
BBRHPJW(Integer.class, 9),
BBRHCJR(Integer.class, 9),
BBRHPJR(Integer.class, 9),
PEJP(Integer.class, 2),
DEMAIN(CouleurDemain.class, 4);
private Class<?> type;
private int size;
Label(Class<?> type, int size) {
this.type = type;
this.size = size;
}
public Class<?> getType() {
return type;
}
public int getSize() {
return size;
}
}

View File

@@ -0,0 +1,28 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.reader.io.serialport.converter;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.teleinfo.internal.reader.io.serialport.ConversionException;
/**
* The {@link Converter} interface defines a converter to translate a Teleinfo String value into Java object.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public interface Converter {
public @Nullable Object convert(String value) throws ConversionException;
}

View File

@@ -0,0 +1,61 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.reader.io.serialport.converter;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption.CouleurDemain;
import org.openhab.binding.teleinfo.internal.reader.io.serialport.ConversionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The {@link CouleurDemainConverter} class defines a converter to translate a Teleinfo String value into
* {@link org.openhab.binding.teleinfo.internal.dto.common.Ptec} object.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public class CouleurDemainConverter implements Converter {
private final Logger logger = LoggerFactory.getLogger(CouleurDemainConverter.class);
@Override
public @Nullable Object convert(String value) throws ConversionException {
logger.debug("convert(String) [start]");
if (logger.isTraceEnabled()) {
logger.trace("value = {}", value);
}
CouleurDemain convertedValue = null;
switch (value) {
case "----":
// convertedValue = null;
break;
case "BLEU":
convertedValue = CouleurDemain.Bleu;
break;
case "BLAN":
convertedValue = CouleurDemain.Blanc;
break;
case "ROUG":
convertedValue = CouleurDemain.Rouge;
break;
default:
throw new ConversionException(value);
}
logger.debug("convert(String) [end]");
return convertedValue;
}
}

View File

@@ -0,0 +1,48 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.reader.io.serialport.converter;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.teleinfo.internal.reader.io.serialport.ConversionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The {@link FloatConverter} class defines a converter to translate a Teleinfo String value into Float object.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public class FloatConverter implements Converter {
private final Logger logger = LoggerFactory.getLogger(FloatConverter.class);
@Override
public @Nullable Object convert(String value) throws ConversionException {
logger.debug("convert(String) [start]");
if (logger.isTraceEnabled()) {
logger.trace("value = {}", value);
}
Object convertedValue = null;
try {
convertedValue = Float.parseFloat(value);
} catch (NumberFormatException e) {
throw new ConversionException(value, e);
}
logger.debug("convert(String) [end]");
return convertedValue;
}
}

View File

@@ -0,0 +1,64 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.reader.io.serialport.converter;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.teleinfo.internal.dto.common.Hhphc;
import org.openhab.binding.teleinfo.internal.reader.io.serialport.ConversionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The {@link HhphcConverter} class defines a converter to translate a Teleinfo String value into
* {@link Hhphc} object.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public class HhphcConverter implements Converter {
private final Logger logger = LoggerFactory.getLogger(HhphcConverter.class);
@Override
public @Nullable Object convert(String value) throws ConversionException {
logger.debug("convert(String) [start]");
if (logger.isTraceEnabled()) {
logger.trace("value = {}", value);
}
Hhphc convertedValue = null;
switch (value) {
case "A":
convertedValue = Hhphc.A;
break;
case "C":
convertedValue = Hhphc.C;
break;
case "D":
convertedValue = Hhphc.D;
break;
case "E":
convertedValue = Hhphc.E;
break;
case "Y":
convertedValue = Hhphc.Y;
break;
default:
throw new ConversionException(value);
}
logger.debug("convert(String) [end]");
return convertedValue;
}
}

View File

@@ -0,0 +1,48 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.reader.io.serialport.converter;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.teleinfo.internal.reader.io.serialport.ConversionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The {@link IntegerConverter} class defines a converter to translate a Teleinfo String value into Integer object.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public class IntegerConverter implements Converter {
private final Logger logger = LoggerFactory.getLogger(IntegerConverter.class);
@Override
public @Nullable Object convert(String value) throws ConversionException {
logger.debug("convert(String) [start]");
if (logger.isTraceEnabled()) {
logger.trace("value = {}", value);
}
Object convertedValue = null;
try {
convertedValue = Integer.parseInt(value, 10);
} catch (NumberFormatException e) {
throw new ConversionException(value, e);
}
logger.debug("convert(String) [end]");
return convertedValue;
}
}

View File

@@ -0,0 +1,82 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.reader.io.serialport.converter;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.teleinfo.internal.dto.common.Ptec;
import org.openhab.binding.teleinfo.internal.reader.io.serialport.ConversionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The {@link PtecConverter} class defines a converter to translate a Teleinfo String value into
* {@link Ptec} object.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public class PtecConverter implements Converter {
private final Logger logger = LoggerFactory.getLogger(PtecConverter.class);
@Override
public @Nullable Object convert(String value) throws ConversionException {
logger.debug("convert(String) [start]");
if (logger.isTraceEnabled()) {
logger.trace("value = {}", value);
}
Ptec convertedValue = null;
switch (value) {
case "TH..":
convertedValue = Ptec.TH;
break;
case "HC..":
convertedValue = Ptec.HC;
break;
case "HP..":
convertedValue = Ptec.HP;
break;
case "HN..":
convertedValue = Ptec.HN;
break;
case "PM..":
convertedValue = Ptec.PM;
break;
case "HCJB":
convertedValue = Ptec.HCJB;
break;
case "HCJW":
convertedValue = Ptec.HCJW;
break;
case "HCJR":
convertedValue = Ptec.HCJR;
break;
case "HPJB":
convertedValue = Ptec.HPJB;
break;
case "HPJW":
convertedValue = Ptec.HPJW;
break;
case "HPJR":
convertedValue = Ptec.HPJR;
break;
default:
throw new ConversionException(value);
}
logger.debug("convert(String) [end]");
return convertedValue;
}
}

View File

@@ -0,0 +1,41 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.reader.io.serialport.converter;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.teleinfo.internal.reader.io.serialport.ConversionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The {@link StringConverter} class defines a converter to translate a Teleinfo String value into String object.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public class StringConverter implements Converter {
private final Logger logger = LoggerFactory.getLogger(StringConverter.class);
@Override
public @Nullable Object convert(String value) throws ConversionException {
logger.debug("convert(String) [start]");
if (logger.isTraceEnabled()) {
logger.trace("value = {}", value);
}
logger.debug("convert(String) [end]");
return value;
}
}

View File

@@ -0,0 +1,105 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.serial;
import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeoutException;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.teleinfo.internal.dto.Frame;
import org.openhab.binding.teleinfo.internal.reader.io.TeleinfoInputStream;
import org.openhab.binding.teleinfo.internal.reader.io.serialport.InvalidFrameException;
import org.openhab.core.io.transport.serial.SerialPort;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The {@link TeleinfoReceiveThread} class defines a thread to decode and fire Teleinfo frames for Serial controller.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public class TeleinfoReceiveThread extends Thread {
private static final int SERIAL_PORT_DELAY_RETRY_IN_SECONDS = 60;
private final Logger logger = LoggerFactory.getLogger(TeleinfoReceiveThread.class);
private SerialPort serialPort;
private @Nullable TeleinfoReceiveThreadListener listener;
private boolean autoRepairInvalidADPSgroupLine;
private ExecutorService executorService;
public TeleinfoReceiveThread(SerialPort serialPort, final TeleinfoSerialControllerHandler listener,
boolean autoRepairInvalidADPSgroupLine, ExecutorService scheduler) {
super("OH-binding-TeleinfoReceiveThread-" + listener.getThing().getUID().getId());
setDaemon(true);
this.serialPort = serialPort;
this.listener = listener;
this.autoRepairInvalidADPSgroupLine = autoRepairInvalidADPSgroupLine;
this.executorService = scheduler;
}
@Override
public void run() {
try (TeleinfoInputStream teleinfoStream = new TeleinfoInputStream(serialPort.getInputStream(),
TeleinfoInputStream.DEFAULT_TIMEOUT_NEXT_HEADER_FRAME_US * 100,
TeleinfoInputStream.DEFAULT_TIMEOUT_READING_FRAME_US * 100, autoRepairInvalidADPSgroupLine,
executorService)) {
while (!interrupted()) {
TeleinfoReceiveThreadListener listener = this.listener;
if (listener != null) {
try {
Frame nextFrame = teleinfoStream.readNextFrame();
if (nextFrame != null)
listener.onFrameReceived(this, nextFrame);
} catch (InvalidFrameException e) {
logger.warn("Got invalid frame. Detail: \"{}\"", e.getLocalizedMessage());
listener.onInvalidFrameReceived(this, e);
} catch (TimeoutException e) {
logger.warn("Got timeout during frame reading", e);
logger.warn("Retry in progress. Next retry in {} seconds...",
SERIAL_PORT_DELAY_RETRY_IN_SECONDS);
listener.continueOnReadNextFrameTimeoutException();
try {
Thread.sleep(SERIAL_PORT_DELAY_RETRY_IN_SECONDS * 1000);
} catch (InterruptedException e1) {
break;
}
} catch (IOException e) {
logger.warn("Got I/O exception. Detail: \"{}\"", e.getLocalizedMessage(), e);
listener.onSerialPortInputStreamIOException(this, e);
break;
} catch (IllegalStateException e) {
logger.warn("Got illegal state exception", e);
}
}
}
} catch (IOException e) {
logger.warn("An error occurred during serial port input stream opening", e);
}
serialPort.removeEventListener();
}
public @Nullable TeleinfoReceiveThreadListener getListener() {
return listener;
}
public void setListener(@Nullable TeleinfoReceiveThreadListener listener) {
this.listener = listener;
}
}

View File

@@ -0,0 +1,36 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.serial;
import java.io.IOException;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.teleinfo.internal.dto.Frame;
import org.openhab.binding.teleinfo.internal.reader.io.serialport.InvalidFrameException;
/**
* The {@link TeleinfoReceiveThreadListener} interface defines all events pushed by a {@link TeleinfoReceiveThread}.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public interface TeleinfoReceiveThreadListener {
void onFrameReceived(final TeleinfoReceiveThread receiveThread, final Frame frame);
void onInvalidFrameReceived(final TeleinfoReceiveThread receiveThread, final InvalidFrameException error);
void onSerialPortInputStreamIOException(final TeleinfoReceiveThread receiveThread, final IOException e);
void continueOnReadNextFrameTimeoutException();
}

View File

@@ -0,0 +1,27 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.serial;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
* The {@link TeleinfoSerialControllerConfiguration} class contains fields mapping thing configuration parameters.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public class TeleinfoSerialControllerConfiguration {
public String serialport = "";
public boolean autoRepairInvalidADPSgroupLine = true;
}

View File

@@ -0,0 +1,195 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.serial;
import static org.openhab.binding.teleinfo.internal.TeleinfoBindingConstants.*;
import java.io.IOException;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.teleinfo.internal.dto.Frame;
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
import org.openhab.binding.teleinfo.internal.reader.io.serialport.InvalidFrameException;
import org.openhab.core.io.transport.serial.PortInUseException;
import org.openhab.core.io.transport.serial.SerialPort;
import org.openhab.core.io.transport.serial.SerialPortIdentifier;
import org.openhab.core.io.transport.serial.SerialPortManager;
import org.openhab.core.io.transport.serial.UnsupportedCommOperationException;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.ThingStatusDetail;
import org.openhab.core.types.Command;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The {@link TeleinfoSerialControllerHandler} class defines a handler for serial controller.
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public class TeleinfoSerialControllerHandler extends TeleinfoAbstractControllerHandler
implements TeleinfoReceiveThreadListener {
private final Logger logger = LoggerFactory.getLogger(TeleinfoSerialControllerHandler.class);
private static final int SERIAL_RECEIVE_TIMEOUT_MS = 250;
private static final int RECEIVER_THREAD_JOIN_DELAY_MS = 500;
private SerialPortManager serialPortManager;
private @Nullable SerialPort serialPort;
private @Nullable TeleinfoReceiveThread receiveThread;
private @Nullable ScheduledFuture<?> keepAliveThread;
private long invalidFrameCounter = 0;
public TeleinfoSerialControllerHandler(Bridge thing, SerialPortManager serialPortManager) {
super(thing);
this.serialPortManager = serialPortManager;
}
@Override
public void initialize() {
invalidFrameCounter = 0;
keepAliveThread = scheduler.scheduleWithFixedDelay(() -> {
if (!isInitialized()) {
openSerialPortAndStartReceiving();
updateStatus(ThingStatus.UNKNOWN);
}
logger.debug("Check Teleinfo receiveThread status...");
logger.debug("isInitialized() = {}", isInitialized());
TeleinfoReceiveThread receiveThreadRef = receiveThread;
if (receiveThreadRef != null) {
logger.debug("receiveThread.isAlive() = {}", receiveThreadRef.isAlive());
}
if (isInitialized() && (receiveThreadRef == null || !receiveThreadRef.isAlive())) {
updateStatus(ThingStatus.UNKNOWN, ThingStatusDetail.NONE, ERROR_UNKNOWN_RETRY_IN_PROGRESS);
logger.info("Try to restart Teleinfo receiving...");
stopReceivingAndCloseSerialPort();
openSerialPortAndStartReceiving();
}
}, 0, 60, TimeUnit.SECONDS);
}
@Override
public void dispose() {
ScheduledFuture<?> keepAliveThreadRef = keepAliveThread;
if (keepAliveThreadRef != null) {
keepAliveThreadRef.cancel(true);
keepAliveThread = null;
}
stopReceivingAndCloseSerialPort();
super.dispose();
}
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
}
@Override
public void onFrameReceived(TeleinfoReceiveThread receiveThread, Frame frame) {
updateStatus(ThingStatus.ONLINE);
fireOnFrameReceivedEvent(frame);
}
@Override
public void onInvalidFrameReceived(TeleinfoReceiveThread receiveThread, InvalidFrameException error) {
invalidFrameCounter++;
updateState(THING_SERIAL_CONTROLLER_CHANNEL_INVALID_FRAME_COUNTER, new DecimalType(invalidFrameCounter));
}
@Override
public void onSerialPortInputStreamIOException(TeleinfoReceiveThread receiveThread, IOException e) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, ERROR_UNKNOWN_RETRY_IN_PROGRESS);
}
@Override
public void continueOnReadNextFrameTimeoutException() {
updateStatus(ThingStatus.UNKNOWN, ThingStatusDetail.NONE, ERROR_UNKNOWN_RETRY_IN_PROGRESS);
}
private void openSerialPortAndStartReceiving() {
TeleinfoSerialControllerConfiguration config = getConfigAs(TeleinfoSerialControllerConfiguration.class);
if (config.serialport.trim().isEmpty()) {
logger.warn("Teleinfo port is not set.");
return;
}
logger.debug("Connecting to serial port '{}'...", config.serialport);
String currentOwner = null;
try {
final SerialPortIdentifier portIdentifier = serialPortManager.getIdentifier(config.serialport);
logger.debug("portIdentifier = {}", portIdentifier);
if (portIdentifier == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR,
ERROR_OFFLINE_SERIAL_NOT_FOUND);
return;
}
logger.debug("Opening portIdentifier");
currentOwner = portIdentifier.getCurrentOwner();
logger.debug("portIdentifier.getCurrentOwner() = {}", currentOwner);
SerialPort commPort = portIdentifier.open("org.openhab.binding.teleinfo", 5000);
serialPort = commPort;
commPort.setSerialPortParams(1200, SerialPort.DATABITS_7, SerialPort.STOPBITS_1, SerialPort.PARITY_EVEN);
try {
commPort.enableReceiveThreshold(1);
} catch (UnsupportedCommOperationException e) {
// rfc2217
}
try {
commPort.enableReceiveTimeout(SERIAL_RECEIVE_TIMEOUT_MS);
} catch (UnsupportedCommOperationException e) {
// rfc2217
}
logger.debug("Starting receive thread");
TeleinfoReceiveThread receiveThread = new TeleinfoReceiveThread(commPort, this,
config.autoRepairInvalidADPSgroupLine, scheduler);
this.receiveThread = receiveThread;
receiveThread.start();
logger.debug("Connected to serial port '{}'", config.serialport);
} catch (PortInUseException e) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR,
ERROR_OFFLINE_SERIAL_INUSE);
} catch (UnsupportedCommOperationException e) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR,
ERROR_OFFLINE_SERIAL_UNSUPPORTED);
}
}
private void stopReceivingAndCloseSerialPort() {
TeleinfoReceiveThread receiveThreadRef = receiveThread;
if (receiveThreadRef != null) {
receiveThreadRef.interrupt();
try {
receiveThreadRef.join(RECEIVER_THREAD_JOIN_DELAY_MS);
} catch (InterruptedException e) {
}
receiveThreadRef.setListener(null);
receiveThread = null;
}
SerialPort serialPortRef = serialPort;
if (serialPortRef != null) {
serialPortRef.close();
serialPort = null;
}
}
}

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<binding:binding id="teleinfo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:binding="https://openhab.org/schemas/binding/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/binding/v1.0.0 https://openhab.org/schemas/binding-1.0.0.xsd">
<name>Teleinfo Binding</name>
<description>The Teleinfo binding decodes the electrical statistics from an ENEDIS/ERDF Electricity Meter</description>
<author>Nicolas Siberil</author>
</binding:binding>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<config-description:config-descriptions
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:config-description="https://openhab.org/schemas/config-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/config-description/v1.0.0
https://openhab.org/schemas/config-description-1.0.0.xsd">
<config-description uri="binding:teleinfo:adco">
<parameter name="adco" type="text" required="true" pattern="^\w{12}$">
<label>ADCO</label>
<description>Electricity meter identifier (format: 12 characters / e.g: '031528042289')</description>
<limitToOptions>false</limitToOptions>
</parameter>
</config-description>
</config-description:config-descriptions>

View File

@@ -0,0 +1,6 @@
teleinfo.thingstate.serial_notfound=Serial Error: Port {0} does not exist
teleinfo.thingstate.serial_inuse=Serial Error: Port {0} is in use
teleinfo.thingstate.serial_unsupported=Serial Error: Unsupported operation on port {0}
teleinfo.thingstate.serial_listeners=Serial Error: Too many listeners on port {0}
teleinfo.thingstate.controller_offline=Controller is offline
teleinfo.thingstate.controller_unknown_retry_inprogress=Serial Error: Retry in progress...

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="teleinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="cbemm_base_electricitymeter" listed="false">
<supported-bridge-type-refs>
<bridge-type-ref id="serialcontroller"/>
</supported-bridge-type-refs>
<label>CBEMM BASE</label>
<description>Single-phase Electricity meter with BASE option - CBEMM (aka "Compteur Bleu Electronique Monophasé
Multitarif")</description>
<channels>
<channel id="isousc" typeId="isouscType"/>
<channel id="ptec" typeId="ptecType"/>
<channel id="imax" typeId="imaxType"/>
<channel id="adps" typeId="adpsType"/>
<channel id="iinst" typeId="iinstType"/>
<channel id="lastUpdate" typeId="lastUpdateType"/>
<channel id="base" typeId="baseType"/>
</channels>
<config-description-ref uri="binding:teleinfo:adco"/>
</thing-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="teleinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="cbemm_ejp_electricitymeter" listed="false">
<supported-bridge-type-refs>
<bridge-type-ref id="serialcontroller"/>
</supported-bridge-type-refs>
<label>CBEMM EJP</label>
<description>Single-phase Electricity meter with EJP option - CBEMM (aka "Compteur Bleu Electronique Monophasé
Multitarif")</description>
<channels>
<channel id="isousc" typeId="isouscType"/>
<channel id="ptec" typeId="ptecType"/>
<channel id="imax" typeId="imaxType"/>
<channel id="adps" typeId="adpsType"/>
<channel id="iinst" typeId="iinstType"/>
<channel id="pejp" typeId="pejpType"/>
<channel id="ejphpm" typeId="ejphpmType"/>
<channel id="ejphn" typeId="ejphnType"/>
<channel id="lastUpdate" typeId="lastUpdateType"/>
</channels>
<config-description-ref uri="binding:teleinfo:adco"/>
</thing-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="teleinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="cbemm_evolution_icc_base_electricitymeter" listed="false">
<supported-bridge-type-refs>
<bridge-type-ref id="serialcontroller"/>
</supported-bridge-type-refs>
<label>CBEMM ICC BASE</label>
<description>Single-phase Electricity meter with BASE option - CBEMM Evolution ICC (aka "Compteur Bleu Electronique
Monophasé Multitarif Evolution ICC")</description>
<channels>
<channel id="isousc" typeId="isouscType"/>
<channel id="ptec" typeId="ptecType"/>
<channel id="imax" typeId="imaxType"/>
<channel id="adps" typeId="adpsType"/>
<channel id="papp" typeId="pappType"/>
<channel id="iinst" typeId="iinstType"/>
<channel id="lastUpdate" typeId="lastUpdateType"/>
<channel id="base" typeId="baseType"/>
</channels>
<config-description-ref uri="binding:teleinfo:adco"/>
</thing-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="teleinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="cbemm_evolution_icc_ejp_electricitymeter" listed="false">
<supported-bridge-type-refs>
<bridge-type-ref id="serialcontroller"/>
</supported-bridge-type-refs>
<label>CBEMM EJP</label>
<description>Single-phase Electricity meter with EJP option - CBEMM (aka "Compteur Bleu Electronique Monophasé
Multitarif")</description>
<channels>
<channel id="isousc" typeId="isouscType"/>
<channel id="ptec" typeId="ptecType"/>
<channel id="imax" typeId="imaxType"/>
<channel id="adps" typeId="adpsType"/>
<channel id="papp" typeId="pappType"/>
<channel id="iinst" typeId="iinstType"/>
<channel id="pejp" typeId="pejpType"/>
<channel id="ejphpm" typeId="ejphpmType"/>
<channel id="ejphn" typeId="ejphnType"/>
<channel id="lastUpdate" typeId="lastUpdateType"/>
</channels>
<config-description-ref uri="binding:teleinfo:adco"/>
</thing-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="teleinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="cbemm_evolution_icc_hc_electricitymeter" listed="false">
<supported-bridge-type-refs>
<bridge-type-ref id="serialcontroller"/>
</supported-bridge-type-refs>
<label>CBEMM ICC HC/HP</label>
<description>Single-phase Electricity meter with HC/HP option - CBEMM Evolution ICC (aka "Compteur Bleu Electronique
Monophasé Multitarif Evolution ICC")</description>
<channels>
<channel id="isousc" typeId="isouscType"/>
<channel id="ptec" typeId="ptecType"/>
<channel id="imax" typeId="imaxType"/>
<channel id="adps" typeId="adpsType"/>
<channel id="papp" typeId="pappType"/>
<channel id="iinst" typeId="iinstType"/>
<channel id="hchc" typeId="hchcType"/>
<channel id="hchp" typeId="hchpType"/>
<channel id="hhphc" typeId="hhphcType"/>
<channel id="lastUpdate" typeId="lastUpdateType"/>
</channels>
<config-description-ref uri="binding:teleinfo:adco"/>
</thing-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="teleinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="cbemm_evolution_icc_tempo_electricitymeter" listed="false">
<supported-bridge-type-refs>
<bridge-type-ref id="serialcontroller"/>
</supported-bridge-type-refs>
<label>CBEMM ICC TEMPO</label>
<description>Single-phase Electricity meter with TEMPO option - CBEMM Evolution ICC (aka "Compteur Bleu Electronique
Monophasé Multitarif Evolution ICC")</description>
<channels>
<channel id="isousc" typeId="isouscType"/>
<channel id="ptec" typeId="ptecType"/>
<channel id="imax" typeId="imaxType"/>
<channel id="adps" typeId="adpsType"/>
<channel id="papp" typeId="pappType"/>
<channel id="iinst" typeId="iinstType"/>
<channel id="bbrhpjr" typeId="bbrhpjrType"/>
<channel id="bbrhcjr" typeId="bbrhcjrType"/>
<channel id="bbrhpjw" typeId="bbrhpjwType"/>
<channel id="bbrhcjw" typeId="bbrhcjwType"/>
<channel id="bbrhpjb" typeId="bbrhpjbType"/>
<channel id="bbrhcjb" typeId="bbrhcjbType"/>
<channel id="demain" typeId="couleurDemainType"/>
<channel id="hhphc" typeId="hhphcType"/>
<channel id="programmeCircuit1" typeId="programmeCircuit1Type"/>
<channel id="programmeCircuit2" typeId="programmeCircuit2Type"/>
<channel id="lastUpdate" typeId="lastUpdateType"/>
</channels>
<config-description-ref uri="binding:teleinfo:adco"/>
</thing-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="teleinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="cbemm_hc_electricitymeter" listed="false">
<supported-bridge-type-refs>
<bridge-type-ref id="serialcontroller"/>
</supported-bridge-type-refs>
<label>CBEMM HC/HP</label>
<description>Single-phase Electricity meter with HC/HP option - CBEMM (aka "Compteur Bleu Electronique Monophasé
Multitarif")</description>
<channels>
<channel id="isousc" typeId="isouscType"/>
<channel id="ptec" typeId="ptecType"/>
<channel id="imax" typeId="imaxType"/>
<channel id="adps" typeId="adpsType"/>
<channel id="iinst" typeId="iinstType"/>
<channel id="hchc" typeId="hchcType"/>
<channel id="hchp" typeId="hchpType"/>
<channel id="hhphc" typeId="hhphcType"/>
<channel id="lastUpdate" typeId="lastUpdateType"/>
</channels>
<config-description-ref uri="binding:teleinfo:adco"/>
</thing-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="teleinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="cbemm_tempo_electricitymeter" listed="false">
<supported-bridge-type-refs>
<bridge-type-ref id="serialcontroller"/>
</supported-bridge-type-refs>
<label>CBEMM TEMPO</label>
<description>Single-phase Electricity meter with TEMPO option - CBEMM (aka "Compteur Bleu Electronique Monophasé
Multitarif")</description>
<channels>
<channel id="isousc" typeId="isouscType"/>
<channel id="ptec" typeId="ptecType"/>
<channel id="imax" typeId="imaxType"/>
<channel id="adps" typeId="adpsType"/>
<channel id="iinst" typeId="iinstType"/>
<channel id="bbrhpjr" typeId="bbrhpjrType"/>
<channel id="bbrhcjr" typeId="bbrhcjrType"/>
<channel id="bbrhpjw" typeId="bbrhpjwType"/>
<channel id="bbrhcjw" typeId="bbrhcjwType"/>
<channel id="bbrhpjb" typeId="bbrhpjbType"/>
<channel id="bbrhcjb" typeId="bbrhcjbType"/>
<channel id="demain" typeId="couleurDemainType"/>
<channel id="hhphc" typeId="hhphcType"/>
<channel id="programmeCircuit1" typeId="programmeCircuit1Type"/>
<channel id="programmeCircuit2" typeId="programmeCircuit2Type"/>
<channel id="lastUpdate" typeId="lastUpdateType"/>
</channels>
<config-description-ref uri="binding:teleinfo:adco"/>
</thing-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="teleinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="cbetm_base_electricitymeter" listed="false">
<supported-bridge-type-refs>
<bridge-type-ref id="serialcontroller"/>
</supported-bridge-type-refs>
<label>CBETM BASE</label>
<description>Three-phase Electricity meter with BASE option - CBETM (aka "Compteur Bleu Electronique Triphasé
Multitarif")</description>
<channels>
<channel id="frameType" typeId="frameTypeType"/>
<channel id="isousc" typeId="isouscType"/>
<channel id="ptec" typeId="ptecType"/>
<channel id="iinst1" typeId="iinst1Type"/>
<channel id="iinst2" typeId="iinst2Type"/>
<channel id="iinst3" typeId="iinst3Type"/>
<channel id="imax1" typeId="imax1Type"/>
<channel id="imax2" typeId="imax2Type"/>
<channel id="imax3" typeId="imax3Type"/>
<channel id="pmax" typeId="pmaxType"/>
<channel id="papp" typeId="pappType"/>
<channel id="ppot" typeId="ppotType"/>
<channel id="adir1" typeId="adir1Type"/>
<channel id="adir2" typeId="adir2Type"/>
<channel id="adir3" typeId="adir3Type"/>
<channel id="lastUpdate" typeId="lastUpdateType"/>
<channel id="base" typeId="baseType"/>
</channels>
<config-description-ref uri="binding:teleinfo:adco"/>
</thing-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="teleinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="cbetm_ejp_electricitymeter" listed="false">
<supported-bridge-type-refs>
<bridge-type-ref id="serialcontroller"/>
</supported-bridge-type-refs>
<label>CBETM EJP</label>
<description>Three-phase Electricity meter with EJP option - CBETM (aka "Compteur Bleu Electronique Triphasé
Multitarif")</description>
<channels>
<channel id="frameType" typeId="frameTypeType"/>
<channel id="isousc" typeId="isouscType"/>
<channel id="ptec" typeId="ptecType"/>
<channel id="iinst1" typeId="iinst1Type"/>
<channel id="iinst2" typeId="iinst2Type"/>
<channel id="iinst3" typeId="iinst3Type"/>
<channel id="imax1" typeId="imax1Type"/>
<channel id="imax2" typeId="imax2Type"/>
<channel id="imax3" typeId="imax3Type"/>
<channel id="pmax" typeId="pmaxType"/>
<channel id="papp" typeId="pappType"/>
<channel id="ppot" typeId="ppotType"/>
<channel id="adir1" typeId="adir1Type"/>
<channel id="adir2" typeId="adir2Type"/>
<channel id="adir3" typeId="adir3Type"/>
<channel id="lastUpdate" typeId="lastUpdateType"/>
<channel id="pejp" typeId="pejpType"/>
<channel id="ejphpm" typeId="ejphpmType"/>
<channel id="ejphn" typeId="ejphnType"/>
</channels>
<config-description-ref uri="binding:teleinfo:adco"/>
</thing-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="teleinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="cbetm_hc_electricitymeter" listed="false">
<supported-bridge-type-refs>
<bridge-type-ref id="serialcontroller"/>
</supported-bridge-type-refs>
<label>CBETM HC/HP</label>
<description>Three-phase Electricity meter with HC option - CBETM (aka "Compteur Bleu Electronique Triphasé
Multitarif")</description>
<channels>
<channel id="frameType" typeId="frameTypeType"/>
<channel id="isousc" typeId="isouscType"/>
<channel id="ptec" typeId="ptecType"/>
<channel id="iinst1" typeId="iinst1Type"/>
<channel id="iinst2" typeId="iinst2Type"/>
<channel id="iinst3" typeId="iinst3Type"/>
<channel id="imax1" typeId="imax1Type"/>
<channel id="imax2" typeId="imax2Type"/>
<channel id="imax3" typeId="imax3Type"/>
<channel id="pmax" typeId="pmaxType"/>
<channel id="papp" typeId="pappType"/>
<channel id="ppot" typeId="ppotType"/>
<channel id="adir1" typeId="adir1Type"/>
<channel id="adir2" typeId="adir2Type"/>
<channel id="adir3" typeId="adir3Type"/>
<channel id="lastUpdate" typeId="lastUpdateType"/>
<channel id="hchc" typeId="hchcType"/>
<channel id="hchp" typeId="hchpType"/>
<channel id="hhphc" typeId="hhphcType"/>
</channels>
<config-description-ref uri="binding:teleinfo:adco"/>
</thing-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="teleinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="cbetm_tempo_electricitymeter" listed="false">
<supported-bridge-type-refs>
<bridge-type-ref id="serialcontroller"/>
</supported-bridge-type-refs>
<label>CBETM TEMPO</label>
<description>Three-phase Electricity meter with TEMPO option - CBETM (aka "Compteur Bleu Electronique Triphasé
Multitarif")</description>
<channels>
<channel id="frameType" typeId="frameTypeType"/>
<channel id="isousc" typeId="isouscType"/>
<channel id="ptec" typeId="ptecType"/>
<channel id="iinst1" typeId="iinst1Type"/>
<channel id="iinst2" typeId="iinst2Type"/>
<channel id="iinst3" typeId="iinst3Type"/>
<channel id="imax1" typeId="imax1Type"/>
<channel id="imax2" typeId="imax2Type"/>
<channel id="imax3" typeId="imax3Type"/>
<channel id="pmax" typeId="pmaxType"/>
<channel id="papp" typeId="pappType"/>
<channel id="ppot" typeId="ppotType"/>
<channel id="adir1" typeId="adir1Type"/>
<channel id="adir2" typeId="adir2Type"/>
<channel id="adir3" typeId="adir3Type"/>
<channel id="bbrhpjr" typeId="bbrhpjrType"/>
<channel id="bbrhcjr" typeId="bbrhcjrType"/>
<channel id="bbrhpjw" typeId="bbrhpjwType"/>
<channel id="bbrhcjw" typeId="bbrhcjwType"/>
<channel id="bbrhpjb" typeId="bbrhpjbType"/>
<channel id="bbrhcjb" typeId="bbrhcjbType"/>
<channel id="demain" typeId="couleurDemainType"/>
<channel id="hhphc" typeId="hhphcType"/>
<channel id="programmeCircuit1" typeId="programmeCircuit1Type"/>
<channel id="programmeCircuit2" typeId="programmeCircuit2Type"/>
<channel id="lastUpdate" typeId="lastUpdateType"/>
</channels>
<config-description-ref uri="binding:teleinfo:adco"/>
</thing-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="teleinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<channel-type id="baseType">
<item-type>Number:Energy</item-type>
<label>BASE</label>
<description>Total consumed energy</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="teleinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<channel-type id="imaxType">
<item-type>Number:ElectricCurrent</item-type>
<label>IMAX</label>
<description>Maximum consumed electric current</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="iinstType">
<item-type>Number:ElectricCurrent</item-type>
<label>IINST</label>
<description>Instantaneous electric current</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="adpsType">
<item-type>Number:ElectricCurrent</item-type>
<label>ADPS</label>
<description>Excess electric current warning</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="teleinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<channel-type id="pappType">
<item-type>Number</item-type>
<label>PAPP</label>
<description>Instantaneous apparent power</description>
<category>Energy</category>
<state pattern="%d VA" readOnly="true"/>
</channel-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="teleinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<channel-type id="frameTypeType" advanced="true">
<item-type>String</item-type>
<label>frameType</label>
<description>frameType</description>
<category>Energy</category>
<state pattern="%s" readOnly="true">
<options>
<option value="Long">Long</option>
<option value="Short">Short</option>
</options>
</state>
</channel-type>
<channel-type id="iinst1Type">
<item-type>Number:ElectricCurrent</item-type>
<label>IINST1</label>
<description>Instantaneous electric current on phase 1</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="iinst2Type">
<item-type>Number:ElectricCurrent</item-type>
<label>IINST2</label>
<description>Instantaneous electric current on phase 2</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="iinst3Type">
<item-type>Number:ElectricCurrent</item-type>
<label>IINST3</label>
<description>Instantaneous electric current on phase 3</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="imax1Type">
<item-type>Number:ElectricCurrent</item-type>
<label>IMAX1</label>
<description>Maximum consumed electric current on phase 1</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="imax2Type">
<item-type>Number:ElectricCurrent</item-type>
<label>IMAX2</label>
<description>Maximum consumed electric current on phase 2</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="imax3Type">
<item-type>Number:ElectricCurrent</item-type>
<label>IMAX3</label>
<description>Maximum consumed electric current on phase 3</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="pmaxType">
<item-type>Number:Power</item-type>
<label>PMAX</label>
<description>Maximum consumed electric power on all phases</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="pappType">
<item-type>Number</item-type>
<label>PAPP</label>
<description>Instantaneous apparent power</description>
<category>Energy</category>
<state pattern="%d VA" readOnly="true"/>
</channel-type>
<channel-type id="ppotType">
<item-type>String</item-type>
<label>PPOT</label>
<description>Electrical potential presence</description>
<category>Energy</category>
<state pattern="%s" readOnly="true"/>
</channel-type>
<channel-type id="adir1Type">
<item-type>Number:ElectricCurrent</item-type>
<label>ADIR1</label>
<description>Excess electric current on phase 1 warning</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="adir2Type">
<item-type>Number:ElectricCurrent</item-type>
<label>ADIR2</label>
<description>Excess electric current on phase 2 warning</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="adir3Type">
<item-type>Number:ElectricCurrent</item-type>
<label>ADIR3</label>
<description>Excess electric current on phase 3 warning</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="teleinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<channel-type id="isouscType">
<item-type>Number:ElectricCurrent</item-type>
<label>ISOUSC</label>
<description>Subscribed electric current</description>
<category>Energy</category>
<state pattern="%d A" readOnly="true"/>
</channel-type>
<channel-type id="ptecType">
<item-type>String</item-type>
<label>PTEC</label>
<description>Current pricing period</description>
<category>Energy</category>
<state pattern="%s" readOnly="true">
<options>
<option value="TH">TH</option>
<option value="HC">HC</option>
<option value="HP">HP</option>
<option value="HN">HN</option>
<option value="PM">PM</option>
<option value="HCJB">HCJB</option>
<option value="HCJW">HCJW</option>
<option value="HCJR">HCJR</option>
<option value="HPJB">HPJB</option>
<option value="HPJW">HPJW</option>
<option value="HPJR">HPJR</option>
</options>
</state>
</channel-type>
<channel-type id="hhphcType">
<item-type>String</item-type>
<label>HHPHC</label>
<description>Pricing schedule group</description>
<category>Energy</category>
<state pattern="%s" readOnly="true">
<options>
<option value="A">A</option>
<option value="C">C</option>
<option value="D">D</option>
<option value="E">E</option>
<option value="Y">Y</option>
</options>
</state>
</channel-type>
<channel-type id="lastUpdateType">
<item-type>DateTime</item-type>
<label>Last Update</label>
<description>Timestamp of last received Teleinfo frame</description>
<state readOnly="true"/>
</channel-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="teleinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<channel-type id="ejphpmType">
<item-type>Number:Energy</item-type>
<label>EJPHPM</label>
<description>Total consumed energy at high rate pricing</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="ejphnType">
<item-type>Number:Energy</item-type>
<label>EJPHN</label>
<description>Total consumed energy at low rate pricing</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="pejpType">
<item-type>Number:Time</item-type>
<label>PEJP</label>
<description>Prior notice to EJP start</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="teleinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<channel-type id="hchcType">
<item-type>Number:Energy</item-type>
<label>HCHC</label>
<description>Total consumed energy at low rate pricing</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="hchpType">
<item-type>Number:Energy</item-type>
<label>HCHP</label>
<description>Total consumed energy at high rate pricing</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="teleinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<channel-type id="bbrhpjrType">
<item-type>Number:Energy</item-type>
<label>BBRHPJR</label>
<description>Total consumed energy at high rate pricing on red days</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="bbrhcjrType">
<item-type>Number:Energy</item-type>
<label>BBRHCJR</label>
<description>Total consumed energy at low rate pricing on red days</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="bbrhpjwType">
<item-type>Number:Energy</item-type>
<label>BBRHPJW</label>
<description>Total consumed energy at high rate pricing on white days</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="bbrhcjwType">
<item-type>Number:Energy</item-type>
<label>BBRHCJW</label>
<description>Total consumed energy at low rate pricing on white days</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="bbrhpjbType">
<item-type>Number:Energy</item-type>
<label>BBRHPJB</label>
<description>Total consumed energy at high rate pricing on blue days</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="bbrhcjbType">
<item-type>Number:Energy</item-type>
<label>BBRHCJB</label>
<description>Total consumed energy at low rate pricing on blue days</description>
<category>Energy</category>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="couleurDemainType">
<item-type>String</item-type>
<label>DEMAIN</label>
<description>Following day color</description>
<category>Energy</category>
<state pattern="%s" readOnly="true">
<options>
<option value="Bleu">Bleu</option>
<option value="Blanc">Blanc</option>
<option value="Rouge">Rouge</option>
</options>
</state>
</channel-type>
<channel-type id="programmeCircuit1Type">
<item-type>String</item-type>
<label>ProgrammeCircuit1</label>
<description>Circuit 1 program</description>
<category>Energy</category>
<state pattern="%s" readOnly="true">
<options>
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</options>
</state>
</channel-type>
<channel-type id="programmeCircuit2Type">
<item-type>String</item-type>
<label>ProgrammeCircuit2</label>
<description>Circuit 2 program</description>
<category>Energy</category>
<state pattern="%s" readOnly="true">
<options>
<option value="P0">P0</option>
<option value="P1">P1</option>
<option value="P2">P2</option>
<option value="P3">P3</option>
<option value="P4">P4</option>
<option value="P5">P5</option>
<option value="P6">P6</option>
<option value="P7">P7</option>
</options>
</state>
</channel-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="teleinfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<bridge-type id="serialcontroller">
<label>Teleinfo Serial Controller</label>
<description>Teleinfo USB Stick with Serial Interface</description>
<channels>
<channel id="invalidFrameCounter" typeId="invalidFrameCounterType"/>
</channels>
<config-description>
<parameter name="serialport" type="text" required="true">
<label>Serial Port</label>
<context>serial-port</context>
<description>Serial port of Teleinfo device (e.g.: /dev/ttyUSB0 on Linux, COM1 on Windows)</description>
<limitToOptions>false</limitToOptions>
</parameter>
<parameter name="autoRepairInvalidADPSgroupLine" type="boolean" required="false">
<label>Auto Repair Malformed ADPS Data</label>
<description>Try to auto repair malformed ADPS data from hardware issues (e.g: "ADPS032" instead of "ADPS 032"
expected/well-formed data)</description>
<default>true</default>
<advanced>true</advanced>
</parameter>
</config-description>
</bridge-type>
<channel-type id="invalidFrameCounterType">
<item-type>Number</item-type>
<label>Frames Corrupted</label>
<description>Counter tracking the number of frames invalid/corrupted (checksum)</description>
<category></category>
<state pattern="%d" readOnly="true"></state>
</channel-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,173 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.internal.reader.io;
import java.io.FileInputStream;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Assert;
import org.junit.Test;
import org.openhab.binding.teleinfo.internal.dto.Frame;
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccBaseOption;
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccHcOption;
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccTempoOption;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongBaseOption;
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongEjpOption;
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption.ProgrammeCircuit1;
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption.ProgrammeCircuit2;
import org.openhab.binding.teleinfo.internal.dto.common.Hhphc;
import org.openhab.binding.teleinfo.internal.dto.common.Ptec;
import org.openhab.binding.teleinfo.util.TestUtils;
/**
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public class TeleinfoInputStreamTest {
@Test
public void testReadNextFrameCbetmBase1() throws Exception {
try (TeleinfoInputStream in = new TeleinfoInputStream(
new FileInputStream(TestUtils.getTestFile("cbetm-base-option-1.raw")))) {
Frame frame = in.readNextFrame();
Assert.assertNotNull(frame);
Assert.assertEquals(FrameCbetmLongBaseOption.class, frame.getClass());
FrameCbetmLongBaseOption frameCbetmLongBaseOption = (FrameCbetmLongBaseOption) frame;
Assert.assertEquals("XXXXXXXXXXXX", frameCbetmLongBaseOption.getAdco());
Assert.assertEquals(20, frameCbetmLongBaseOption.getIsousc());
Assert.assertEquals(1181243, frameCbetmLongBaseOption.getBase());
Assert.assertEquals(Ptec.TH, frameCbetmLongBaseOption.getPtec());
Assert.assertEquals(0, frameCbetmLongBaseOption.getIinst1());
Assert.assertEquals(2, frameCbetmLongBaseOption.getIinst2());
Assert.assertEquals(0, frameCbetmLongBaseOption.getIinst3());
Assert.assertEquals(26, frameCbetmLongBaseOption.getImax1().intValue());
Assert.assertEquals(18, frameCbetmLongBaseOption.getImax2().intValue());
Assert.assertEquals(27, frameCbetmLongBaseOption.getImax3().intValue());
Assert.assertEquals(7990, frameCbetmLongBaseOption.getPmax());
Assert.assertEquals(540, frameCbetmLongBaseOption.getPapp());
Assert.assertEquals("00", frameCbetmLongBaseOption.getPpot());
}
}
@Test
public void testReadNextFrameCbemmEvoIccHc1() throws Exception {
try (TeleinfoInputStream in = new TeleinfoInputStream(
new FileInputStream(TestUtils.getTestFile("cbemm-evo-icc-hc-option-1.raw")))) {
Frame frame = in.readNextFrame();
Assert.assertNotNull(frame);
Assert.assertEquals(FrameCbemmEvolutionIccHcOption.class, frame.getClass());
FrameCbemmEvolutionIccHcOption frameCbemmEvolutionIccHcOption = (FrameCbemmEvolutionIccHcOption) frame;
Assert.assertEquals("XXXXXXXXXXXX", frameCbemmEvolutionIccHcOption.getAdco());
Assert.assertEquals(30, frameCbemmEvolutionIccHcOption.getIsousc());
Assert.assertEquals(6906827, frameCbemmEvolutionIccHcOption.getHchc());
Assert.assertEquals(7617931, frameCbemmEvolutionIccHcOption.getHchp());
Assert.assertEquals(Ptec.HP, frameCbemmEvolutionIccHcOption.getPtec());
Assert.assertEquals(3, frameCbemmEvolutionIccHcOption.getIinst());
Assert.assertEquals(44, frameCbemmEvolutionIccHcOption.getImax().intValue());
Assert.assertEquals(680, frameCbemmEvolutionIccHcOption.getPapp());
Assert.assertNull(frameCbemmEvolutionIccHcOption.getAdps());
Assert.assertEquals(Hhphc.A, frameCbemmEvolutionIccHcOption.getHhphc());
}
}
@Test
public void testReadNextFrameCbetmEjp1() throws Exception {
try (TeleinfoInputStream in = new TeleinfoInputStream(
new FileInputStream(TestUtils.getTestFile("cbetm-ejp-option-1.raw")))) {
Frame frame = in.readNextFrame();
Assert.assertNotNull(frame);
Assert.assertEquals(FrameCbetmLongEjpOption.class, frame.getClass());
FrameCbetmLongEjpOption frameCbetmLongEjpOption = (FrameCbetmLongEjpOption) frame;
Assert.assertEquals("XXXXXXXXXX", frameCbetmLongEjpOption.getAdco());
Assert.assertEquals(30, frameCbetmLongEjpOption.getIsousc());
Assert.assertEquals(1111111, frameCbetmLongEjpOption.getEjphn());
Assert.assertEquals(2222222, frameCbetmLongEjpOption.getEjphpm());
Assert.assertNull(frameCbetmLongEjpOption.getPejp());
Assert.assertEquals(Ptec.HN, frameCbetmLongEjpOption.getPtec());
Assert.assertEquals(10, frameCbetmLongEjpOption.getIinst1());
Assert.assertEquals(5, frameCbetmLongEjpOption.getIinst2());
Assert.assertEquals(8, frameCbetmLongEjpOption.getIinst3());
Assert.assertEquals(38, frameCbetmLongEjpOption.getImax1().intValue());
Assert.assertEquals(42, frameCbetmLongEjpOption.getImax2().intValue());
Assert.assertEquals(44, frameCbetmLongEjpOption.getImax3().intValue());
Assert.assertEquals(17480, frameCbetmLongEjpOption.getPmax());
Assert.assertEquals(5800, frameCbetmLongEjpOption.getPapp());
Assert.assertEquals("00", frameCbetmLongEjpOption.getPpot());
}
}
@Test
public void testReadNextFrameCbemmEvoIccTempo1() throws Exception {
try (TeleinfoInputStream in = new TeleinfoInputStream(
new FileInputStream(TestUtils.getTestFile("cbemm-evo-icc-tempo-option-1.raw")))) {
Frame frame = in.readNextFrame();
Assert.assertNotNull(frame);
Assert.assertEquals(FrameCbemmEvolutionIccTempoOption.class, frame.getClass());
FrameCbemmEvolutionIccTempoOption frameCbemmEvolutionIccTempoOption = (FrameCbemmEvolutionIccTempoOption) frame;
Assert.assertEquals("XXXXXXXXXXXX", frameCbemmEvolutionIccTempoOption.getAdco());
Assert.assertEquals(45, frameCbemmEvolutionIccTempoOption.getIsousc());
Assert.assertEquals(2697099, frameCbemmEvolutionIccTempoOption.getBbrhcjb());
Assert.assertEquals(3494559, frameCbemmEvolutionIccTempoOption.getBbrhpjb());
Assert.assertEquals(41241, frameCbemmEvolutionIccTempoOption.getBbrhcjw());
Assert.assertEquals(194168, frameCbemmEvolutionIccTempoOption.getBbrhpjw());
Assert.assertEquals(0, frameCbemmEvolutionIccTempoOption.getBbrhcjr());
Assert.assertEquals(89736, frameCbemmEvolutionIccTempoOption.getBbrhpjr());
Assert.assertEquals(Ptec.HPJR, frameCbemmEvolutionIccTempoOption.getPtec());
Assert.assertNull(frameCbemmEvolutionIccTempoOption.getDemain());
Assert.assertEquals(3, frameCbemmEvolutionIccTempoOption.getIinst());
Assert.assertEquals(37, frameCbemmEvolutionIccTempoOption.getImax().intValue());
Assert.assertEquals(620, frameCbemmEvolutionIccTempoOption.getPapp());
Assert.assertNull(frameCbemmEvolutionIccTempoOption.getAdps());
Assert.assertEquals(Hhphc.Y, frameCbemmEvolutionIccTempoOption.getHhphc());
Assert.assertEquals(ProgrammeCircuit1.B, frameCbemmEvolutionIccTempoOption.getProgrammeCircuit1());
Assert.assertEquals(ProgrammeCircuit2.P2, frameCbemmEvolutionIccTempoOption.getProgrammeCircuit2());
}
}
@Test
public void testReadNextFrameCbemmEvoIccBase1() throws Exception {
try (TeleinfoInputStream in = new TeleinfoInputStream(
new FileInputStream(TestUtils.getTestFile("cbemm-evo-icc-base-option-1.raw")))) {
Frame frame = in.readNextFrame();
Assert.assertNotNull(frame);
Assert.assertEquals(FrameCbemmEvolutionIccBaseOption.class, frame.getClass());
FrameCbemmEvolutionIccBaseOption frameCbemmEvolutionIccBaseOption = (FrameCbemmEvolutionIccBaseOption) frame;
Assert.assertEquals("031762120162", frameCbemmEvolutionIccBaseOption.getAdco());
Assert.assertEquals(30, frameCbemmEvolutionIccBaseOption.getIsousc());
Assert.assertEquals(190575, frameCbemmEvolutionIccBaseOption.getBase());
Assert.assertEquals(Ptec.TH, frameCbemmEvolutionIccBaseOption.getPtec());
Assert.assertEquals(1, frameCbemmEvolutionIccBaseOption.getIinst());
Assert.assertEquals(90, frameCbemmEvolutionIccBaseOption.getImax().intValue());
Assert.assertEquals(270, frameCbemmEvolutionIccBaseOption.getPapp());
Assert.assertNull(frameCbemmEvolutionIccBaseOption.getAdps());
}
}
@Test
public void testInvalidADPSgrouplineWithAutoRepairActivated() throws Exception {
try (TeleinfoInputStream in = new TeleinfoInputStream(
new FileInputStream(TestUtils.getTestFile("invalid-adps-groupline.raw")), true)) {
Frame frame = in.readNextFrame();
Assert.assertNotNull(frame);
Assert.assertEquals(FrameCbemmEvolutionIccBaseOption.class, frame.getClass());
FrameCbemmEvolutionIccBaseOption frameCbemmEvolutionIccBaseOption = (FrameCbemmEvolutionIccBaseOption) frame;
Assert.assertEquals(37, frameCbemmEvolutionIccBaseOption.getAdps().intValue());
}
}
}

View File

@@ -0,0 +1,40 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.teleinfo.util;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
*
* @author Nicolas SIBERIL - Initial contribution
*/
@NonNullByDefault
public final class TestUtils {
private TestUtils() {
// private constructor
}
public static File getTestFile(String testResourceName) {
URL url = TestUtils.class.getClassLoader().getResource(testResourceName);
try {
return new File(url.toURI());
} catch (URISyntaxException e) {
throw new IllegalStateException(e);
}
}
}

Some files were not shown because too many files have changed in this diff Show More