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

In 2-tariff mode 2 simulated grid sensor sets are needed #82

Closed rrozema closed 7 months ago

rrozema commented 1 year ago

I've got different day-time and night-time (+ weekends) tariffs, for each tariff there are 2 separate meters: one for import from the grid plus one for export to the grid: 4 meters in total for grid energy usage & production. Even though the battery_sim correctly allows to configure the 2-in-2-out scenario with all my 4 sensors, it provides only 1 set of simulated import and export sensors. I can therefor not correctly simulate my house holds' energy usage. Can you please add the missing simulated grid tariff 2 sensors?

I found that #74 seems to be talking about exactly what I am asking for, so this could in fact be a duplicate. But I only see a single pair of simulated sensors created in version 1.105 of the integration. I would expect 2 pairs to be available because I selected the 2-tariff mode and entered the 4 sensors reporting my in- and outgoing energy for 2 tariffs.

hif2k1 commented 10 months ago

Thanks for the request. I think we are having some bugs with the 2 in 2 out which should be resolved shortly, but we've been focusing on that for now.

Just to be clear are you asking for (a) tariff (money/energy unit) inputs for the meters that operate at different times (e.g. night/day) or (b) are you asking for simulated energy export and import sensors for the different times?

If it is (a) then yes that is a good plan and will try to implement once the existing bugs are ironed out. If it is (b) then that is not totally straightforward as the battery collates a number of readings before updating. The simulated meters were added to enable integration into the energy dashboard and for most applications a single pair is fine for this. I can work on it, but it's probably not as much of a priority.

rrozema commented 10 months ago

I think you're right that currently 2 in 2 out does not work correctly: the 2nd tarif's sensors seem not to get stored into the config resulting in the simulated battery only to respond to inputs during the 1st tarif time window. During the 2nd tarif's time frame the battery will neither charge nor discharge automatically. That bug is however reported as another issue.

My request here is to have the exact same number of simulated im- and export sensors as the number of real im- and export sensors in the system so that the simulated im- and export sensors can be used as a drop-in replacement in any representation. I think this is your scenario (b).

For example in 1 in 1 out mode 2 simulated sensors should be created and in 2 in 2 out mode 4 simulated sensors should be created. The prices for energy im- and exported into each of the sensors will be different, hence it is important to include in the simulation during which tarif period the im- and export took place.

I do see how this can complicate your code. But I still think it is needed to do a proper simulation of how much money can be made/lost where the energy contract has multiple tarifs.

I think the energy dashboard is less suited for simulation purposes as HA doesn't allow to create a 2nd instance of such energy dashboard with different sensors specified. Plus, every time you change the energy dashboard's settings you risk losing your historical data of your actual system. So instead of the energy dashboard I use the Sankey chart card to show multiple scenarios above each other in one page. I think this helps making a proper comparison between my actual system and one or more simulated battery systems using my actual data. For now I ignore any tariff cost differences by summing both tarif's usages but I would very much like to include the costs and savings in my simulations too.

Op di 22 aug. 2023 23:26 schreef hif2k1 @.***>:

Thanks for the request. I think we are having some bugs with the 2 in 2 out which should be resolved shortly, but we've been focusing on that for now.

Just to be clear are you asking for (a) tariff (money/energy unit) inputs for the meters that operate at different times (e.g. night/day) or (b) are you asking for simulated energy export and import sensors for the different times?

If it is (a) then yes that is a good plan and will try to implement once the existing bugs are ironed out. If it is (b) then that is not totally straightforward as the battery collates a number of readings before updating. The simulated meters were added to enable integration into the energy dashboard and for most applications a single pair is fine for this. I can work on it, but it's probably not as much of a priority.

— Reply to this email directly, view it on GitHub https://github.com/hif2k1/battery_sim/issues/82#issuecomment-1688954641, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANKYDSPFBMC5F5SFMUGP23XWUPZXANCNFSM6AAAAAAZ4ZX4DE . You are receiving this because you authored the thread.Message ID: @.***>

hif2k1 commented 10 months ago

Ok, I will work on it.

rrozema commented 10 months ago

Currently adding a new integration after installing the latest version (v1.2.0). After selecting two_import_two_export scenario, plus the price is in a sensor scenario I see that I can now correctly select 4 sensors for the consumption and production (2 for each). The tariff sensors dialog however still only allows for the selection of 2 sensors. I think this dialog should ask for 4 sensors as well when two_import_two_export is selected: image I checked the entry created in core.config_entries, and this now correctly lists the 4 energy sensors, there are however only 2 price sensors (as expected, since the dialog did not let me select the 2nd pair).

      {
        "entry_id": "e1599ecdf8afda2be598ebc24d3136a2",
        "version": 1,
        "domain": "battery_sim",
        "title": "battery_sim: Enphase 5P (3rd Gen)",
        "data": {
          "size_kwh": 5.0,
          "max_discharge_rate_kw": 5.7,
          "max_charge_rate_kw": 3.84,
          "efficiency": 0.9,
          "setup_type": "config_flow",
          "name": "battery_sim: Enphase 5P (3rd Gen)",
          "type_of_energy_meter": "two_import_two_export",
          "tariff_type": "Sensors that track tariffs",
          "import_sensor": "sensor.electricity_meter_energy_consumption_tarif_1",
          "export_sensor": "sensor.electricity_meter_energy_production_tarif_1",
          "second_import_sensor": "sensor.electricity_meter_energy_consumption_tarif_2",
          "second_export_sensor": "sensor.electricity_meter_energy_production_tarif_2",
          "energy_import_tariff": "input_number.electricity_meter_energy_consumption_tarif_1_price",
          "energy_export_tariff": "input_number.electricity_meter_energy_production_tarif_1_price"
        },
        "options": {},
        "pref_disable_new_entities": false,
        "pref_disable_polling": false,
        "source": "user",
        "unique_id": "battery_sim: Enphase 5P (3rd Gen)",
        "disabled_by": null
      }

The sensors list in the integrations screen however still shows only 2 simulated sensors created for this new battery. I expected 4 simulated sensors to be created, so I can use them as an in-place replacement for my 4 real energy sensors in the simulated chart cards: image

I will check on monday (weekend has a single tariff only) and let you know if this new battery now responds correctly to both import sensors (which is actually testing #74, not this one).

hif2k1 commented 7 months ago

This should be resolved in the latest release, now each meter has it's own separate tariff information and simulated sensor.