Abstract-Private houses are more and more enabled with devices that can produce renewable energy, and the not so remote chance of selling the surplus energy makes them new players in the energy market. This market is likely to become deregulated since each energy home-producer can negotiate the energy price with consumers, typically by means of an auction; on the other hand, consumers can always rely on energy companies, even if their energy is more expensive. This scenario could lead to advantages for users, but it is certainly complex and dynamic, and needs an appropriate management. To this purpose, in this paper we propose an agent-based application to deal with the negotiation among different parties producing and consuming energy. Software agents, thanks to their autonomy in taking decisions, well suit the requirements of the proposed scenario. For our application, we adopt a strategy derived from game theory, in order to optimize energy production and supply costs by means of negotiation and learning. The effectiveness of our approach is proved by simulation results of a situation involving energy buyers, energy producers using renewable micro-generation facilities and large-scale traditional electricity companies.