hif2k1 / battery_sim

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

Battery not working #3

Closed elRadix closed 2 years ago

elRadix commented 2 years ago

I added both sensor but nothing is happening, those are the sensor that used in the energy consumption and both are in kWh. Both are created from a template sensor coming from an utility meter as basis. I am using a P1 meter to collect the data. see below config and screenshot

battery_sim:
  tesla_powerwall:
    name: Tesla Powerwall
    import_sensor: sensor.daily_energy
    export_sensor: sensor.daily_injection
    size_kwh: 13.5
    max_discharge_rate_kw: 5.0
    max_charge_rate_kw: 3.68
    efficiency: 0.9

 utility_meter:
  daily_energy_peak:
    source: sensor.p1_meter_total_power_import_t1
    cycle: daily
  daily_energy_offpeak:
    source: sensor.p1_meter_total_power_import_t2
    cycle: daily
  daily_injection_peak:
    source: sensor.p1_meter_total_power_export_t1
    cycle: daily
  daily_injection_offpeak:
    source: sensor.p1_meter_total_power_export_t2
    cycle: daily

sensor:
  - platform: template
    sensors:

      daily_energy:
        friendly_name: Daily Energy
        unique_id: daily_energy
        unit_of_measurement: kWh
        device_class: energy
        value_template: "{{ (states('sensor.daily_energy_offpeak')|float(0) + states('sensor.daily_energy_peak')|float(0)) | round(3)}}"

      daily_injection:
        friendly_name: Daily Injection
        unique_id: daily_injection
        unit_of_measurement: kWh
        device_class: energy
        value_template: "{{ (states('sensor.daily_injection_peak')|float(0) + states('sensor.daily_injection_offpeak')|float(0)) | round(3) }}"

SmartSelect_20211022-131821_Chrome

browetd commented 2 years ago

Exactly the same issue... It is in my case indicating correctly if the battery should charge or discharge but the curve is definitely flat at zero...

hif2k1 commented 2 years ago

Well I'm really glad people are interested in my extension! Thank you for the feedback. I'm guessing it's something to do with the sensor data maybe. Can you post any of the meter readings? How often are the readings from the utility meter, are the positive or negative? Are they in kwh?

elRadix commented 2 years ago

yes they are both getting real time updates and are both positive

export sensor SmartSelect_20211022-183627_Chrome

import sensor SmartSelect_20211022-183520_Chrome

hif2k1 commented 2 years ago

Ok, I'll have a think.

hif2k1 commented 2 years ago

I think I might have fixed the bug. Can you update the integration and try again? If it's still not working then let me know. Thanks.

elRadix commented 2 years ago

Ok, I'll let you know tomorrow when the sun is back.

NBS1997 commented 2 years ago

This is a great project by the way, but i had to make a few Tweaks the sensor/py to get things to register and they may relevant to the above.

My Import/Export is live (second-by-second) kWh and noticed that the battery would charge/discharge well when there was large amounts of Energy moving. But the slight overnight discharge or when the generation was near equal to consumption was not being registered.

I increased the Float for the round from 2 up to 10 digits and now the Battery discharges at a much better rate. image

RalfPfitzner commented 2 years ago

(Almost) No discharge over night was the same thing that occured to my installation as well.

Well test with the new rounding setting from NBS 1997.

Yorik-Code commented 2 years ago

Similar here, came here to post something similar. Even took screenshots to see if it will help. I will also test now.

Yorik-Code commented 2 years ago

With these changes, mine is now working as expected. It is creating some very long outputs in terms of decimal places, but it is working nicely.

This is a great project by the way, but i had to make a few Tweaks the sensor/py to get things to register and they may relevant to the above.

My Import/Export is live (second-by-second) kWh and noticed that the battery would charge/discharge well when there was large amounts of Energy moving. But the slight overnight discharge or when the generation was near equal to consumption was not being registered.

I increased the Float for the round from 2 up to 10 digits and now the Battery discharges at a much better rate. image

hif2k1 commented 2 years ago

Similar here, came here to post something similar. Even took screenshots to see if it will help. I will also test now.

This is a different issue so I've opened a new issue for this and tried to implement a fix

hif2k1 commented 2 years ago

Ok, I'll let you know tomorrow when the sun is back. @elRadix Is it working for you now? Thanks,

elRadix commented 2 years ago

with the latest update, the battery is now working

elRadix commented 2 years ago

SmartSelect_20211028-001157_Chrome

created a template sensor

      battery_energy_saved_lg16kw:
        friendly_name: Battery Energy Saved LG16KW
        unit_of_measurement: kWh
        device_class: energy 
        value_template: '{{ (states.sensor.lg_chem_prime_16_kw.attributes.energy_saved

and then some battery utility meter for battery In and out

   battery_sim_daily_lg16kw_in:
    source: sensor.lg_chem_prime_16_kw
    cycle: daily
  battery_sim_monthly_lg16kw_out:
    source: sensor.lg_chem_prime_16_kw
    cycle: monthly

  battery_sim_daily_lg16kw_out:
    source: sensor.battery_energy_saved_lg16kw
    cycle: daily
  battery_sim_monthly_lg16kw_out:
    source: sensor.battery_energy_saved_lg16kw
    cycle: monthly
TheGreatHorla commented 2 years ago

@elRadix : stupid question but how do you make a card with the attributes visible like in your first post?

hif2k1 commented 2 years ago

I don't think that's a card, I think it's the entity view. If you go to configuration, entities and find the entity on the list and then click the sliders button in the top right. You can then expand the attributes section at the bottom.

elRadix commented 2 years ago

you can this card


  type: custom:entity-attributes-card
  title: LG Battery 16KW
  heading_name: List
  heading_state: States
  filter:
    include:
      - key: sensor.lg_chem_prime_16_kw.*
    exclude:
      - key: sensor.lg_chem_prime_16_kw.d*
      - key: sensor.lg_chem_prime_16_kw.f*
      - key: sensor.lg_chem_prime_16_kw.i*
      - key: sensor.lg_chem_prime_16_kw.state*
      - key: sensor.lg_chem_prime_16_kw.u*`

SmartSelect_20211118-103100_Chrome

https://github.com/custom-cards/entity-attributes-card

TheGreatHorla commented 2 years ago

@elRadix : Perfect! Thank you. image

BinnenBeest commented 2 years ago

SmartSelect_20211028-001157_Chrome

created a template sensor

      battery_energy_saved_lg16kw:
        friendly_name: Battery Energy Saved LG16KW
        unit_of_measurement: kWh
        device_class: energy 
        value_template: '{{ (states.sensor.lg_chem_prime_16_kw.attributes.energy_saved

and then some battery utility meter for battery In and out

   battery_sim_daily_lg16kw_in:
    source: sensor.lg_chem_prime_16_kw
    cycle: daily
  battery_sim_monthly_lg16kw_out:
    source: sensor.lg_chem_prime_16_kw
    cycle: monthly

  battery_sim_daily_lg16kw_out:
    source: sensor.battery_energy_saved_lg16kw
    cycle: daily
  battery_sim_monthly_lg16kw_out:
    source: sensor.battery_energy_saved_lg16kw
    cycle: monthly

Can you give more insight in how you did create this sensors and screenshot how you implemented this in Energy Management? I rather novice in writing yaml.

hif2k1 commented 2 years ago

I've now added charging and discharging rates and daily energy counter to the attributes. I hope this will make this a bit simpler. Thinking about adding them as separate sensors rather than just attributes as well. What do you think?

TheGreatHorla commented 2 years ago

@hif2k1 : In my opinion it would be easier to have almost all the attributes as another sensor. I (and I imagine most of the users) use it to see if a home battery is a usefull investment (in the winter the answer is no for me it seems unless I expand my solar panels greatly). I used Elradix template to view all attributes because only the battery percentage is fairly useless. I would be easier for users from HA like me who doesn't write complicated automatisations but just use a couple of integrations and expect it to 'just' work.

amanimmortal commented 2 years ago

SmartSelect_20211028-001157_Chrome created a template sensor

      battery_energy_saved_lg16kw:
        friendly_name: Battery Energy Saved LG16KW
        unit_of_measurement: kWh
        device_class: energy 
        value_template: '{{ (states.sensor.lg_chem_prime_16_kw.attributes.energy_saved

and then some battery utility meter for battery In and out

   battery_sim_daily_lg16kw_in:
    source: sensor.lg_chem_prime_16_kw
    cycle: daily
  battery_sim_monthly_lg16kw_out:
    source: sensor.lg_chem_prime_16_kw
    cycle: monthly

  battery_sim_daily_lg16kw_out:
    source: sensor.battery_energy_saved_lg16kw
    cycle: daily
  battery_sim_monthly_lg16kw_out:
    source: sensor.battery_energy_saved_lg16kw
    cycle: monthly

Can you give more insight in how you did create this sensors and screenshot how you implemented this in Energy Management? I rather novice in writing yaml.

In answer to this question, this is what I have setup to get this working. Note that the attributes now include a "daily energy saved" so most likely you could use that instead of setting up a daily/monthly utility meter, but I have done it this way as I adapted it from the old method.

You'll have to specify your own sensor for the input data, mine being sensor.tesla_powerwall so just replace my instances of that with whatever your own battery shows up as.

sensor:
  - platform: template
    sensors:
      battery_energy_saved_tp:
        friendly_name: Battery Energy Saved Tesla Powerwall
        unit_of_measurement: kWh
        device_class: energy
        value_template: '{{ (states.sensor.tesla_powerwall.attributes.total_energy_saved) }}'

utility_meter:
  battery_sim_daily_tp_in:
    source: sensor.tesla_powerwall
    cycle: daily
  battery_sim_monthly_tp_in:
    source: sensor.tesla_powerwall
    cycle: monthly
  battery_sim_daily_tp_out:
    source: sensor.battery_energy_saved_tp
    cycle: daily
  battery_sim_monthly_tp_out:
    source: sensor.battery_energy_saved_tp
    cycle: monthly
purcell-lab commented 2 years ago

I've now added charging and discharging rates and daily energy counter to the attributes. I hope this will make this a bit simpler. Thinking about adding them as separate sensors rather than just attributes as well. What do you think?

Yes please.

Different sensors would make it a lot simpler to utilise.

Sensors that can feed the energy dashboard directly would be ideal.

Screenshot_20220206-194720

BinnenBeest commented 2 years ago

I've now added charging and discharging rates and daily energy counter to the attributes. I hope this will make this a bit simpler. Thinking about adding them as separate sensors rather than just attributes as well. What do you think?

Yes please.

Different sensors would make it a lot simpler to utilise.

Sensors that can feed the energy dashboard directly would be ideal.

Screenshot_20220206-194720

Fully agree with that. My goal is to test the simulation for a longer period to determine if the ROI is feasible.

hif2k1 commented 2 years ago

OK, thanks. I'm just testing a release of multiple sensors/entities. Had a few bugs, but should be ready soon.

On Sun, 6 Feb 2022, 09:59 Geert van BinnenBeest.be, < @.***> wrote:

I've now added charging and discharging rates and daily energy counter to the attributes. I hope this will make this a bit simpler. Thinking about adding them as separate sensors rather than just attributes as well. What do you think?

Yes please.

Different sensors would make it a lot simpler to utilise.

Sensors that can feed the energy dashboard directly would be ideal.

[image: Screenshot_20220206-194720] https://user-images.githubusercontent.com/79175134/152675472-52409103-035f-42e0-b688-588feb1862d5.png

Fully agree with that. My goal is to test the simulation for a longer period to determine if the ROI is feasible.

— Reply to this email directly, view it on GitHub https://github.com/hif2k1/battery_sim/issues/3#issuecomment-1030798879, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFAIZGIV7CHWWN4FYAYJYXLUZZBB3ANCNFSM5GQJYTBA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

hif2k1 commented 2 years ago

Latest release has individual sensors for most attributes. Haven't got one for money saved yet because I need to figure out how to handle the units, but will try to do this too.

BinnenBeest commented 2 years ago

Latest release has individual sensors for most attributes. Haven't got one for money saved yet because I need to figure out how to handle the units, but will try to do this too.

To explain myself I doubt that it’s feasible to invest in a LG Chem battery infrastructure. Measurement and simulation can help me to determine the feasibility. So I only need to know the amounts of kWh I can save on one year.