This study addresses the challenges of high energy consumption and environmental concerns in traditional greenhouse operations by exploring an integrated greenhouse with grid-tied photovoltaic (PV)-battery systems. A two-layer hierarchical optimization framework is proposed for effective energy management. In the upper layer, greenhouse operations are optimized with the Energy Consumption Minimization (ECM) strategy and the Energy Cost Minimization (ECoM) strategy, ensuring suitable climate conditions while reducing energy use and costs. In the lower layer, the scheduling of the hybrid energy system is optimized with the Self-consumption Maximization (SCM) strategy and the Total Cost Minimization (TCM) strategy, aiming to maximize the self-consumption of PV power and minimize total costs, including energy costs, battery aging costs, and carbon emission costs, while meeting the greenhouse’s electricity demand. A sensitivity analysis is conducted to investigate the impact of electricity prices, feed-in tariffs, battery capacity, and PV array area on hybrid energy system scheduling. Results reveal that the ECoM strategy reduces costs by 6.98% compared to the ECM strategy, and the TCM strategy reduces total costs by 43.50% compared to the SCM strategy. Battery capacity and PV array area are found to have a more significant influence on total costs than electricity prices and feed-in tariffs. This study can offer crucial insights for realizing cost-effective and environmentally friendly greenhouse operations, contributing to the advancement of sustainable agriculture.