How to convert time of binary_sensor ON to money spent :)

I have configured my binary sensor and history_stats platform to count ON time of my heating. I am tracking monthly usage. I’d like to have also monthly cost.
Mathematics would be:
Time_Heating_On * Average_Gas_Usage_Per_Hour * Cost, for example:
98:44 * 1,3 * 3,55
I think for simplicity i could extract just hours from time and then display results of multiplicationbut have no idea kow.
How do i proceed with this, any ideas or somebody has something similar implemented?

template:
  - binary_sensor:
      - name: "HEATING"
        state: >
          {{ states('sensor.heating_power')|float > 100 }}

 - platform: history_stats
   name: Heating this month
   entity_id: binary_sensor.HEATING
   state: 'on'
   type: time
   start: '{{ now().replace(day=1).replace(hour=0).replace(minute=0).replace(second=0) }}'
   end: "{{ now() }}"

This is the best i could get from ChatGPT. I feel i am almost there, but code is giving errors bc of outdatet info in chatgtp

sensor:
  - platform: template
    sensors:
      monthly_heating_cost:
        friendly_name: "Monthly Heating Cost"
        value_template: >
          {% set on_time = state_attr('sensor.heating_this_month', 'value') %}
          {% set average_gas_usage_per_hour = 1.3 %}  # Replace with your actual value
          {% set cost_per_hour = 3.55 %}  # Replace with your actual cost
          {{ (on_time | float / 3600) * average_gas_usage_per_hour * cost_per_hour | round(2) }}
        unit_of_measurement: 'currency_symbol'  # Replace with your currency unit
1 Like

Final working version

template:
  - sensor:
      - name: "Monthly Heating Cost"
        unit_of_measurement: "PLN"
        state: >
          {% set on_time = states('sensor.heating_on_this_month') %}
          {% set average_gas_usage_per_hour = 1.3 %}
          {% set cost_per_hour = 3.55 %}
          {{ ((on_time | float ) * average_gas_usage_per_hour * cost_per_hour) | round(0)  }}