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

Can't get component to work, values remain 0 #39

Closed timh77 closed 1 year ago

timh77 commented 1 year ago

Hi!

Tried to add the battery_sim component yesterday and today but eventhough I think I followed the manual correctly all values remain 0 and the status remains "discharging". Hope anyone has an idea.

The data source is a utility meter (DSMR integration) which has import and export sensors for two tariffs. I added a template sensor to calculate the total import and export. Result is two sensors which are updated thoughout the day.

The error log remains empty. Below the configuration which I copied from the core.config_entries file.

      {
        "entry_id": "dd6d2150a9bfbfe686bf6525cbef0c49",
        "version": 1,
        "domain": "battery_sim",
        "title": "battery_sim: 10.0_kWh_battery",
        "data": {
          "size_kwh": 10.0,
          "max_discharge_rate_kw": 4.4,
          "max_charge_rate_kw": 4.4,
          "efficiency": 0.88,
          "name": "battery_sim: 10.0_kWh_battery",
          "import_sensor": "sensor.total_electricity_consumption",
          "export_sensor": "sensor.total_electicity_production",
          "energy_tariff": "sensor.energy_current_hour",
          "setup_type": "config_flow"
        },
        "options": {},
        "pref_disable_new_entities": false,
        "pref_disable_polling": false,
        "source": "user",
        "unique_id": "battery_sim: 10.0_kWh_battery",
        "disabled_by": null
      }
emkookmer commented 1 year ago

Hi,

Can you add you definition of the template sensors ❓

hif2k1 commented 1 year ago

Yes would be helpful to know more about the template sensors as they may not be triggering the battery to update. You can also get more information by getting the debug log from the battery_sim by adding:

logger:
  default: critical
  logs:
    custom_components.battery_sim: debug

to your configuration.yaml and then restarting. If you leave it to run for a few minutes go to logs then and click "load full log" you should see entries from the battery saying it's been set up and then each time it receives an update. You could paste the output here then we can maybe say more.

Thanks

timh77 commented 1 year ago

Pretty weird... All of a sudden it started to work fine during the weekend. The battery is being charged/discharged like it should.

As for the template sensors, I have two. The first is to get the total consumption by adding the two tarif sensors. The second for the total production. I checked both sensors during the week and they were updated correctly throughout the day.

  total_electricity_consumption:
    value_template: >
      {{ states('sensor.energy_consumption_tarif_1') | float +
         states('sensor.energy_consumption_tarif_2') | float }}
    unit_of_measurement: 'kWh'
    friendly_name: "Total Electricity Consumption"

  total_electicity_production:
    value_template: >
      {{ states('sensor.energy_production_tarif_1') | float +
         states('sensor.energy_production_tarif_2') | float }}
    unit_of_measurement: 'kWh'
    friendly_name: "Total Electricity Production"
hif2k1 commented 1 year ago

That is very strange. Glad it's working now. Let us know if it stops working again.

r13ssh commented 1 year ago

I had a similar issue with nothing happening, even if I set "override charge" to True.

After bouncing HA one more time after setting up the custom battery (in my case) it now started working... 

Just putting this out there if anyone runs into a similar issue.