Teleinfo : new platform

Hi,
i try to create a new platform for the EDF Teleinfo frames sent by an electrical meter.

I’m using HomeAssistant using the Virtualenv setup on a Raspberry PI Zero W.
So i create a file “teleinfo.py” in directory $HOME/.homeassistant/custom_components/sensor.

On the configuration file, i add the sensor like that :

$ cat sensors/teleinfo.yaml
- platform: teleinfo
  device: "/dev/ttyUSB0"

An the main configuration :

$ grep sensor configuration.yaml
sensor: !include_dir_merge_list sensors
binary_sensor: !include_dir_merge_list binary_sensor

I launch HA using systemd:

$ cat /etc/systemd/system/[email protected]
[Unit]
Description=Home Assistant
After=network.target

[Service]
Type=simple
User=pirate
ExecStart=/home/pirate/bin/ha.sh

[Install]
WantedBy=multi-user.target

$ cat /home/pirate/bin/ha.sh
#!/bin/bash

. /home/pirate/Projets/home-assistant-configuration/venv/bin/activate && \
        cd /home/pirate/Projets/home-assistant-configuration && \
        python3 -m homeassistant --config /home/pirate/Projets/home-assistant-configuration/

When i start HA, i’ve got this error :

2017-10-15 10:59:13 INFO (MainThread) [homeassistant.setup] Setting up sensor
2017-10-15 10:59:13 ERROR (MainThread) [homeassistant.setup] Error during setup of component sensor
Traceback (most recent call last):
  File "/home/pirate/Projets/home-assistant-configuration/venv/lib/python3.4/site-packages/homeassistant/setup.py", line 194, in _async_setup_component
    component.setup, hass, processed_config)
AttributeError: 'module' object has no attribute 'setup'

The code : https://gist.github.com/nlamirault/5ed4859572373d043e67b9950ddb733a
does anyone see the problem?

I try a custom component :

I configure it using :

sensor: !include_dir_merge_list sensors

and in sensors/teleinfo.yaml file :

- platform: teleinfo
  name: "edf"
  device: "/dev/ttyUSB0"

HA logs :

