The above is a good example but it shows the average over all recorder data.
If you want to project the current electricity usage per hour on top of the graph with electricity rates of the day you need the following SQLite statement:
SELECT AVG(state)/1000 as total_average, GROUP_CONCAT(state ORDER BY hour) as hourly_averages
FROM (SELECT ROUND(AVG(state)/1000, 3) as state, strftime("%H",datetime(last_updated_ts,"unixepoch","localtime")) as hour
FROM states INNER JOIN states_meta ON states_meta.metadata_id=states.metadata_id
WHERE states_meta.entity_id = 'sensor.p1_meter_5c2faf102094_active_power'
AND date(last_updated_ts,"unixepoch","localtime") = date("now","localtime")
GROUP BY strftime("%H",datetime(last_updated_ts,"unixepoch"))
);
