Skip to content

Commit

Permalink
Update SimSolarBattery.lua
Browse files Browse the repository at this point in the history
Lost energy calculation resulted in a negative value, instead of a positive value.
  • Loading branch information
jakenl authored Apr 10, 2021
1 parent a774486 commit e6e766c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions SimSolarBattery.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
--version 0.1.2 05-04-2021: changed a check for latest data storage from seconds to milliseconds to accommodate meters that update every second
--version 0.1.3 05-04-2021: Added a check to avoid big deviations in calculation when inverter power level is small while having
-- also a small script interval. Added more debug logging
--version 0.1.4a 09-04-2021: Description text fix + little preparation for future release
--version 0.1.4b 10-04-2021: Description text fix + little preparation for future release

--To be created virtual devices in the hardware section of Domoticz:
local solarBattery_name = 'Virtual Solar Battery' -- (1) Virtual 'Custom Sensor' device name for the 'Virtual Solar Battery'. Change axis label to kWh
Expand Down Expand Up @@ -238,7 +238,7 @@ return {
domoticz.log('Energy balance = '..energyBalance..' Wh (negative = consumption)',domoticz.LOG_DEBUG)

if energyBalance > maxBbatteryInverterEnergy then
inverterLostEnergy = maxBbatteryInverterEnergy - energyBalance
inverterLostEnergy = energyBalance - maxBbatteryInverterEnergy
domoticz.log('Positive energybalance above max inverter capacity. inverterLostEnergy = '.. energyBalance ..' - ' ..maxBbatteryInverterEnergy .. ' = ' .. inverterLostEnergy, domoticz.LOG_DEBUG)
energyBalance = maxBbatteryInverterEnergy
batteryProdWatt = battery_inverter_power.value
Expand Down

0 comments on commit e6e766c

Please sign in to comment.