Energy consumption of a HomeConnect dishwasher

HomeConnect devices do not seem to report back their energy or water consumption. But the consumption per load / cycle is indicated in Siemens / Bosch documentation. So, I thought I can create my own sensor to calculate the consumption:

- trigger:
    - trigger: state
      entity_id: sensor.kitchen_dishwasher_program_progress
  sensor:
    - name: "Dishwasher Energy Consumed"
      icon: "mdi:lightning-bolt"
      device_class: "energy"
      state_class: "total_increasing"
      unit_of_measurement: "kWh"
      unique_id: "sensor.kitchen_dishwasher_energy_consumed"
      state: >
        {% set delta = (trigger.to_state.state | float(0)) - (trigger.from_state.state | float(0)) %}
        {% set current = (states.sensor.kitchen_dishwasher_energy_consumed.state | float(0)) %}
        {% set act_prgm = states.select.kitchen_dishwasher_active_program.state %}
        {% set frst = trigger.from_state.state %}
        {% set prgms = { "dishcare_dishwasher_program_intensiv_70": 1.6, "dishcare_dishwasher_program_eco_50": 1.2 } %}
        {% if delta > 0.0 and frst != 'unknown' and frst != 'unavailable' and act_prgm != 'unknown' and act_prgm != 'unavailable' and prgms[act_prgm] != 'unknown' and prgms[act_prgm] != 'unavailable' %} %}
          {{ current + (delta * prgms[act_prgm])/100 | round(3) }}
        {% else %}
          {{ current | round(3) }}
        {% endif %}

The problem is: It always reports zero. I have tested the same config with my car, and it works:

- trigger:
    - trigger: state
      entity_id: sensor.snowwhite_energy_added
  sensor:
    - name: "Snowwhite Charge Added"
      icon: "mdi:ev-station"
      device_class: "energy"
      state_class: "total_increasing"
      unit_of_measurement: "kWh"
      unique_id: "sensor.snowwhite_charge_added"
      state: >
        {% set delta = (trigger.to_state.state | float(0)) - (trigger.from_state.state | float(0)) %}
        {% set current = (states.sensor.snowwhite_charge_added.state | float(0)) %}
        {% set loc = states.device_tracker.snowwhite_location_tracker.state %}
        {% set frst = trigger.from_state.state %}
        {% if delta > 0 and frst != 'unknown' and frst != 'unavailable' and loc == 'home' %}
          {{ current + delta | round(2) }}
        {% else %}
          {{ current | round(2) }}
        {% endif %}

Looking at the chart for the trigger sensor, it looks like something it should work, but it doesn’t:

What is going on here? What am I missing? How can I troubleshoot this?

You ever got this working? I think if you name your sensor “Kitchen Dishwasher Energy Consumed” it should work.

There is no need for reinventing wheel.
There is custom integration that you can install using hacs called powercalc that you can use for calculation of device power consumption.
But you can always use smart plug or outlet to plug dishwasher in and get real time power consumption.