A variable refrigerant flow (VRF) system for a building includes an outdoor VRF unit, a plurality of indoor VRF units, a battery, and a predictive VRF controller. The outdoor VRF unit includes powered VRF components configured to apply heating or cooling to a refrigerant. The indoor VRF units are configured to use the heated or cooled refrigerant to provide heating or cooling to a plurality of building zones. The battery is configured to store electric energy and discharge the stored electric energy for use in powering the powered VRF components. The predictive VRF controller is configured to optimize a predictive cost function to determine an optimal amount of electric energy to purchase from an energy grid and an optimal amount of electric energy to store in the battery or discharge from the battery for use in powering the powered VRF components at each time step of an optimization period.