Calculate power form other variables

Regards,
I want to calculate power usage on my heat pump using temperature sensor.
Now I can visualize data but cannot calculate right power.
It is easy to determine when pump working. If temp otuput is > 30 pump working. I found way to make step function

SELECT (((abs(mean("temp_input") - 29 ) / (mean("temp_input") - 29) + 1 ) /2)/24) as uptime FROM "sensors" WHERE ("feature" = 'temp1') AND $timeFilter GROUP BY time($__interval) fill(null)

Another way
`

SELECT mean(“temp_input”)/mean(“temp_input”) FROM “sensors” WHERE (“feature” = ‘temp1’) AND “temp_input”> 30 AND timeFilter GROUP BY time(__interval) fill(null)

`

Any idea how to calculate power usage for specific time range.
Thank you
Heat pump power 2,5kW