ESPHome support

ESPHome support was already there for DSMR. On GitHub there is a repository from nldroid which works absolutely fine! I even posted about this a while ago: ESPHome powered P1 meter. Yet this only worked for most of the readers, not all. Some countries like Belgium, Luxembourg, Sweden, and probably some other countries had some other fields in use than the standard.

For example Luxembourg is using encryption on their P1 port. So the data has to be decrypt before it is readable. Some other countries does also use KVar, which we in Holland don’t use. I wanted DSMR to be available for everybody in every country who’s using meters based on DSMR. So I started to look into the code and tried to rewrite some code, add more libraries, and boy did I found out that I’m not that good in coding…

I eventually asked a code dev-er from ESPHome. First Jesse, who gave me the first examples for custom_component, which I still struggled with. Later Guillermo who helped me a lot with rewriting more code. He eventually wrote the whole code as it is today. Off course I paid for his help, as he put a lot of time in to it.

Decryption support for Luxembourg

We found some good usable decryption examples, and as most Home Assistant users in Luxembourg knows: the decryption wasn’t handled that good. Not in the readers, not in the Home Assistant dsmr component. Obviously the question is: where should the decryption be handled?

To skip that question, I’ve decided to try to get that support straight into (my) reader. And luckily Guillermo managed to pull that off. If there’s a decryption key set, the reader will try to decrypt the telegrams with that key. If it isn’t set, it won’t decrypt.

There are two ways to set the key, either in the code, or via Home Assistant. Via the code it’s just one extra line under dsmr: ‘decryption_key’:

dsmr:
  id: dsmr_instance
  decryption_key: '00112233445566778899AABBCCDDEEFF'

Via Home Assistant you can use the service which is in the code via an API: <node_name>_set_dsmr_key

The code on GitHub

As I want it to be available for everybody, I’ve put the code on GitHub: https://github.com/zuidwijk/dsmr

Just use the example code “slimmelezer.yaml” and all the available fields will be added to Home Assistant.

