New Teleinfo Binding - Tester and Feedback welcome

Hi,
I started the development of a new binding for Teleinfo support in OpenHAB.
Teleinfo is a protocol for French electricity meters provided by ENEDIS/ERDF. Teleinfo give you in real time many metrics from an electricity meter: id of electricity meter (ADCO), index of HCHC, index of HPHC, instantaneous intensity (IINST), Subscribed intensity (ISOUSC), etc.

The binding Teleinfo will make it possible:

  • to monitor the current consumption of your house,
  • to trigger scenarios according to the consumption, current pricing period (HC/HP)
  • to estimated costs of electricity consumption

The first version will be based on OpenHAB 2.5.x.

Development status:
Alpha release
an alpha version is planned in 1/2 week for testing. This version will support the Teleinfo of HCHP electricity meters (Base, Tempo and EJP mode can be developed later).
The binding will decode the teleinfo frames from a serial port (e.g: /dev/ttyXX, COMx).
Nota: to read Teleinfo from electricity meter (Actaris A14C5 model), I use the following USB module: GCE Electronics USB Teleinfo module.

I will need to help test the binding and discuss its current or future features.
Any help will be welcome ! :grinning:

1 Like

Hi,
Here is the Alpha release: https://github.com/nokyyz/openhab2-addons/releases/tag/Teleinfo-binding-version-alpha-20190716-1440

Any feedback will be appreciate !

Hello Nokyys,
I have some good results with an executable writen in C code for my Raspberry.
Here is my approach :

  • use C program to endless write serial values in a ramfile for preserving sd card
  • use Openhab to read file and display value ( and in the future to send heaters desirate state to a ramfile read by maybe the same C program )

I use this approach because my final goal is to manage heaters over-current consumption to prevent electricity cut. ( always with a C program )
Maybee I 'm wrong but I was thinked that OpenHab on Pi was too slow for manage this, ( but enought for display electricity ERDF values, and send heater comfort/economy/off desirate state commands ).
Now it’s difficulty to establish rules to enter and exit délestage mode ( reaction time? when stop a delestage state? How long a heater should stay off before stopping another one … )
It’s hard to find data on the web to tune it. Did you plan to think about this?
See you soon!

Hi @srsr,
I wrote the Teleinfo binding especially to manage my (electrical) heaters and consumption :slight_smile: All my heaters have an “pilote” wire and each “pilote” wire is connected to an Zwave Qubino ZMNHJA2. The Teleinfo binding provides some real-time metrics (ADPS, IINST) that can be used to trigger an “délestage” mode. With an OpenHAB rule, you can switch OFF some heaters (thanks to Qubino ZMNHJA2) when a ADPS or IINST value is reached and prevent to electrical cut. E.g:

rule "DĂ©lestage des radiateurs"
when 
     Item CompteurElectrique_ADPS changed from NULL
then
     sendCommand(ChauffageZone1Dimmer, modeArretDelestage)
end

Hello Nokyys,
Did you always plan to stop the same heater first when a overcomsumption is reach? How do you manage the exit of a delestage state?
I think the best way is to exit delestage state only when an IINST value is enought low, not when ADPS became OFF.
otherwise, it will be a good thing to not switch off a heater more than a few minutes to keep temperature room, maybee less than 5 minutes?
I actually have an old Delta Dore unit, it use 3 groups of heaters for delestage, and on delestage state it stop one group at a time for few minutes, and switch off the next group after etc…
I don’t have tested yet your binding. Do you think it will be compatible with serial on GPIO port?

I think so

Hi,
i have installed the binding… first i had some problems with the serial port

Error while starting bundle: file:/usr/share/openhab2/addons/teleinfo-2.5.0.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.teleinfo [232]
Unresolved requirement: Import-Package: org.eclipse.smarthome.io.transport.serial

i have installed the binding-serial1 - 1.13.0 now the teleinfo-binding ist online :grinning:

Where can i find the channels for this binding?

UPDATE:
I think i’ve found one problem, i have a threephase energy-meter. In TRACE-Mode i can see that the binding stops when reading groupLine = IINST1 002 J

