hif2k1 / battery_sim

Home assistant home battery simulator - allows you to model how much energy you would save with a home battery
115 stars 14 forks source link

Second export to grid #74

Closed SiemG closed 1 year ago

SiemG commented 1 year ago

Hello,

Is it possible to add an second export to the grid, this is because i have 2 import and 2 export tariffs, one is active in the evening and weekends while the other is active on workdays.

Thanks in advance

hif2k1 commented 1 year ago

Thanks, I will try and include this in the next release.

On Tue, 16 May 2023 at 07:46, SiemG @.***> wrote:

Hello,

Is it possible to add an second export to the grid, this is because i have 2 import and 2 export tariffs, one is active in the evening and weekends while the other is active on workdays.

Thanks in advance

— Reply to this email directly, view it on GitHub https://github.com/hif2k1/battery_sim/issues/74, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFAIZGKLCWTSVT3TESQCT23XGMPERANCNFSM6AAAAAAYDFO6C4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

nbeernink commented 1 year ago

Tried to add support for this via my fork here: https://github.com/hif2k1/battery_sim/compare/master...nbeernink:battery_sim:two_export

I haven't PR'd yet because I'm not quite sure how to test it. I prefer not to touch my production setup and don't know how to simulate the import/export sensors in a development environment from a P1 port. Tips here are welcome. :) Code-wise it seems this is all that's needed.

One question; Do I understand correctly that both import and both export sensors are read by the async_source_tracking function and values from the sensors are added together?

hif2k1 commented 1 year ago

Thanks, for your work on this. It should be working now in the latest release.

Your code was almost perfect. async_source_tracking_function actually registers listeners for each of the input sensors. However, there are different call back functions for the import sensors and the export sensors. I think the way you had it the second export would be read as an additional import.

I'm probably not the right person to advise about testing, but you can run a separate developer instance of home assistant with all your normal sensors. To allow you to test things.