Heating, ventilation and air-conditioning(HVAC) system is a very important component in designing a Smart Home. The HVAC system itself is a Cyber-Physical system(CPS) and comes under Industry 4.0. Being connected to network it requires an integrated architecture of communication and control for its smooth operation. Heterogeneous nature of control and cyber domains is a great challenge in dealing with CPS development. An intelligent controller design coupled in a communication framework is presented in this paper for performance improvements in HVAC system. The control and communication architecture considers relevant system objectives based on system states and actuator actions. The HVAC system regulates the flow of conditioned air for various desired temperatures in different thermal zones. The formulated problem has been solved through real time optimization approach using learning based Proportional-Integral(PI) controller methodology following the communication protocol. The gradient descent algorithm updates the parameters of PI controller which in turn generates online control actions for achieving desired states. The algorithm helps in obtaining optimal control actions for the actuators and shows a fast convergence to the different desired temperature sets.