Hi @pakutz79,
This Alpha-20190716 version has been tested on a “mono-phase” HCHP electricity meter.
If you want, I can try to implement the “tri-phase” teleinfo protocol :slight_smile: To implement and test this new feature, I have need a dump file of your teleinfo. Is it possible for you ?

Hi nokyyz,
i created an issue in github…

you can find the informations in ERDF-NOI-CPT_02E.pdf on page 19

The following objects are transmitted in the teleinfo frame:

ADCO 049501170122 7
OPTARIF BASE 0
ISOUSC 20 8
BASE 000009985 *
PTEC HC… S
IINST1 001 I
IINST2 000 I
IINST3 001 K
IINST 000 W
IMAX1 006 6
IMAX2 016 8
IMAX3 015 8
PMAX 05710 3
PAPP 00280 +
HHPHC E 0
MOTDETAT 000000 B
PPOT 00

I have already looked at the code of the teleinfo binding, but I’m not really familiar with the structure of Bindings yet.

Hi @pakutz79,
I have read the specification for Triphase electricity meter, but for the moment, I’m blocked by the OpenHAB development environment with Eclipse IDE. I have reinstall Eclipse IDE following the official documentation (https://www.openhab.org/docs/developer/ide/eclipse.html) but no binding are available in Browse Repo list of app.bndrun file :frowning:

Hi all, @pakutz79, @srsr,
I have finished a full refactoring of Teleinfo binding to support the Three-phased electricity meters !

Here is the new release (Alpha 20191015-1958): https://github.com/nokyyz/openhab2-addons/releases/tag/alpha-20191015-1958
This version has been designed to support the following features:

  • Single-phased electricity meters with BASE, HC, TEMPO or EJP option (CBEMM and CBEMM Evolution ICC)
  • Three-phased electricity meters with BASE, HC, TEMPO or EJP option (CBETM)

Any feedback will be welcome !

2 Likes

Thank you, i will try it out this weekend.

1 Like

Thanks for this @nokyyz!

I tried the latest release (https://github.com/nokyyz/openhab2-addons/releases/tag/alpha-20191015-1958) with this module:

Amazon link:

I didn’t have much trouble adding the Things with Paper UI, I added the serial controller and then it discovered my meter as a Single-phase Electricity meter with BASE option - CBEMM Evolution ICC (aka “Compteur Bleu Electronique Monophasé Multitarif Evolution ICC”)

It seems to work very well so far, but I ran into checksum errors twice:

12:28:37.716 [TRACE] [nternal.reader.io.TeleinfoInputStream] - groupLine = I�X 090 H
12:28:37.722 [TRACE] [nternal.reader.io.TeleinfoInputStream] - computedChecksum = 7
12:28:37.725 [TRACE] [nternal.reader.io.TeleinfoInputStream] - checksum = H
12:28:37.729 [ERROR] [internal.serial.TeleinfoReceiveThread] - Got invalid frame The groupLine seems corrupted (integrity not checked) during receiving. exiting thread.

And in that case the binding simply stops working :frowning:

By the way, it’s unrelated to your work, but I have a long-standing problem with serial bindings eating up the CPU, I haven’t been able to figure out a solution and it’s almost a showstopper to using any serial binding with openHAB Edit: disregard this, it seems to work better after a while.
:

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
 7005 openhab   20   0 4452556 385108  20440 S 103.3  18.8  21:00.41 java

openhab> threads --list
...
182 │ Thread-61    ...    │ RUNNABLE      │ 665716   │ 165230
...
openhab> threads 182
Thread 182 Thread-61 RUNNABLE
Stacktrace:
gnu.io.RXTXPort.eventLoop line: -2
gnu.io.RXTXPort$MonitorThread.run line: 1611

Wondering if others have this problem too.

Nonetheless, great work, I look forward to having this binding added in the distribution!

I have had another random issue last night which caused the data collection to stop. Restarting the bundle solved it (and cause the CPU to jump to 100% again).

2019-10-24 05:41:56.945 [ERROR] [nternal.serial.TeleinfoReceiveThread] - Got I/O exception Underlying input stream returned zero bytes during receiving. exiting thread.

It seems to happen every few hours in my case. Maybe some reconnection logic when an error happens could be a good idea?

Hi @ysc,
Thank you for your feedback !

Can you add an issue in my GitHub please ? https://github.com/nokyyz/openhab2-addons/issues
I’m implementing a Retry mechanism to prevent this invalid data. The teleinfo reading will be suspend during 1 minute and resume after this pause. After 5 unsuccess retries, the binding will stop the reading definitively.
What do you think about that ?

I have some times a similar issue but for the moment I cannot find the steps to reproduce. For my part, this error throws on Enedis HC/HP switch. I have created an issue on GitHub to try to solve it : https://github.com/nokyyz/openhab2-addons/issues/7
Can we continue the discussion in this Github issue?

1 Like

Sounds good, not even sure the 1-minute suspend and abandon after 5 retries is not necessary but it can’t hurt :slight_smile:

You are right :slight_smile: In the “corrupted frames” case, the binding will go to the next frame without pause. The suspend and retry mechanism is mostly for timeout and I/O errors.
I think that this fix will be implemented shortly. After some tests, I will post a new version in this thread.
See you soon

I’m sharing the Ruby script I wrote today in the meantime. To be perfectly clear - I still would like a Téléinfo binding in openHAB, of course :slight_smile: , but since in my case the data is not collected on my main instance, I have to transmit it somehow, hence the MQTT-based solution: this script will expose the meter as a Homie MQTT device. You need the mqtt and teleinfo gems installed (sudo gem install mqtt, sudo gem install teleinfo).
If you decide to use it, alter the variables at the beginning of the script to your needs, including the Téléinfo properties you want from your meter (different models provide different properties, you have to familiarize yourself with those first).

#!/usr/bin/env ruby

require 'teleinfo'
require 'mqtt'

$device = '/dev/ttyUSB0'
$broker_host = '192.168.1.141'
$homie_device = 'linky'
$homie_node = 'teleinfo'
$homie_type = 'PowerMeter'
$homie_name = 'Linky'
$teleinfo_properties = {
  :base => { :name => 'Base Tariff Energy', :unit => 'kWh', :type => 'integer', :kilo => true },
  :papp => { :name => 'Apparent Power', :unit => 'VA', :type => 'integer' },
  :iinst => { :name => 'Instantaneous Intensity', :unit => 'A', :type => 'integer' }
}

MQTT::Client.connect($broker_host) do |c|
  # Publish device descriptions
  c.publish("homie/#{$homie_device}/$homie", "4.0.0", true)
  c.publish("homie/#{$homie_device}/$name", $homie_name, true)
  c.publish("homie/#{$homie_device}/$state", "ready", true)
  c.publish("homie/#{$homie_device}/$nodes", $homie_node, true)
  c.publish("homie/#{$homie_device}/$extensions", "", true)

  c.publish("homie/#{$homie_device}/#{$homie_node}/$name", $homie_name, true)
  c.publish("homie/#{$homie_device}/#{$homie_node}/$type", $homie_type, true)
  c.publish("homie/#{$homie_device}/#{$homie_node}/$properties", $teleinfo_properties.keys.join(','), true)
  $teleinfo_properties.each { |k,v|
    c.publish("homie/#{$homie_device}/#{$homie_node}/#{k.to_s}/$name", v[:name], true)
    c.publish("homie/#{$homie_device}/#{$homie_node}/#{k.to_s}/$datatype", v[:type], true)
    c.publish("homie/#{$homie_device}/#{$homie_node}/#{k.to_s}/$unit", v[:unit], true)
  }

  teleinfo = Teleinfo::Parser.new(File.open($device, 'r'))
  teleinfo.each { |f|
    puts f.to_json
    $teleinfo_properties.each { |k,v|
      if v[:kilo] then
        c.publish("homie/#{$homie_device}/#{$homie_node}/#{k.to_s}", f.to_hash[k] / 1000.0, true)
      else
        c.publish("homie/#{$homie_device}/#{$homie_node}/#{k.to_s}", f.to_hash[k], true)
      end
    }

    #c.publish('linky/teleinfo', f.to_json)
  }
end

My OpenHAB server is close to my electricity meter :slight_smile:

To simplify your architecture, have you try the Serial port over IP method ?
Some links: