We present optical and near-infrared (NIR) photometry and spectroscopy as well as modelling of the lightcurves of the Type IIb supernova (SN) 2011dh. Our extensive dataset, for which we present the observations obtained after day 100, spans two years, and complemented with Spitzer mid-infrared (MIR) data, we use it to build an optical-to-MIR bolometric lightcurve between days 3 and 732. To model the bolometric lightcurve before day 400 we use a grid of hydrodynamical SN models, which allows us to determine the errors in the derived quantities, and a bolometric correction determined with steady-state non-local thermodynamic equilibrium (NLTE) modelling. Using this method we find a helium core mass of 3.1 +0.7 −0.4 M for SN 2011dh, consistent within error bars with previous results obtained using the bolometric lightcurve before day 80. We compute bolometric and broad-band lightcurves between days 100 and 500 from spectral steady-state NLTE models, presented and discussed in a companion paper. The preferred 12 M (initial mass) model, previously found to agree well with the observed spectra, shows a good overall agreement with the observed lightcurves, although some discrepancies exist. Time-dependent NLTE modelling shows that after day ∼600 a steadystate assumption is no longer valid. The radioactive energy deposition in this phase is likely dominated by the positrons emitted in the decay of 56 Co, but seems insufficient to reproduce the lightcurves, and what energy source is dominating the emitted flux is unclear. We find an excess in the K and the MIR bands developing between days 100 and 250, during which an increase in the optical decline rate is also observed. A local origin of the excess is suggested by the depth of the He 20 581 Å absorption. Steady-state NLTE models with a modest dust opacity in the core (τ = 0.44), turned on during this period, reproduce the observed behaviour, but an additional excess in the Spitzer 4.5 µm band remains. Carbon-monoxide (CO) first-overtone band emission is detected at day 206, and possibly at day 89, and assuming the additional excess to be dominated by CO fundamental band emission, we find fundamental to first-overtone band ratios considerably higher than observed in SN 1987A. The profiles of the [O ] 6300 Å and Mg ] 4571 Å lines show a remarkable similarity, suggesting that these lines originate from a common nuclear burning zone (O/Ne/Mg), and using small scale fluctuations in the line profiles we estimate a filling factor of 0.07 for the emitting material. This paper concludes our extensive observational and modelling work on SN 2011dh. The results from hydrodynamical modelling, steady-state NLTE modelling, and stellar evolutionary progenitor analysis are all consistent, and suggest an initial mass of ∼12 M for the progenitor.