davidusb-geek / emhass

emhass: Energy Management for Home Assistant, is a Python module designed to optimize your home energy interfacing with Home Assistant.
MIT License
263 stars 51 forks source link

Wrong objective formula in case of "grid cost" cost function #134

Closed michaelpiron closed 7 months ago

michaelpiron commented 7 months ago

While looking at the code in order to understand the functioning of EMHASS, I noticed an inconsistency in the objective formulas. The profit cost function shows this: https://github.com/davidusb-geek/emhass/blob/bec6f76f1d7795a1ab8730fb0a61f883e75caf0c/src/emhass/optimization.py#L196-L204 which looks correct, and is consistent with the EMHASS documentation:

However, the "grid cost" cost function seems to have the formulas inverted, which is unexpected: https://github.com/davidusb-geek/emhass/blob/bec6f76f1d7795a1ab8730fb0a61f883e75caf0c/src/emhass/optimization.py#L205-L211

Therefore, I wonder if the objective formulas in "Grid cost" cost function shouldn't be inverted. I'll propose a pull request for this.

michaelpiron commented 7 months ago

Made a pull request immediately, therefore closing this issue