kWh usage based on state visualization help?

Hey all! I’m having a hard time wrapping my head around how to accurately achieve something. I’ve got a heat pump and, ultimately, would like to get a Grafana visualization of monthly kWh usage broken out by heating & cooling (ie. cooling kWh vs. heating kWh). I use Emporia Vue integrated with homeassistant and can get total daily kWh usage of sensor.heat_pump_1_1d (or month). But that won’t show me whether the heat pump is in heating or cooling mode. For that, I have the Mitsubishi integration and can get the state of sensor.air_handler. I created two template sensors (below), but those are somewhat flawed for days when cooling AND heating is used because it assigns the current value of the Emporia Vue sensor when the change is made, which is not the actual kWh usage. How should I think about this differently? Or is there a different way to create these template sensors, or something else to use entirely (even other than Grafana)? I’m open to anything, I just want to end up with a view of kWh used broken out by cooling vs. heating. Thanks for any thoughts/help you can all provide!

- sensor:
    - name: "Daily Cooling Energy"
      unit_of_measurement: "kWh"
      state_class: total_increasing
      device_class: energy
      state: >
        {% if is_state('climate.air_handler', 'cool') %}
          {{ states('sensor.heat_pump_1_1d') | float }}
        {% endif %}

- sensor:
    - name: "Daily Heating Energy"
      unit_of_measurement: "kWh"
      state_class: total_increasing
      device_class: energy
      state: >
        {% if is_state('climate.air_handler', 'heat') %}
          {{ states('sensor.heat_pump_1_1d') | float }}
        {% endif %}

Make a utility_meter helper with two tariffs: heat and cool. Set the source sensor as your heat pump kWh.

When the climate is in heating mode, select the heat tariff. When the climate is in cooling mode, select the cool tariff.

This will output two kWh sensors, one for energy consumed while in heat mode, and one for energy consumed while in cool mode.