hif2k1 / battery_sim

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

Installation documentation is missing #2

Closed RalfPfitzner closed 2 years ago

RalfPfitzner commented 2 years ago

It would be really great if any installation instruction would be provided.

I'm just searching in the darkness for some light to make this integration work at all.

browetd commented 2 years ago

Agree ... wonderful idea having this battery sim, I was looking for it... but the integration is showing "charging" or "discharging" but the energy saved is still 0... and the battery charged is still null as well... Help !

Plawasan commented 2 years ago

This is a great idea but same as others, I'm struggling with config. Here's my use case: I have two power sensors configured:

Both are power sensors (i.e. kW) however I do also have energy meters created for both (kWh).

What I was expecting would happen is that if solar is producing more (e.g. 2000W) than what I'm currently consuming (e.g. 700W) the battery would be "charged" with 1300W of power, if then solar stops, the battery will discharge at 700W - hope that's sound.

This is my current config:

battery_sim:
  home_battery:
    name: Home Battery Sim
    export_sensor: sensor.power_production_now
    import_sensor: sensor.power_meter_watts
    size_kwh: 7.5
    max_discharge_rate_kw: 5.0
    max_charge_rate_kw: 3.68
    efficiency: 0.9

I tried different combinations of import/export (which is a bit confusing honestly), still couldn't really figure out what the correct config would be for the hopefully correct logic described above to apply...

