Multiple total daily energy sensor

Hello
I’ve created total daily energy sensor for my heating device

 - platform: total_daily_energy
    name: "Total daily usage"
    id: kospel_daily_power_usage
    power_id: power
    unit_of_measurement: kWh
    device_class: energy
    icon: mdi:calendar-clock

I wan’t to create two sub total calculacion based on state of the sensors.

- platform: total_daily_energy
    name: "Total daily power usage CO"
    id: kospel_daily_power_usage_co
    power_id: power
    unit_of_measurement: kWh
    icon: mdi:calendar-clock
    device_class: energy
    filters:
      - lambda: |-
          if (id(sensor_wb_co).state == 1 && id(tdr).state == "co")  {
            return x;
          } else {
            return {}; 
          }

but result is based on total energy usage not sum of current power

and second one

- platform: total_daily_energy
    name: "Kospel zużycie energii dzienne CWU"
    id: kospel_daily_power_usage_cwu
    power_id: power
    device_class: energy
    unit_of_measurement: kWh
    icon: mdi:calendar-clock
    filters:
      - lambda: |-
          if (id(sensor_wb_cwu).state == 1 && id(tdr).state == "cwu") {
            return x;
          } else {
            return {}; 
          }       

do you have any tips how to proceed?