Count hours when a specific value is higher than a treshold
Q: This is the query that i've built, actually i'm able to select only the rows that have the kw value greater than 1 and group them by
month, but i'm not able to figure out how to calculate the production
hours:

You need to get each measurement and the next measurement into a single row. This is typically what the lag window function does:
SELECT mt.insert_time,
       lag(mt.insert_time) OVER w AS next_time 
       (mt.data-&gt;&gt;'kw')::int AS curr_value,
       ((lag(mt.data) OVER w)-&gt;&gt;'kw')::int AS next_value
FROM mytable mt 
WHERE sensor = 7 
WINDOW w AS (order by pk)  -- or order by insert_time if you prefer

Once both the current and next measurements are in the same row, you have the duration between them (=next_time - insert_time) and can sum and filter out rows when the kw value went from above 1 to below 1 or the opposite, or were both below 1.