Edit: I re-read the instructions, updated config to the use the energy meters rather than power meters, swapped import/export (still think it's confusing), the battery is "charging" now which is consistent with solar generating more than what I'm consuming - let's see if that correctly reverses tonight when solar drops off.

battery_sim:
  home_battery:
    name: Home Battery Sim
    import_sensor: sensor.solar_energy
    export_sensor: sensor.energy_meter
    size_kwh: 7.5
    max_discharge_rate_kw: 5.0
    max_charge_rate_kw: 3.68
    efficiency: 0.9
Plawasan commented 2 years ago

And the answer is no, it doesn't :)

This is what I get, the battery starts correctly charging, but then even when solar generation drops off it never discharges: image

Anyway, I liked the idea so much I replicated it with just a couple helpers and template sensors and that gives me exactly the output expected from the integration, see the "helper" line

image

I would still very much prefer to use the integration as my solution is rather hacky, my python skills aren't exactly up-to-date so all i can offer is help with testing/validating the logic.

Thanks!

hif2k1 commented 2 years ago

Agree ... wonderful idea having this battery sim, I was looking for it... but the integration is showing "charging" or "discharging" but the energy saved is still 0... and the battery charged is still null as well... Help !

I think this is the same as this issue #3 which I may now have fixed, but I'm not sure. Anyway if you keep an eye on the other thread hopefully we'll get it sorter out.

hif2k1 commented 2 years ago

This is a great idea but same as others, I'm struggling with config. Here's my use case: I have two power sensors configured:

  • sensor.power_production_now - measures solar power generation
  • sensor.power_meter_watts - measures the power consumption of the house

Both are power sensors (i.e. kW) however I do also have energy meters created for both (kWh).

What I was expecting would happen is that if solar is producing more (e.g. 2000W) than what I'm currently consuming (e.g. 700W) the battery would be "charged" with 1300W of power, if then solar stops, the battery will discharge at 700W - hope that's sound.

This is my current config:

battery_sim:
  home_battery:
    name: Home Battery Sim
    export_sensor: sensor.power_production_now
    import_sensor: sensor.power_meter_watts
    size_kwh: 7.5
    max_discharge_rate_kw: 5.0
    max_charge_rate_kw: 3.68
    efficiency: 0.9

I tried different combinations of import/export (which is a bit confusing honestly), still couldn't really figure out what the correct config would be for the hopefully correct logic described above to apply...

Edit: I re-read the instructions, updated config to the use the energy meters rather than power meters, swapped import/export (still think it's confusing), the battery is "charging" now which is consistent with solar generating more than what I'm consuming - let's see if that correctly reverses tonight when solar drops off.

battery_sim:
  home_battery:
    name: Home Battery Sim
    import_sensor: sensor.solar_energy
    export_sensor: sensor.energy_meter
    size_kwh: 7.5
    max_discharge_rate_kw: 5.0
    max_charge_rate_kw: 3.68
    efficiency: 0.9

I'm sorry I'm not really understanding what is going on here.

Both import and export should be cumulative energy meters measuring in kWh. It looks like you are using power rather than energy which is probably confusing it. These inputs usually gradually count up as energy is generated or used. I'm glad you've managed to make your own system though, that is clever. I spent ages messing around with template sensors before giving up and deciding I had to make an integration to do this so you obviously understand HA better than me!

Maybe try using energy meters rather than instant power readings and see if that works.

Thanks,

Hamish

hif2k1 commented 2 years ago

It would be really great if any installation instruction would be provided.

I'm just searching in the darkness for some light to make this integration work at all.

Ok, great. Have you looked at the Readme? Once you've installed the integration you need to add whatever configuration you want to use into the HA config file. I've provided some example configurations. I am looking at adding config_flow which is a graphical way to do setup, but I haven't got to grips with it yet.

Plawasan commented 2 years ago

I'm sorry I'm not really understanding what is going on here.

Both import and export should be cumulative energy meters measuring in kWh. It looks like you are using power rather than energy which is probably confusing it. These inputs usually gradually count up as energy is generated or used. I'm glad you've managed to make your own system though, that is clever. I spent ages messing around with template sensors before giving up and deciding I had to make an integration to do this so you obviously understand HA better than me!

Maybe try using energy meters rather than instant power readings and see if that works.

Thanks,

Hamish

I did change my config to energy meters, they are both cumulative numbers that count up.. yet I'm still seeing the results I posted above.

I am more than happy to beta test anything you put together, as I said my solution is a rather hacky, a proper integration is the way to go so I very much appreciate the effort you're putting into making one.

hif2k1 commented 2 years ago

Ok so looking at the graph it looks like the battery is charging up even before there's any solar input. When there is some solar generation the battery actually goes down a bit. I'm guessing you've got the import and export swapped over. Import should be energy your importing from the grid. Export should really be the energy you haven't used from the solar panels that you are sending back to the grid. Try swapping your import and export.

On Sun, Oct 24, 2021, 6:16 PM Plawasan @.***> wrote:

This is a great idea but same as others, I'm struggling with config. Here's my use case: I have two power sensors configured:

  • sensor.power_production_now - measures solar power generation
  • sensor.power_meter_watts - measures the power consumption of the house

Both are power sensors (i.e. kW) however I do also have energy meters created for both (kWh). What I was expecting would happen is that if solar is producing more (e.g. 2000W) than what I'm currently consuming (e.g. 700W) the battery would be "charged" with 1300W of power, if then solar stops, the battery will discharge at 700W - hope that's sound. This is my current config:

battery_sim: home_battery: name: Home Battery Sim export_sensor: sensor.power_production_now import_sensor: sensor.power_meter_watts size_kwh: 7.5 max_discharge_rate_kw: 5.0 max_charge_rate_kw: 3.68 efficiency: 0.9

I tried different combinations of import/export (which is a bit confusing honestly), still couldn't really figure out what the correct config would be for the hopefully correct logic described above to apply... Edit: I re-read the instructions, updated config to the use the energy meters rather than power meters, swapped import/export (still think it's confusing), the battery is "charging" now which is consistent with solar generating more than what I'm consuming - let's see if that correctly reverses tonight when solar drops off.

battery_sim: home_battery: name: Home Battery Sim import_sensor: sensor.solar_energy export_sensor: sensor.energy_meter size_kwh: 7.5 max_discharge_rate_kw: 5.0 max_charge_rate_kw: 3.68 efficiency: 0.9

I'm sorry I'm not really understanding what is going on here.

Both import and export should be cumulative energy meters measuring in kWh. It looks like you are using power rather than energy which is probably confusing it. These inputs usually gradually count up as energy is generated or used. I'm glad you've managed to make your own system though, that is clever. I spent ages messing around with template sensors before giving up and deciding I had to make an integration to do this so you obviously understand HA better than me!

Maybe try using energy meters rather than instant power readings and see if that works.

Thanks,

Hamish

I did change my config to energy meters, they are both cumulative numbers that count up.. yet I'm still seeing the results I posted above.

I am more than happy to beta test anything you put together, as I said my solution is a rather hacky, a proper integration is the way to go so I very much appreciate the effort you're putting into making one.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hif2k1/battery_sim/issues/2#issuecomment-950360877, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFAIZGPSU3AYCHCPSPEWDKTUIQ5PZANCNFSM5GJSH6NQ . 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.

Plawasan commented 2 years ago

Ok so looking at the graph it looks like the battery is charging up even before there's any solar input. When there is some solar generation the battery actually goes down a bit. I'm guessing you've got the import and export swapped over. Import should be energy your importing from the grid. Export should really be the energy you haven't used from the solar panels that you are sending back to the grid. Try swapping your import and export.

I swapped the config last night (exactly at the point where green line starts dropping), here's what I'm seeing now:

my current config:

battery_sim:
  home_battery:
    name: Home Battery Sim
    export_sensor: sensor.solar_energy
    import_sensor: sensor.energy_meter
    size_kwh: 7.5
    max_discharge_rate_kw: 5.0
    max_charge_rate_kw: 3.68
    efficiency: 0.9
elRadix commented 2 years ago

same issue here the graph is even not moving at all

here is my config

battery_sim:
  tesla_powerwall:
    name: Tesla Powerwall 13.5 KW
    import_sensor: sensor.daily_energy # energy your importing from the grid.
    export_sensor: sensor.daily_injection    # energy you haven't used from the solar panels
    size_kwh: 13.5
    max_discharge_rate_kw: 5.0
    max_charge_rate_kw: 3.68
    efficiency: 0.9

see screenshot below SmartSelect_20211025-150318_Chrome SmartSelect_20211025-150359_Chrome

The battery line is not moving at all

hif2k1 commented 2 years ago

Ok so looking at the graph it looks like the battery is charging up even before there's any solar input. When there is some solar generation the battery actually goes down a bit. I'm guessing you've got the import and export swapped over. Import should be energy your importing from the grid. Export should really be the energy you haven't used from the solar panels that you are sending back to the grid. Try swapping your import and export.

I swapped the config last night (exactly at the point where green line starts dropping), here's what I'm seeing now:

  • initially the progress look good
  • ignore the jump in the blue line (my helper-sim), I've updated it to match the value from the integration so that I can see them move together
  • from that point the slope of the green (integration) line and the blue (helper) line is different, possibly due to the fact that I apply efficiency on "charging", i.e. I reduce the power going into the battery, not sure where the integration applies it
  • then at 23:29 the integration changes to a completely different slope for no apparent reason
  • then in the morning the integration shows the battery move up again but at that point solar is still lower than consumption so the battery should still be discharging
  • if it makes any difference my solar power is also simulated, using this integration - https://www.home-assistant.io/integrations/forecast_solar
  • I've included a graph of the input entities so that you can see their progression (they are both on separate y_axis as they have very different absolute values) image

my current config:

battery_sim:
  home_battery:
    name: Home Battery Sim
    export_sensor: sensor.solar_energy
    import_sensor: sensor.energy_meter
    size_kwh: 7.5
    max_discharge_rate_kw: 5.0
    max_charge_rate_kw: 3.68
    efficiency: 0.9

Glad it's working better.

hif2k1 commented 2 years ago

same issue here the graph is even not moving at all

here is my config

battery_sim:
  tesla_powerwall:
    name: Tesla Powerwall 13.5 KW
    import_sensor: sensor.daily_energy # energy your importing from the grid.
    export_sensor: sensor.daily_injection    # energy you haven't used from the solar panels
    size_kwh: 13.5
    max_discharge_rate_kw: 5.0
    max_charge_rate_kw: 3.68
    efficiency: 0.9

see screenshot below SmartSelect_20211025-150318_Chrome SmartSelect_20211025-150359_Chrome

The battery line is not moving at all

What version are you using?

elRadix commented 2 years ago

System Health

version core-2021.10.6
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.9.7
os_name Linux
os_version 5.10.70
arch x86_64
timezone Europe/Brussels
Home Assistant Community Store GitHub API | ok -- | -- Github API Calls Remaining | 5000 Installed Version | 1.15.2 Stage | running Available Repositories | 974 Installed Repositories | 92
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 6.5 -- | -- update_channel | beta supervisor_version | supervisor-2021.10.6 docker_version | 20.10.7 disk_total | 48.5 GB disk_used | 26.3 GB healthy | true supported | true board | ova supervisor_api | ok version_api | ok installed_addons | Terminal & SSH (8.6.0), AppDaemon 4 (0.7.0), WireGuard (0.5.1), Mosquitto broker (6.0.1), Home Assistant Google Drive Backup (0.105.2), SSH & Web Terminal (9.0.1), chrony (2.2.0), InfluxDB (4.2.1), Grafana (7.2.0), AdGuard Home (4.1.9), Portainer (2.0.0), Visual Studio Code (3.6.2), FTP (4.2.1), Portainer (2.9.1-5), Samba share (9.5.1), Filebrowser (2.17.2-7), SSH Tunnel & Forwarding (0.9.8), Papermerge (2.0.1-13)
Lovelace dashboards | 3 -- | -- resources | 51 views | 119 mode | storage
MercedesME 2020 websocket_connection_state | connected -- | -- api_endpoint_reachable | ok
Plawasan commented 2 years ago

Glad it's working better.

Better.. but still not perfect. 2 main issues I see:

hif2k1 commented 2 years ago

System Health

version core-2021.10.6 installation_type Home Assistant OS dev false hassio true docker true user root virtualenv false python_version 3.9.7 os_name Linux os_version 5.10.70 arch x86_64 timezone Europe/Brussels Home Assistant Community Store Home Assistant Cloud Home Assistant Supervisor Lovelace MercedesME 2020

Sorry I meant which version of the battery sim integration are you using - you can see this in HACS

hif2k1 commented 2 years ago

Glad it's working better.

Better.. but still not perfect. 2 main issues I see:

  • the saw pattern in a period where solar output is consistently higher than consumption, i.e. the battery should stay charged (see the helper line) - this seems to correlate with large-step status changes or the simulated solar energy entity, I assume since there is no update in the solar kWh number (but there are continuous updates to consumption) you (correctly...) evaluate that as no power is generated between the updates i.e. the battery needs to discharge. This is obviously more of a problem of the upstream integration (forecast.solar), I overcome it by checking the difference between power generated/consumed every minute, not by checking energy values.
  • the sudden change of discharge rate exactly at midnight - both input entities count up continuously, they don't reset at midnight so that shouldn't play a role.. image

The real issue is that the battery sim isn't meant to work out how much of your solar energy you are using and how much you are exporting - sending to the grid. Do you have an export or injection meter that tells you how much has been sent to the grid rather than just a solar generation meter? Likewise you consumption meter is probably showing your total consumption where ideally you want a meter only measuring what you are importing from the grid. This is because solar energy you generate yourself and use immediately wouldn't go in and out of the battery.

I suppose you could work this out, but it would be complex, particularly with your different update frequencies on the two meters. I think this is outside the scope of the battery sim project.

RalfPfitzner commented 2 years ago

Documentation improved, main "bugs" fixed.