Calculate price of consumed energy in Spain's PVPC system

Good tutorial.
You might be interested in Energy: Cost for the individual devices which allow home assistant to make all of this for you (it does it for your global consumption but not for individual devices yet)