Slimmelezer - unexpected state class

Hi all,

Prior to upgrading to 2021.9, my Slimmelezer from Marcel Zuidwijk was easily integrated. Data was flowing in and the newly (great!) energy dashboard was working fine.

However, somehow after upgrading to 2021.9, I get the following warning or error message:

Unexpected state class
The following entities do not have the expected state class 'total_increasing'
sensor.energy_consumed_tariff_1 (measurement)

I’ve reflashed the Slimmelezer, upgraded it to ESPHome 2021.9 dev, downgraded it again etcetera, but it is still broken…any clues what this might be/how to solve it? Thanks in advance!

3 Likes

I’m having the same issue, and all my graphs are empty. Worked great before 2021.9.0 but now doesn’t show at all. The entities itself seem fine though.

1 Like

Here the same problem.

The component still needs to be adjusted in ESPHome, as a temporary solution you can also add the state_class yourself in your ESPHome config.

state_class: total_increasing

Can you give a bit more details on this? I bought SlimmeLezer as a pre-installed ready-made solution so “changing your ESPHome config” is quite vague to me, especially given I never had an ESPHome config for SlimmeLezer (as it was all pre-installed on SlimmeLezer itself).

Thanks Klaas, this removed the error message!
Still have to be patient to see the data flowing again…

Okay, I figured it out, the original ESPHome config was here: dsmr/slimmelezer.yaml at 2a60634ab628626951736d404878e1361c23868b · zuidwijk/dsmr · GitHub

So you just have to add state_class: total_increasing to the relevant sensors to get the following .yaml:

---
substitutions:
  device_name: slimmelezer
  device_description: "DIY P1 module to read your smart meter"

esphome:
  name: ${device_name}
  comment: "${device_description}"
  platform: ESP8266
  esp8266_restore_from_flash: true
  board: d1_mini
  name_add_mac_suffix: true
  project:
    name: zuidwijk.slimmelezer
    version: "1.0"
  on_boot:
    then:
      - if:
          condition:
            lambda: return id(has_key);
          then:
            - lambda: |-
                std::string key(id(stored_decryption_key), 32);
                id(dsmr_instance).set_decryption_key(key);
          else:
            - logger.log:
                level: info
                format: "Not using decryption key. If you need to set a key use Home Assistant service 'ESPHome:  ${device_name}_set_dsmr_key'"

wifi:
  networks:
    - ssid: "your_wifi_ssid"
      password: "yout_wifi_password"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: ${device_name}

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  services:
    service: set_dsmr_key
    variables:
      private_key: string
    then:
      - logger.log:
          format: Setting private key %s. Set to empty string to disable
          args: [private_key.c_str()]
      - globals.set:
          id: has_key
          value: !lambda "return private_key.length() == 32;"
      - lambda: |-
          if (private_key.length() == 32)
            private_key.copy(id(stored_decryption_key), 32);
          id(dsmr_instance).set_decryption_key(private_key);

ota:

web_server:
  port: 80

uart:
  baud_rate: 115200
  rx_pin: D7

globals:
  - id: has_key
    type: bool
    restore_value: yes
    initial_value: "false"
  - id: stored_decryption_key
    type: char[32]
    restore_value: yes

dsmr:
  id: dsmr_instance
  # For Luxembourg users set here your decryption key
  #decryption_key: !secret decryption_key // enable this when using decryption for Luxembourg; key like '00112233445566778899AABBCCDDEEFF'

sensor:
  - platform: dsmr
    energy_delivered_lux:
      name: "Energy Consumed Luxembourg"
      state_class: total_increasing
    energy_delivered_tariff1:
      name: "Energy Consumed Tariff 1"
      state_class: total_increasing
    energy_delivered_tariff2:
      name: "Energy Consumed Tariff 2"
      state_class: total_increasing
    energy_returned_lux:
      name: "Energy Produced Luxembourg"
      state_class: total_increasing
    energy_returned_tariff1:
      name: "Energy Produced Tariff 1"
      state_class: total_increasing
    energy_returned_tariff2:
      name: "Energy Produced Tariff 2"
      state_class: total_increasing
    power_delivered:
      name: "Power Consumed"
      accuracy_decimals: 0
      filters:
        - multiply: 1000
    power_returned:
      name: "Power Produced"
      accuracy_decimals: 0
      filters:
        - multiply: 1000
    electricity_failures:
      name: "Electricity Failures"
      icon: mdi:alert
    electricity_long_failures:
      name: "Long Electricity Failures"
      icon: mdi:alert
    voltage_l1:
      name: "Voltage Phase 1"
    voltage_l2:
      name: "Voltage Phase 2"
    voltage_l3:
      name: "Voltage Phase 3"
    current_l1:
      name: "Current Phase 1"
    current_l2:
      name: "Current Phase 2"
    current_l3:
      name: "Current Phase 3"
    power_delivered_l1:
      name: "Power Consumed Phase 1"
      accuracy_decimals: 0
      filters:
        - multiply: 1000
    power_delivered_l2:
      name: "Power Consumed Phase 2"
      accuracy_decimals: 0
      filters:
        - multiply: 1000
    power_delivered_l3:
      name: "Power Consumed Phase 3"
      accuracy_decimals: 0
      filters:
        - multiply: 1000
    power_returned_l1:
      name: "Power Produced Phase 1"
      accuracy_decimals: 0
      filters:
        - multiply: 1000
    power_returned_l2:
      name: "Power Produced Phase 2"
      accuracy_decimals: 0
      filters:
        - multiply: 1000
    power_returned_l3:
      name: "Power Produced Phase 3"
      accuracy_decimals: 0
      filters:
        - multiply: 1000
    gas_delivered:
      name: "Gas Consumed"
      state_class: total_increasing
    gas_delivered_be:
      name: "Gas Consumed Belgium"
      state_class: total_increasing
  - platform: uptime
    name: "Uptime"
  - platform: wifi_signal
    name: "Wi-Fi Signal"
    update_interval: 60s

