Solaredge Modbus Configuration for Single Inverter and Battery

@Remko

Could I suggest you look at my code here and maybe fork it for your improvements (happy for your version to be the main one and for me to refork from you), I’ve broken up the package to make it more (imo) maintainable and customisable for others as a single file is too hard to manage.

Also with it being it github it would be easier update as each commit is tracked so people can see exactly what has changed and they can fork and make local changes that maybe arent relevant to you.

Only suggesting this as trying to follow this 6m thread of changes and copy paste without diffs is rather frustrating especially when there is a way that is effectively a global standard for managing code.

Feel free to ignore me though :slight_smile: there’s no hard feelings if you do :slight_smile:

EDIT:
PS Happy to help you if you are unfamiliar with Github and version control.

1 Like

@ryanm101

Great idea. I’m starting to lose track of all the changes too. Keeping a master version in Github with version control is definitely the way to go.

I’ve just merged a PR from someone with fixes for battery effectiveness and power. Bugfixes by treynaer · Pull Request #3 · ryanm101/hasolarcfg · GitHub

Feel free to raise PRs against mine and if @remko wants to own it i’ll happily grant it back to him… I’ve updated the readme to ensure credit goes to the correct person.

Thanks for this!! I fully agree Github is the way to go, I just never created my own project there. I actually currently do not have that much time to manage this, so I am perfectly happy with using your Github as the master. I will update the first post to reference your code

no worries just send me a DM with your username for Github and i can add you with perms on the repo if you want.

@ryanm101

I’m pleased to report that that works :+1:

I now need to look at other sections where both inverter values are used and combine them in the variable states.

1 Like

This bit seems weird…

as there is circular logic.

When I made it I am sure I had a reason for it. I think it had something to do with restoring the state after a reboot, or when something becomes unavailable, but looking at it now… I have to agree it looks weird. It can probably just be taken out.

I’ve updated the readme to add some warnings (most esp about automations) and additional info

Just looked over your repo (sorry, is that short for repository? I’m pretty new to this).

Looks really good. Like the way you’ve split it into packages and created additional templates for things like “battery time to charge” and “battery status info” etc. Also like the additional tariff sections. I need to incorporate some of that into mine to factor in our Octopus Go rates.

Just a question on packages if I may. I currently have everything in a single energy.yaml file which is called from my config.yaml thus:

homeassistant:
  packages: !include_dir_named packages

I presume that if I want to use one of your packages I simpy add it to the packages folder and remove the corresponding code from the energy.yaml?

Is there a way I can do that in a ‘test’ environment without changing the ‘live’ code?

Thanks and brilliant work both @ryanm101 and @Remko

repo (sorry, is that short for repository?

Yup

I presume that if I want to use one of your packages I simpy add it to the packages folder and remove the corresponding code from the energy.yaml ?

Yup

Is there a way I can do that in a ‘test’ environment without changing the ‘live’ code?

Only by spinning up another HA instance, eg using docker on your local laptop.

There is an issue with the time to discharge i think… or charge time… one of them is suspect and i’ve not had a chance to delve into it.

1 Like

Thank you that’s a good tip, I’ll give that a go.

Hi Dave, by chance I installed the HA Update 2023.3.5 last night which fixed the issues.

Just back to the extra digits to sort e.g. Battery % is 43.238% which I’ve got an idea how to fix reading through these posts, so going to try that as well as using the Template Editor.

I looked at it again and there is actually no circular logic.

    {% set battery_effectiveness = states('sensor.solar_battery_effectiveness') %}

          
    {% if (is_state('sensor.solar_battery_effectiveness', 'unavailable') or is_state('sensor.solar_battery_effectiveness', 'unknown') or (battery_effectiveness == 0)) %}
      1
    {% elif (i1_dc_power + b1_dc_power <= 0) %}
      {% if (b1_dc_power >= 0 or i1_dc_power <= 0) %}
        {{ battery_effectiveness }}
      {% else %}
        {{ (1 - ((b1_dc_power * -1 - (i1_dc_power)) / b1_dc_power * -1)) }}
      {% endif %} 
    {% else %}

In the inital “set” I define ‘battery_effectivness’ which is used in the if then else statements. I basically read the ‘solar_battery_effectivness’ into the variable used in the lower statements.

You are correct i’m a muppet I misread the unique_id … DOH!

@Remko It might be worth either creating a 2nd repo or adding a dir called Views to this one and then we can manage the frontend code the same way… I’ve purposefully not do that with your as my dash is different and still not really what i want it to look like.

You could create a new template sensor and for the value template just add {{ states('sensor.solaredge_b1_state_of_energy') | round(2) }} to it then use the new sensor for the card

Yep, good idea. I’ll create a subfolder in my fork as well and update my readme with some pictures as well

Always nice to hear that someone managed to upgrade HA without any issues :grin:

Glad you got it sorted.

If you figure out how to reduce the number of decimals in the battery state of energy, let me know. The Gauge Card is okay, but the Power Distribution and Tesla Like Flow Card both show battery state of energy to umpteen decimals. Since they all use the same entity, and that entity is set to 1 decimal place by default, I can’t figure out why.

I’m in the same boat. I’m only getting production values. Any updates on this scenario or am I out of luck?

image