oct. 23 14:58:48 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:48,029 [18925] INFO     custom_components.sensor.teleinfo: Read teleinfo informations                                                          [2/1980]
oct. 23 14:58:48 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:48,270 [18925] INFO     kylin: Port: /dev/ttyUSB0 - FT230X Basic UART
oct. 23 14:58:48 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:48,310 [18925] INFO     kylin: Open serial port: /dev/ttyUSB0 with timeout 2
oct. 23 14:58:48 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:48,376 [18925] INFO     kylin: Line:
oct. 23 14:58:48 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:48,611 [18925] INFO     kylin: New frame
oct. 23 14:58:48 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:48,707 [18925] INFO     kylin: Line: ADCO 050122094329 <
oct. 23 14:58:48 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:48,781 [18925] INFO     kylin: Line: OPTARIF HC.. <
oct. 23 14:58:48 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:48,839 [18925] INFO     kylin: Line: ISOUSC 30 9
oct. 23 14:58:48 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:48,905 [18925] INFO     kylin: Line: HCHC 027997526 5
oct. 23 14:58:48 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:48,963 [18925] INFO     kylin: Line: HCHP 050378195 9
oct. 23 14:58:49 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:49,014 [18925] INFO     kylin: Line: PTEC HC.. S
oct. 23 14:58:49 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:49,059 [18925] INFO     kylin: Line: IINST 001 X
oct. 23 14:58:49 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:49,133 [18925] INFO     kylin: Line: IMAX 032 D
oct. 23 14:58:49 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:49,280 [18925] INFO     kylin: Line: PAPP 00230 &
oct. 23 14:58:49 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:49,429 [18925] INFO     kylin: Line: HHPHC A ,
oct. 23 14:58:49 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:49,721 [18925] INFO     kylin: Frame: [{'checksum': '<', 'value': '050122094329', 'name': 'ADCO'}, {'checksum': '<', 'value': 'HC..', 'name': 'OPTARIF'
}, {'checksum': '9', 'value': '30', 'name': 'ISOUSC'}, {'checksum': '5', 'value': '027997526', 'name': 'HCHC'}, {'checksum': '9', 'value': '050378195', 'name': 'HCHP'}, {'checksum': 'S', 'value': 'HC..', 'name': 
'PTEC'}, {'checksum': 'X', 'value': '001', 'name': 'IINST'}, {'checksum': 'D', 'value': '032', 'name': 'IMAX'}, {'checksum': '&', 'value': '00230', 'name': 'PAPP'}, {'checksum': ',', 'value': 'A', 'name': 'HHPHC'
}]
oct. 23 14:58:49 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:49,827 [18925] WARNING  custom_components.sensor.teleinfo: =====> [{'checksum': '<', 'value': '050122094329', 'name': 'ADCO'}, {'checksum': '<', 'value
': 'HC..', 'name': 'OPTARIF'}, {'checksum': '9', 'value': '30', 'name': 'ISOUSC'}, {'checksum': '5', 'value': '027997526', 'name': 'HCHC'}, {'checksum': '9', 'value': '050378195', 'name': 'HCHP'}, {'checksum': 'S
', 'value': 'HC..', 'name': 'PTEC'}, {'checksum': 'X', 'value': '001', 'name': 'IINST'}, {'checksum': 'D', 'value': '032', 'name': 'IMAX'}, {'checksum': '&', 'value': '00230', 'name': 'PAPP'}, {'checksum': ',', '
value': 'A', 'name': 'HHPHC'}]
oct. 23 14:58:49 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:49,915 [18925] INFO     custom_components.sensor.teleinfo: Teleinfo data: {'checksum': '<', 'value': '050122094329', 'name': 'ADCO'}
oct. 23 14:58:50 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:49,990 [18925] INFO     custom_components.sensor.teleinfo: Teleinfo data: {'checksum': '<', 'value': 'HC..', 'name': 'OPTARIF'}
oct. 23 14:58:50 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:50,066 [18925] INFO     custom_components.sensor.teleinfo: Teleinfo data: {'checksum': '9', 'value': '30', 'name': 'ISOUSC'}
oct. 23 14:58:50 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:50,098 [18925] INFO     custom_components.sensor.teleinfo: Teleinfo data: {'checksum': '5', 'value': '027997526', 'name': 'HCHC'}
oct. 23 14:58:50 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:50,161 [18925] INFO     custom_components.sensor.teleinfo: Teleinfo data: {'checksum': '9', 'value': '050378195', 'name': 'HCHP'}
oct. 23 14:58:50 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:50,224 [18925] INFO     custom_components.sensor.teleinfo: Teleinfo data: {'checksum': 'S', 'value': 'HC..', 'name': 'PTEC'}
oct. 23 14:58:50 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:50,282 [18925] INFO     custom_components.sensor.teleinfo: Teleinfo data: {'checksum': 'X', 'value': '001', 'name': 'IINST'}
oct. 23 14:58:50 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:50,356 [18925] INFO     custom_components.sensor.teleinfo: Teleinfo data: {'checksum': 'D', 'value': '032', 'name': 'IMAX'}
oct. 23 14:58:50 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:50,393 [18925] INFO     custom_components.sensor.teleinfo: Teleinfo data: {'checksum': '&', 'value': '00230', 'name': 'PAPP'}
oct. 23 14:58:50 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:50,431 [18925] INFO     custom_components.sensor.teleinfo: Teleinfo data: {'checksum': ',', 'value': 'A', 'name': 'HHPHC'}
oct. 23 14:58:50 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:50,451 [18925] INFO     custom_components.sensor.teleinfo: Teleinfo frame: on {'ISOUSC': '30', 'OPTARIF': 'HC..', 'HCHC': '027997526', 'PAPP': '00230',
 'ADCO': '050122094329', 'IMAX': '032', 'HCHP': '050378195', 'PTEC': 'HC..', 'HHPHC': 'A', 'IINST': '001'}
oct. 23 14:58:50 jarvis-zero1 ha.sh[18916]: 2017-10-23 14:58:50,511 [18925] WARNING  custom_components.sensor.teleinfo: sensor.edf

But i have non sensor.edf on the UI, and according to the API :

$ curl -H "Content-Type: application/json" http://192.168.1.32:8123/api/states/sensor.edf
{"message": "Entity not found"}

How can i debug that ? Any idea ?
Thanks

Hello,
I’m also interested on this component but it seems that it’s not yet available on the last ha release.
Did you manage to configure it correctly to get edf data ?
Thanks

Yes a PR is in progress : https://github.com/home-assistant/home-assistant/pull/10603
It works fine at home :slight_smile:
I’m running out of time to finalize it.

any chance to get it merged ?

If not (yet), how to install a custom component on hass.io ?

thanks a lot in advance!

Not enough time right now … I’ll try to rework it asap

Any luck ? I can give it a try sometime soon if you want!

FYI:
New Pull Request was issued by @nlamirault:


Unfortunately this one also got closed by now.
I hope, Nicolas will find some time soon to finish this sensor binding.

Hi,

I was also interested in teleinfo integration but I did it another way.
I coded a simple service which publishes the teleinfo frames via MQTT.
And then I use the native HA/MQTT integration.

Publish teleinfo frames to MQTT

docker run -d --name teleinfo-mqtt --device=/dev/ttyUSB0:/dev/ttyUSB0 -e MQTT_URL=mqtt://localhost:1883 fmartinou/teleinfo-mqtt:1.0.0-amd64

Read MQTT topic and get teleinfo data

- platform: mqtt
  name: teleinfo
  icon: mdi:speedometer
  state_topic: /teleinfo
  json_attributes_topic: /teleinfo
  value_template: "{{ value_json.PAPP.value }}"
  unit_of_measurement: VA

It’s in early stage but it works (at least for me :wink:
Feel free to test.
Feedback and contributions are welcome!

Hi,

Some times (years :slight_smile:) ago, I wrote a .NET program to export raw télé-information data to a MQTT broker.

I’ve recently discovered Home Assistant, so I adapted it and created a local add-on.

As it could be usefull for others, and a good way to make it evolves, I packaged it as an add-on called “TeleInfo2Mqtt”.
To install it, just add this add-ons repository (you can also copy and add it as local add-on) : https://github.com/fdrevet/hassio-addons-repository

It’s a beta release, for the moment :

  • following headers are published : IINST, PAPP, HCHC, HCHP, PTEC
  • no units of measurment yet
  • TLS connection to MQTT broker is not available
  • latest télé-information data are also available via a Rest Api (default port 8093) http://yourserver:8093/api/data/live

Have a good try :slight_smile:

1 Like

Hello,
I use this teleinfo integration since 2017 (works fine). I saw today a warning in the log and I try to update it, but the integration (https://www.home-assistant.io/components/sensor.teleinfo/) has been deleted ?

No 'version' key in the manifest file for custom integration 'teleinfo'. As of Home Assistant 2021.6, this integration will no longer be loaded

Is someone know why the integration has been removed ? Thanks

Are you familiar with ESPHome? There is a Teleinfo / Linky component for it that quickly transforms an ESP8266 with a bit of hardware into a Teleinfo interface that supports both historical and standard mode. (Hint: For advanced support of standard mode you may want to look into the open PRs for ESPHome.)

Thanks for your idea. I already got the hardware part. I’m wondering why this component has been deleted on github and the official integration removed !
Well, I will try to get the custom component working by myself I guess.

Yes, I got that. But the ESPHome component will not only provide the hardware but also the full HA integration. All Linky tags that you configure will be available as sensors in HA.