This paper proposes an IoT-Fog-Cloud distributed consensus algorithm for solving the energy hub (EH) dispatch problem with packet-dropping communication links and some of EH elements' uncertainties. Every generating and consumption unit in this algorithm is required to estimate total power generated, total load, and power mismatches. Energy node coordination is accomplished using a distributed approach. Such a distributed approach wins in work sharing, enduring a single link failure, effective decision-making, quickest convergence, and autonomy for global power nodes. The method works with all grid types in connected and islanded modes. Minimizing total operation cost and emissions while meeting total demand and system constraints are the most crucial contributions of this paper. Two case studies are applied to explain performance and effectiveness of the proposed algorithm with different packet loss scenarios. Under uncertainty, sensitivity of the system was evaluated. Results show mismatch between generated and consumed power is improved by 100% in the electricity grid, 99.94% in heating grid, and 99.91% in gas grid. Also, total operating cost, total emissions, and emissions cost decreased by 8.6%, 13.48%, and 18.73%, respectively.