39 comments

  1. Bob van Mierlo

    Hi Marcel,

    Ik heb je P1 wifi reader gekocht toen je deze nog standaard met esp-link leverde. Ik probeer deze nu te flashen naar esphome, maar de D1 mini pro wil onmogelijk in flashmodus gaan. Met geen enkele applicatie of usbkabel wil hij een nieuwe firmware accepteren.

    Heb ESPHome geprobeerd vanaf m’n latop, maar ook vanaf de Home Assistant server. Geen succes.
    Ook de ESPHome flasher voor windows werkt in 64bit en 32bit versie niet.

    Heb je nog ideeën?

      1. Hubald Alberti

        Ha Marcel, kan je mij in de CC opnemen? Zit in hetzelfde schuitje!
        (Complimenten trouwens voor de samenwerking met Home Assistant, een mooie stap!)

        1. Marcel

          Weet je zeker dat het geen “voeding only” kabeltje is? Niet alle usb kabels zijn hetzelfde. Vaak wordt er alleen een voedingskabeltje geleverd. Ook kan het zijn dat er geen driver is geïnstalleerd voor de usb-chip (CH340) … Heb je onder apparaatbeheer wel een onbekend apparaat als je ‘m aansluit op je computer?

    1. Marco

      Ik zit ook in hetzelfde schuitje met de v1.1;
      Misschien een idee hier een blog over te schrijven om veel supportvragen te voorkomen?

      1. Marcel

        Als jullie nog de oudere versie hebben met een jumper erop, dan moet de jumper verwijderd worden voor het flashen, en na het flashen weer terug gezet worden.

    2. Eric

      hoi
      ik loop tegen het zelfde probleem aan. misschien wel een driver probleem. Aparaatbeheer zegt een ft233r usb Uart driver. Blijkbaar staat de Wemos nog in verkeerde modus.
      Mijn meter komt uit januari.
      Misschien is een simpel stappen plan wel een idee

  2. Cristian van Loenen

    Hi, I bought the WIFI/ESPHome version for use with the new Energy functionality in Home Assistant (v2021.8.1). It was detected by HA as a new ESPHome integration and I see 1 device and 32 entities. However, I cannot select any of them to configure the Energy Grid Consumption (not in the list, not accepted). How can this be done?

    1. Marcel

      Hi Coen, to be honest, I havent played with the Energy dashboard, so I can’t answer that now. Better to ask that either on the forum or Discord.

      1. Cristian van Loenen

        I found out it is related to a few things:
        – The entities need to have state_class: measurement
        – The entities need to have a last reset timestamp property

        The easiest way however (do not know how accurate) is using the statistics functionalities and creating a new sensor in Home Assistant based on the Current power consumed entities from the reader (ESP):

        – platform: integration
        source: sensor.power_consumed_phase_1
        name: Consumed Phase 1
        unit_prefix: k
        round: 3

        This delivers a kWh sensor which can be used in the Energy dashboard as a grid entity

        1. Cristian van Loenen

          Not sure if it is even possible to configure entities in ESP directly in the way it is usable in the Energy dashboard, but as HA is promoting your product as a good solution for Energy Dashboard DSMR readings that would be of great help (or providing a good guide on the steps needed to add them like my example above)

          1. Marcel

            For the Energy Dashboard I cannot give support at this time… I havent had any time to play with it, even I’m a creator for devices that’s using it. I will eventually, but for now I’ll be focusing to get all the backorders as soon as possible shipped to their new happy smart home 😉

        2. Marcel

          My GitHub code is already a little out dated… I need to update that with lates adjustments from Otto and Guillermo (glmnet). Guillermo has made some great work on the code.

          1. Cristian van Loenen

            Just wanted to add the solution is reported in issue #9 on your github. Recompiling your ESP code (unchanged) on the newest version of ESP and reinstalling it on the device resolved the issue. The entities sensor.energy_consumed_tariff_1 / sensor.energy_consumed_tariff_2 are directly available for the Energy Dashboard. No need for any statistics, etc.

            Thanks for your great work!

  3. Rob

    Hallo Marcel,
    Ik heb een D1 Mini geflashed met je slimmelezer yaml.
    Het werkt meteen met Home Assistant, super!
    Maar ik heb ook DSMR Reader draaien en daar moet ik bij het ip-adres ook een poort ingeven, welke is dat?
    Alvast bedankt.

    1. Marcel

      Dat werkt niet Rob, de esp8266 kan maar 1 connectie aan. Plus je draait esphome, daar zit geen telnetserver in om het aan dsmr-reader te koppelen. Wil je en dsmr-reader gebruiken én home assistant. Dan raad ik je aan om esp-link te gebruiken, dat te koppelen aan dsmr-reader. en vervolgens dsmr-reader aan home assistant te koppelen via mqtt (dat is de enige manier die ik adviseer). Of je moet voor ethernet gaan, die kan meerdere connecties aan. Dan kan je en aan dsmr-reader koppelen en aan home assistant.

  4. Eric

    Bij mij wordt de Wemos d1 mini zowel in Windows al MacOs gezien als FT232R USb Uart.
    Dat is denk ik de reden dat ik niet kan flashen. Weet jij hoe dat kan. driver installeren werkt niet

    1. Marcel

      Dat is wel heel bijzonder! Alle Wemosen die ik heb, zowel de V1 als de V3 hebben allemaal de CH340 chip erop. Op mijn Mac zie ik “Productcode: 0x7523 & Fabrikantcode: 0x1a86” wat zie jij bij systeeminformatie staan?

  5. Andreas

    Hallo Marcel,
    Zo’n twee weken geleden de slimmelezer gekocht en gekregen. Aangesloten via Wifi en alles werkte prima.
    vandaag firmware update gedaan met “Latest Firmware SlimmeLezer (2021.8.0)” maar ik kom er niet meer bij. zie hem wel af en toe verschijnen als wifi netwerk, maar kan er niet mee verbinden. Enig idee wat ik nog kan doen?

    1. Marcel

      Beste kan je even met een usb kabel aan je computer aansluiten (moet je wel zorgen dat je de drivers hebt voor de CH340 chipset). Dan kan je via putty of andere terminal programma zien wat ie doet. Mail me als je er niet uit komt 🙂

  6. Armin

    Hi Marcel,
    a question from an austrian trying to get the SlimmeLezer to work here:
    What Pins on the ESP Board do you use to
    a) connect to Pin2 in the cable and
    b) connect to Pin5 in the cable?
    Best Regards,
    Armin

    1. Marcel

      Pins:
      1. [+5v] through diode to capacitor array (100/10/1/0,1 uF) and 5v on Wemos
      2. [EN] connected to the 5v rail after the diode (so either from P1 port or via usb of Wemos)
      3. [GND] connected to ground
      4. Not connected
      5. [DATA] Pulled up via 10k resistor to 5v and connected to the input logic inverter. The output is connected to 2nd UART D7/GPIO13
      6. [GND] connected to ground

  7. chris.van.aalst

    Marcel,

    vandaag slimme meter aangesloten, werkte eerst helemaal niet, geen power op de P1 poort, via usb werkte hij wel; na wat zoeken bleek dat ik de P1 poort moest activeren (in Belgie bij Fluvius); ging gelukkig online. Daarna eigen wifi ssid/passw ingevoerd en hij is nu beschikbaar via esphome.
    Ik heb nu 1 apparaat en een hele hoop entiteiten, maar enkel WIFI en uptime data is beschikbaar, al de rest is onbeschikbaar.
    Mis ik nog een stap ? Ik lees dat er voor Luxemburg een speciale key nodig is, maar voor Belgie/Nederland zou dit out-of-the-box moeten werken ? Of hangt dit ook van mijn meter af ? (meter is 2 maanden geleden nieuw geplaatst: SICONIA T211 M21 0071 merk Sagemcom )

    Chris

    1. Marcel

      Hey Chris, ik weet dat er problemen zijn, of waren, na de software update van Belgische meters van Fluvius (nieuwere 5.0 versie). Het is volgens mij opgelost na een software update. Ik zal vandaag nog even een nieuwere update plaatsen op de product pagina.

      1. Chris

        Marcel,

        ik gebruik ESPHOME en heb nu gewoon een configuratie aangemaakt met de laatste ‘slimmelezer.yaml’ van je GitHub (update 2021.9) – ik heb er de zaken voor Luxemburg uitgehaald.
        Ik heb hetzelfde probleem, maar kan nu de logging bekijken:
        dit krijg ik eenmaal bij opstarten:
        [W][uart:041]: You’re using the same serial port for logging and the UART component. Please disable logging over the serial port by setting logger->baud_rate to 0.
        -> opgelost door baud_rate:0 toe te voegen onder logger:

        dit krijg ik continue:
        Invalid string length
        [11:09:57][E][dsmr:138]: 0-0:96.1.4(50215)

        ik gebruik: Home Assistant: core-2021.8.6

        mvg

        Chris

  8. Cees Bakker

    Hello Marcel,

    I have installed the SlimmeLezer (with SlimmeLezer firmware for DSMR 2.x) and it works like a charm.
    It correctly shows up under the Home Assistant ESPHome integration (as slimmelezer-261e42; 1 device – 32 entities).

    However, I don’t see any entity for the SlimmeLezer in the Home Assistant (2021.9.4) Configuration|Energy configuration (i.e. Add Consumption).
    Did I do something wrong or did I forgot something?

    Additional Note:
    In my local network the SlimmeLezer Web Server is reachable from the browser on http://192.168.1.69.
    I already tried to install the Home Assistant DSMR integration but with connection type network, IP address 192.168.1.69, port 23, and DSMR version 2.2 I receive a ‘failed to connect’ error.

    Thanks in advance,

    Cees
    (the Netherlands)

  9. Niklas Lanzén

    Hi!
    I just received my SlimmeLezer and I live in Sweden. I have installed my SlimmeLezer and it has connected itself to to Home Assistant. Via ESPhome I can see 32 entities.
    But, when I try to add an entity to Energy produced or consumed I see no possible entities to chose from. I can see onm this page that Sweden has some “some other fields in use than the standard”. Anyone that knows what I should do?

  10. Andreas

    Hi Marcel
    ik ben al een tijdje aan de gang met homeassistant, maar ik kom er niet uit, ik heb een issue aangemaakt bij HA, maar die verwezen me naar jou. Ik krijg het niet voor elkaar om mijn zelf geconsumeerde zonne-energie te zien te krijgen/te berekenen. Mijn zonnepanelen leveren energie terug via fase 2 en 3, maar die kan ik binnen HA niet kiezen als entiteit. ik heb alleen de volgende entiteiten om uit te kiezen
    energy consumed tariff1
    energy consumed tariff2
    energy consumed Luxembourg

    energy produced Luxembourg
    energy produced Tariff1
    energy produced Tariff2

    doe ik iets fout?

    1. Marcel

      Hoi Andreas, beetje raar dat HA je naar mij verwijst… Ze moeten je naar ESPHome verwijzen. ESPHome beheert alle code, wijzigingen, features en issues. Ik hou niet van afschuiven, maar ik kan je denk niet heel veel helpen qua ESPHome. Heb je je eigen yaml code binnen ESPHome draaien? Dat raad ik sowieso aan. Dan kan je zelf makkelijk en snel wijzigingen doorvoeren, en hoef je niet elke keer je wifi opnieuw te koppelen bij een firmware upgrade.

      1. Andreas

        Hi Marcel,
        bedankt iig voor je antwoord. Dit was de comment die ik kreeg van HA:
        “The older “firmware” of the slimmelezer doesn’t support it, newer do. However, that is not a concern of the Home Assistant project. Please contact the vendor for more information and support on this.”
        vandaar dat ik bij jou uitkwam. Ik ga verder zoeken bij esphome.
        nogmaals bedankt!

        1. Marcel

          Ah ok, het heeft te maken met de “state_class: total_increasing” wat je toe moest voegen. Dat was de known issue met ESPHome destijds.
          Je zou ook esp-link kunnen proberen (staat op de product pagina)… dat is alleen een serial2wifi bridge wat alle data direct naar HA stuurt via de DSMR integratie.
          Zo heb ik mijn ethernet reader ook geïntegreerd. Heb zelf geen zonnepanelen helaas.

          1. Andreas

            Hi Marcel,
            volgens mij was dat state-class probleem opgelost met de firmware van 5 september? toch?
            Ik denk dat ik terug moet naar de schoolbanken. ik dacht met je slimme lezer en de integratie in HA, niet zo veel zelf te hoeven doen, maar helaas, ik begrijp er steeds minder van hoe het allemaal in elkaar steekt en aan elkaar gekoppeld moet worden. Maar goed, daar is dit niet het goede platform voor.
            In ieder geval bedankt voor je welwillendheid.

          2. Marcel

            Dat was in ieder geval wel de bedoeling Anreas… Ik maakte altijd gebruik van esp-link, en bied dat nog steeds als download aan. Alleen het koppelen daarvan aan wifi is wat minder gebruiksvriendelijk dan via een captive portal van ESPHome, echter zijn er zoveel verschillende issues gaande met ESPHome momenteel, dat het soms verwarrend kan zijn (en in mijn ogen wat minder gebruiksvriendelijk). Uiteindelijk zal dat wel opgelost worden, maar ik neig nu weer om mensen esp-link aan te bieden als workaround.

Leave a Reply to Andreas Cancel reply

Your email address will not be published. Required fields are marked *

Leave the field below empty!