n_distinct
The number of groups in a GROUP BY comes from n_distinct. Here it was set to 5, so the planner thinks there are 5 devices.
task
The group-count estimate for readings by device_id is far off. Fix it so the HashAggregate estimate is between 55 and 65 rows.