hif2k1 / battery_sim

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

No discharge at night? #83

Closed timdj closed 9 months ago

timdj commented 11 months ago

I have configured a simulated battery with 2 in and 2 out. However the battery won't discharge at night exactly at the time the second tariff starts

image

hif2k1 commented 11 months ago

Yes seems its not picking up the second tarrif. Can you get more info by running it in debug mode and posting the log? Just add this to your config file: logger:

default: critical logs: custom_components.battery_sim: debug

Then run it for the period when the problem is happening and then post then log.

Thanks

On Wed, 19 Jul 2023, 10:41 Tim de Jong, @.***> wrote:

I have configured a simulated battery with 2 in and 2 out. However the battery won't discharge at night exactly at the time the second tariff starts

[image: image] https://user-images.githubusercontent.com/524112/254532805-7e079944-f7b7-4565-8c92-ea9f96a0ea41.png

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

Daandamhuis commented 11 months ago

@hif2k1 : It seems like the second sensor isn’t stored in the configuration. I’ve added _LOGGER.debug(config and this was the output of the log. I\ve setup two batteries (Powerwall and Custom Battery).

Because it checks for len(second import or export) > 6 it fails to the set the second one, because it doesn’t exists in the config.

{
   "size_kwh":13.5,
   "max_discharge_rate_kw":5.0,
   "max_charge_rate_kw":3.68,
   "efficiency":0.9,
   "setup_type":"config_flow",
   "name":"battery_sim: Tesla Powerwall",
   "type_of_energy_meter":"two_import_two_export",
   "tariff_type":"No tariff information",
   "import_sensor":"sensor.energy_consumption_tarif_1",
   "export_sensor":"sensor.energy_production_tarif_1"
} 

Rest of the log

2023-08-11 22:24:56.214 DEBUG (MainThread) [custom_components.battery_sim] Setup battery_sim.battery_sim: Battery-16kwh
2023-08-11 22:24:56.214 DEBUG (MainThread) [custom_components.battery_sim] {'unique_name': 'Battery-16kwh', 'size_kwh': 16.0, 'max_discharge_rate_kw': 9.0, 'max_charge_rate_kw': 6.0, 'efficiency': 0.9, 'setup_type': 'config_flow', 'name': 'battery_sim: Battery-16kwh', 'type_of_energy_meter': 'two_import_two_export', 'tariff_type': 'No tariff information', 'import_sensor': 'sensor.energy_consumption_tarif_1', 'export_sensor': 'sensor.energy_production_tarif_1'}
2023-08-11 22:24:56.215 DEBUG (MainThread) [custom_components.battery_sim] Setup battery_sim.battery_sim: Tesla Powerwall
2023-08-11 22:24:56.215 DEBUG (MainThread) [custom_components.battery_sim] {'size_kwh': 13.5, 'max_discharge_rate_kw': 5.0, 'max_charge_rate_kw': 3.68, 'efficiency': 0.9, 'setup_type': 'config_flow', 'name': 'battery_sim: Tesla Powerwall', 'type_of_energy_meter': 'two_import_two_export', 'tariff_type': 'No tariff information', 'import_sensor': 'sensor.energy_consumption_tarif_1', 'export_sensor': 'sensor.energy_production_tarif_1'}
2023-08-11 22:25:31.101 DEBUG (MainThread) [custom_components.battery_sim] <battery_sim: Battery-16kwh> monitoring sensor.energy_consumption_tarif_1
2023-08-11 22:25:31.101 DEBUG (MainThread) [custom_components.battery_sim] <battery_sim: Battery-16kwh> monitoring None
2023-08-11 22:25:31.101 DEBUG (MainThread) [custom_components.battery_sim] <battery_sim: Battery-16kwh> monitoring sensor.energy_production_tarif_1
2023-08-11 22:25:31.102 DEBUG (MainThread) [custom_components.battery_sim] <battery_sim: Battery-16kwh> monitoring None
2023-08-11 22:25:31.102 DEBUG (MainThread) [custom_components.battery_sim] <battery_sim: Tesla Powerwall> monitoring sensor.energy_consumption_tarif_1
2023-08-11 22:25:31.102 DEBUG (MainThread) [custom_components.battery_sim] <battery_sim: Tesla Powerwall> monitoring None
2023-08-11 22:25:31.102 DEBUG (MainThread) [custom_components.battery_sim] <battery_sim: Tesla Powerwall> monitoring sensor.energy_production_tarif_1
2023-08-11 22:25:31.102 DEBUG (MainThread) [custom_components.battery_sim] <battery_sim: Tesla Powerwall> monitoring None
Casenl commented 10 months ago

I am having the exact same issue with 2 tariffs, no discharging during 2nd tariff (23:00 - 07:00), Logging doesn't seem to show anything strange, but doesn't do anything between tariff changes. Here is a small part of the log:


> 2023-08-14 23:00:45.403 DEBUG (MainThread) [custom_components.battery_sim] Battery update event (battery_sim: LG Chem). Import: 0.007, Export: 0.0
> 2023-08-14 23:00:45.403 DEBUG (MainThread) [custom_components.battery_sim] Battery (battery_sim: LG Chem) normal mode.
> 2023-08-14 23:00:45.403 DEBUG (MainThread) [custom_components.battery_sim] Battery update complete (battery_sim: LG Chem). Sensors: {'total energy saved': 2.9236999999992803, 'battery_energy_out': 2.9236999999992803, 'battery_energy_in': 9.990210526315009, 'current charging rate': 0.0, 'current discharging rate': 0.4201667689162387, 'simulated grid export after battery charging': 5512.208789473685, 'simulated grid import after battery discharging': 7509.0623000000005, 'total_money_saved': 0.0, 'Battery_mode_now': 'Discharging', 'money_saved_on_imports': 0.0, 'extra_money_earned_on_exports': 0.0, 'battery_cycles': 1.0742161856252697}
> 2023-08-14 23:01:45.390 DEBUG (MainThread) [custom_components.battery_sim] Battery update event (battery_sim: LG Chem). Import: 0.006, Export: 0.0
> 2023-08-14 23:01:45.390 DEBUG (MainThread) [custom_components.battery_sim] Battery (battery_sim: LG Chem) normal mode.
> 2023-08-14 23:01:45.390 DEBUG (MainThread) [custom_components.battery_sim] Battery update complete (battery_sim: LG Chem). Sensors: {'total energy saved': 2.929699999999593, 'battery_energy_out': 2.929699999999593, 'battery_energy_in': 9.990210526315009, 'current charging rate': 0.0, 'current discharging rate': 0.36007849928311625, 'simulated grid export after battery charging': 5512.208789473685, 'simulated grid import after battery discharging': 7509.0623000000005, 'total_money_saved': 0.0, 'Battery_mode_now': 'Discharging', 'money_saved_on_imports': 0.0, 'extra_money_earned_on_exports': 0.0, 'battery_cycles': 1.0742161856252697}
> 2023-08-15 07:02:47.406 DEBUG (MainThread) [custom_components.battery_sim] Battery update event (battery_sim: LG Chem). Import: 0.007, Export: 0.0
> 2023-08-15 07:02:47.406 DEBUG (MainThread) [custom_components.battery_sim] Battery (battery_sim: LG Chem) normal mode.
> 2023-08-15 07:02:47.407 DEBUG (MainThread) [custom_components.battery_sim] Battery update complete (battery_sim: LG Chem). Sensors: {'total energy saved': 2.9366999999992003, 'battery_energy_out': 2.9366999999992003, 'battery_energy_in': 9.990210526315009, 'current charging rate': 0.0, 'current discharging rate': 0.0008731198647756483, 'simulated grid export after battery charging': 5512.208789473685, 'simulated grid import after battery discharging': 7509.0623000000005, 'total_money_saved': 0.0, 'Battery_mode_now': 'Discharging', 'money_saved_on_imports': 0.0, 'extra_money_earned_on_exports': 0.0, 'battery_cycles': 1.0742161856252697}
> 2023-08-15 07:03:47.474 DEBUG (MainThread) [custom_components.battery_sim] Battery update event (battery_sim: LG Chem). Import: 0.006, Export: 0.0
> 2023-08-15 07:03:47.475 DEBUG (MainThread) [custom_components.battery_sim] Battery (battery_sim: LG Chem) normal mode.
> 2023-08-15 07:03:47.475 DEBUG (MainThread) [custom_components.battery_sim] Battery update complete (battery_sim: LG Chem). Sensors: {'total energy saved': 2.942699999999513, 'battery_energy_out': 2.942699999999513, 'battery_energy_in': 9.990210526315009, 'current charging rate': 0.0, 'current discharging rate': 0.3595912610933118, 'simulated grid export after battery charging': 5512.208789473685, 'simulated grid import after battery discharging': 7509.0623000000005, 'total_money_saved': 0.0, 'Battery_mode_now': 'Discharging', 'money_saved_on_imports': 0.0, 'extra_money_earned_on_exports': 0.0, 'battery_cycles': 1.0742161856252697}
rrozema commented 10 months ago

I had a similar issue, although mine was more noticeable: I had no charge during the day (my "first" tarif was the night tarif). Based on the information in this issue, I went ahead and created 2 helpers:

Next I went ahead and edited my /config/.Storage/core.config_entries file:

After the restart all of my simulated batteries started charging and I finally get my simulated charts filled in: image

I think this proves that indeed the issue reported here also is my problem.

Daandamhuis commented 10 months ago

I've made some changes and it seems to be working. I'll update the PR to make it so it is working again.

image

hif2k1 commented 10 months ago

Thanks to @Daandamhuis hopefully going to have this resolved shortly. @rrozema like that energy distribution card what did you use for that?

rrozema commented 10 months ago

It's the sankey chart card, available through HACS: https://github.com/MindFreeze/ha-sankey-chart. I use that sankey in combination with Energy Period Selector Plus: https://github.com/flixlix/energy-period-selector-plus.

This combi enables me to create a single page in HA that easily compares the situation for "no battery" (my actual measurements) with multiple variations of simulated batteries over any selectable time frame: day, week, month, year or custom.

Op wo 23 aug 2023 om 11:13 schreef hif2k1 @.***>:

Thanks to @Daandamhuis https://github.com/Daandamhuis hopefully going to have this resolved shortly. @rrozema https://github.com/rrozema like that energy distribution card what did you use for that?

— Reply to this email directly, view it on GitHub https://github.com/hif2k1/battery_sim/issues/83#issuecomment-1688958979, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANKYDWM7DSX4LQC7CAAHTDXWUQKZANCNFSM6AAAAAA2PUTYXQ . You are receiving this because you were mentioned.Message ID: @.***>

hif2k1 commented 10 months ago

Thanks, will have a look at the sankey charts. I have released an update now (v1.2.0) which should hopefully fix this day/night meter issue (thanks to @Daandamhuis). Let me know if this has resolved the problem.

hif2k1 commented 9 months ago

Hopefully this is resolved with the update. Let me know if not.