myStrom WiFi Switch

I have a MyStrom Wifi Switch that I also got integrated.
I can query the values via the rest interface and the following code.

switch:
  - platform: mystrom
    host: <IP-ADRESS>
    name: myStrom

rest:
  - scan_interval: 1
    resource: <IP-ADRESS>
    method: GET
    sensor:
      - name: "myStrom power"
        value_template: '{{ value_json.power}}'
        unit_of_measurement: 'W'
        device_class: power
        state_class: measurement
      - name: "myStrom energy"
        value_template: '{{ value_json.Ws}}'
        unit_of_measurement: 'Ws'
        state_class: measurement
        device_class: power
      - name: "myStromPV temperature"
        value_template: '{{ value_json.temperature}}'
        unit_of_measurement: '°C'
        state_class: measurement

The problem is that I would like to have a variable in HomeAssitant that indicates the consumption in kWh. Unfortunately, the interface only gives the average consumption in Ws since the last query. Can someone write me a code that converts this.

Here is the link to the documentation of the interface myStrom

try this :point_down: