MySql query slows down
Try this rewriting. It avoids the GROUP BY and should be using the index on (sensor_id, recorded_at) for both the subquery and the join:

SELECT 
    input_times.instant, 
    c.sensor_id, 
    c.recorded_at AS first_before,
    c.value 
FROM 
    ( SELECT 80 AS sensor_id UNION ALL
      SELECT 85  UNION ALL
      SELECT 88  UNION ALL
      SELECT 89
    ) AS s
  CROSS JOIN
    ( SELECT '2016-06-29 00:00:00' AS instant 
      UNION ALL 
      ...
    ) AS input_times
  JOIN  
    cumulative_energy_consumptions AS c
  ON  c.sensor_id = s.sensor_id
  AND c.recorded_at = ( SELECT ci.recorded_at 
                        FROM cumulative_energy_consumptions AS ci
                        WHERE ci.sensor_id = s.sensor_id
                          AND ci.recorded_at &lt;= input_times.instant 
                        ORDER BY ci.recorded_at DESC
                        LIMIT 1
                      ) ;