New Teleinfo Binding - Tester and Feedback welcome

Hi @ysc,
Thank you for your feedback !

Can you add an issue in my GitHub please ?
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 :
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 = ''
$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 =$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)
        c.publish("homie/#{$homie_device}/#{$homie_node}/#{k.to_s}", f.to_hash[k], true)

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

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:

Hi all, @pakutz79, @srsr, @ysc,
Here is the new release (Beta 20191029-2235) :
This release try to fix binding crashs on random I/O errors (see and invalid/corrupted frame errors.

Any feedback will be welcome !

Hi @nokyyz
Thanks for your work !
I use your binding on openhab 2.5.0.M3 on docker with the previous (Alpha 20191015-1958) version. My teleinfo hardware is a Cartelectronic like @ysc. It works well but I noticed several issues/enhancements:

  • Same issue than @ysc [ERROR] [nternal.serial.TeleinfoReceiveThread] - Got invalid frame The groupLine seems corrupted (integrity not checked) during receiving. exiting thread.. I will try the new beta version next week.
  • Rules auto updating seems to be broken when using your binding: need a restart of my docker image to take into account modifications in my .rules files.
  • Could this binding directly support a ser2net device? For example with a device address like ip:port instead of /dev/ttyXXX. With that my docker image could be independent of the harware where he is running. Enocean binding seems to already support this.

Thanks @hollysaiqs for your feedback !

Yes, the beta-20191029-2235 version should fix this issue :slight_smile:

I’m using OpenHAB 2.5.0-M1 on Docker (‘openhab/openhab:2.5.0.M1-amd64-debian’ image). I will check it in the next few days. I am very surprised that this problem is due to my teleinfo binding…

I think OpenHAB supports the rfc2217 feature natively. If you want to try/test, I can update the binding configuration to replace Serial port dropdown list to a simple text field.
Ok ?

For my information, can you give me some details about your electricty meter ? single-phase or tree-phase ? your pricing option (Base, HC, Tempo, EJP) ?


Hi @nokyyz,

My electricity meter is single phased and my pricing option is HC.
A text field instead of dropdown list would be great!
No time to test the new version for the moment…

Hi all, @pakutz79, @srsr, @ysc, @hollysaiqs
Here is the new release (Beta 20191104-2035) :
Release note:

Any feedback will be welcome !

1 Like

Hi @nokyyz,
I am testing the new release and I am trying to have a working rfc2217 configuration. I receive this error:

[rial.TeleinfoSerialControllerHandler] - An error occurred during serial port connection. Detail: ""
	at ~[?:?]
	at org.openhab.binding.teleinfo.internal.serial.TeleinfoSerialControllerHandler.openSerialPortAndStartReceiving( [243:org.openhab.binding.teleinfo:]
	at org.openhab.binding.teleinfo.internal.serial.TeleinfoSerialControllerHandler.access$5( [243:org.openhab.binding.teleinfo:]
	at org.openhab.binding.teleinfo.internal.serial.TeleinfoSerialControllerHandler$ [243:org.openhab.binding.teleinfo:]
	at java.util.TimerThread.mainLoop( [?:?]
	at [?:?]
Caused by:
	at ~[?:?]
	at ~[?:?]
	... 5 more

Here is my ser2net.conf:
5001:telnet:0:/dev/ttyUSB0:1200 7DATABITS EVEN 1STOPBIT remctl

Where is my mistake?
Do I need to add something to my docker image configuration?

Hi @hollysaiqs,
I could not test the RFC2217 feature… After some searchs on this forum, have you try with RAW option instead of Telnet ? E.g:
5001:telnet:0:/dev/ttyUSB0:1200 7DATABITS EVEN 1STOPBIT remctl
5001:raw:0:/dev/ttyUSB0:1200 7DATABITS EVEN 1STOPBIT remctl

Hi @nokyyz,
With raw option, I receive this error:

[ERROR] [rial.TeleinfoSerialControllerHandler] - An error occurred during serial port connection. Detail: ""
	at ~[?:?]
	at org.openhab.binding.teleinfo.internal.serial.TeleinfoSerialControllerHandler.openSerialPortAndStartReceiving( [243:org.openhab.binding.teleinfo:]
	at org.openhab.binding.teleinfo.internal.serial.TeleinfoSerialControllerHandler.initialize( [243:org.openhab.binding.teleinfo:]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke( ~[?:?]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke( ~[?:?]
	at java.lang.reflect.Method.invoke( ~[?:?]
	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect( [133:org.openhab.core:2.5.0.M3]
	at [133:org.openhab.core:2.5.0.M3]
	at [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker( [?:?]
	at java.util.concurrent.ThreadPoolExecutor$ [?:?]
	at [?:?]
Caused by:
	at ~[?:?]
	at ~[?:?]
	... 12 more

During my searchs I didn’t see anyone who succeeds in making rfc2217 works… Everybody seems to use socat instead. Does rfc2217 actually work on openhab?

No idea :sweat_smile:
And what is the result with socat command ?

I have a working socat configuration in my openhab docker image. I have to manually launch the socat command inside the docker:

socat pty,link=/dev/ttyUSB21 tcp:,reuseaddr,keepalive,connect-timeout=5,keepcnt=5,keepidle=5,keepintvl=5

It seems to work because I can see teleinfo data when I launch cat /dev/ttyUSB21
Now openhab send me this error:

[ERROR] [rial.TeleinfoSerialControllerHandler] - No port identifier for '/dev/ttyUSB21'

Any idea?

It works :grinning: with socat command

socat pty,link=/dev/ttyUSB21,raw,user=openhab,group=dialout,mode=777 tcp:,reuseaddr,keepalive,connect-timeout=5,keepcnt=5,keepidle=5,keepintvl=5
1 Like

Good job @hollysaiqs !

In this case, what is the value of Serial port parameter in Teleinfo Serial Configuration configuration ?

Thanks @nokyyz,
The value of Serial Port is /dev/ttyUSB21 (socat emulates an USB hardware). No need to have rfc2217 with socat, sorry for asking a functionality which was finally useless (for me).
I am currently trying to automate socat launching when running the docker image.

Is there any chance this binding will be official in openhab 2.5.0? Release seems to be close…

It remains to write the documentation (i’m struggling :neutral_face:), to merge/synchronize with the last source code of official openhab-addons github and then create a pull request :sweat:

So, what is the command line to broadcast your Teleinfo serial port on TCP/IP ? I think it would be interesting to specify it in the binding documentation…