Read SMART-Meter Values

Hi, I have this smartmeter in my house: eBZ DD3 BZ06 ETA ODZ1
I entered the PIN for my smartmeter and connected it with this cable https://shop.weidmann-elektronik.de/index.php?page=product&info=24 to my raspberry pi:

In the pi shell I can see the device and after setting the correct baud rate etc with:
stty -F /dev/ttyUSB0 9600 -parodd cs7 -cstopb parenb -ixoff -crtscts -hupcl -ixon -opost -onlcr -isig -icanon -iexten -echo -echoe -echoctl -echoke

I can read the values:

!

/EBZ5DD3BZ06ETA_107



1-0:0.0.0*255(1EBZ0100XXXXXX)

1-0:96.1.0*255(1EBZ0100XXXXXX)

1-0:1.8.0*255(008468.60627700*kWh)

1-0:16.7.0*255(000173.63*W)

1-0:36.7.0*255(000030.31*W)

1-0:56.7.0*255(000143.32*W)

1-0:76.7.0*255(000000.00*W)

1-0:96.5.0*255(001C0104)

0-0:96.8.0*255(08D7C6B5)

!

Not sure how it should look like, but I guess it is correct because it shows the correct kwh and correct device id:

What would be the next step to integrate this to home assist?

My goal is it to read the current energy consumption and have statistics

I am une step further.

sensor:
  - platform: serial
    name: Smart Meter Raw
    serial_port: /dev/ttyUSB0
    baudrate: 9600
    bytesize: 7
    parity: O
    stopbits: 1
  - platform: template
    sensors:
      total_power_consumption:
        value_template: >
          {{ states('sensor.smart_meter_raw') | regex_findall_index('1-0:1.8.0\*255\((\d+\.\d+)\*kWh\)') }}
        unit_of_measurement: 'kWh'
        friendly_name: 'Total Power Consumption'

With this I can read the total power consumption. But it is flickering in the UI view under settings => devices & scenes => Entities => Total power Consumption
I can see the coorect value for a small amount of time and afterwards Unavailable within a second periodically. I guess this is because the Smart Meter is sending the data every second.

1.) How can I fix this problem? I guess this is a common problem with serial data. What would be the best practice in this case?

2.) Where and how can I visualize this data in my dashboard or somewhere else?

I solved my first problem by adding an if in my template:

sensor:
  - platform: serial
    name: Smart Meter Raw
    serial_port: /dev/ttyUSB0
    baudrate: 9600
    bytesize: 7
    parity: O
    stopbits: 1
  - platform: template
    sensors:
      total_power_consumption:
        value_template: >
          {% set raw_value = states('sensor.smart_meter_raw') %}
          {% if raw_value.startswith('1-0:1.8.0') %}
            {{ raw_value | regex_findall_index('1-0:1.8.0\*255\((\d+\.\d+)\*kWh\)') }}
          {% endif %}
        unit_of_measurement: 'kWh'
        friendly_name: 'Total Power Consumption'
      current_power_consumption:
        value_template: >
          {% set raw_value = states('sensor.smart_meter_raw') %}
          {% if raw_value.startswith('1-0:16.7.') %}
            {{ raw_value | regex_findall_index('1-0:16.7.0\*255\(([\d\.]+)\*W\)') }}
          {% endif %}
        unit_of_measurement: 'W'
        friendly_name: 'Current Power Consumption'

Now I would like to visualize the data somehow and do statistics. Where can I do this magic?