text_sensor:
  - platform: dsmr
    identification:
      name: "DSMR Identification"
    p1_version:
      name: "DSMR Version"
    p1_version_be:
      name: "DSMR Version Belgium"
  - platform: wifi_info
    ip_address:
      name: "IP Address"
    ssid:
      name: "Wi-Fi SSID"
    bssid:
      name: "Wi-Fi BSSID"

And then you run the following command in the same directory as you saved slimmelezer.yaml:

esphome run slimmelezer.yaml

If that fails, look up the IP (it will be in the entity in Home Assistant) and run this:

esphome run slimmelezer.yaml --device your_slimmelezer_ip
3 Likes

Bit confused right now. How is the update of the firmware managed anyway? The Github page states that the component is managed by ESPhome and not in the Git repo.

I’m used to compile the YAML via the ESPhome dashboard. Managed to compile and upload it but the reading has stopped :frowning:

Thanks. Works like a charm.

Thank you, perfect fix

This repository is outdated: https://github.com/zuidwijk/dsmr since we add the DSMR component to ESPHome native.

1 Like

There is already an PR open in ESPHome to change the state_class, when that is merged the changes in your example config are no longer needed :grinning_face_with_smiling_eyes:

2 Likes

But don’t we still need to reflash our SlimmeMeter to have this take effect anyway? And therefore don’t we need the original config still? I’m really having trouble understanding what we as end-users need to do.

1 Like

That’s right, eventually you have to flash the SlimmeLezer again, but it’s no longer necessary to add the state_class yourself.

But it’s also a thing that the SlimmeLezer is flashed by default with certain firmware and that unfortunately quickly becomes outdated, updating for the end user can be a task.

And as far as I can find, https://github.com/zuidwijk/dsmr/blob/2a60634ab628626951736d404878e1361c23868b/slimmelezer.yaml is the only place the default config is posted. So even though that repository is outdated there seems to be no other place to get the config from needed to reflash?

I guess preferably Marcel Zuidwijk should update the “Latest firmware” on SlimmeLezer – Marcel Zuidwijk but just a link to the config there would be good too. It is a bit odd that there is only a binary version available. Luckily though the SlimmeLezer itself has a webpage to upload new firmware.

I guess I’ll try to convince Marcel of that when the new ESPHome release is done :slight_smile:

Hi I have similar issues. I am not familiar with using ESPHome. Installed the SlimmeLezer via the ip-address 192.168.4.1. Via the user interface I’ve added my WiFi credentials and BOOM HomeAssistant picked-up the SlimmeLezer and until 2021.9.0 it worked perfectly.

The proposed solutions by @klaasnicolaas and @TheLastProject in this thread confuses me a lot. I don’t know how to access the slimmelezer and where to put these additional statements or even to access it. I’ve installed the ESPHome addon, but this doesn’t give me any options to connect with the slimmelezer.

Is it best to wait for a fix?

it’s confusing because everyone uses the SlimmeLezer differently. one that has its own yaml config and the other flashes the firmware that Marcel Zuidwijk offers via the website every time.

Fixed it with the solution from @TheLastProject for now (many thx ;-)) by adding the device to ESPHome and sending the yaml to it. After the update however the device name is now including a part of the MAC address, how can I fix this to just be “slimmelezer” again?

How to flash?

Hi, im using the “Firmware for older meters (DSMR2.x)” I think the yaml of that is different than the one on GitHub but i’m not sure. Is there an possibility to apply the Quick fix to?

1 Like