solmoller / eversolar-monitor

Script to capture data and create statistics from Eversolar/zeversolar Solar Inverters. Includes easy install image files for Raspberry Pi. Working edition since 2012 :-)
https://github.com/solmoller/eversolar-monitor/blob/wiki/Introduction.md
MIT License
30 stars 20 forks source link

Full integration with the new Home Assistant 'Energy' tab #59

Open solmoller opened 2 years ago

solmoller commented 2 years ago

The integration to HA is good, but we should look into a full and automated integration

sorentorp commented 2 years ago

Yay - great idea!

LeighAS commented 2 years ago

Hey peeps, spent some time tonight getting Home assistant setup on my rp3. Installed mosquitto mqtt broker addon and configured it, then altered my ini file to match on the eversolar rpi. image image

I don't seem to be able to hear anything the eversolar monitor is publishing from the mqtt broker. what am I missing?

LeighAS commented 2 years ago

sudo apt install -y mosquitto mosquitto-clients

just read this in the comments of the perl script. definitely missed that. also now the sun is down i think i'm missing the light too.

LeighAS commented 2 years ago

image managed to send a message from the clients cmd line and received it in homeassistant so its looking promising now for tomorrow when the sun comes up, hoping auto discovery works

LeighAS commented 2 years ago

has been working since this morning except I think there may still be issues regarding running 2 inverters through one pi.

image so this is the webpage vs home assistant. the daily total so far appears correct but the combined instantaneous power is incorrect, this would be a useful metric to have so as to use for storing power.

My shelly EM arrived today and that can give me the import/export values for the whole house combined so I will be most likely using those values for turning on loads i.e. batteries or turning up a hybrid inverter if the sun is not out and I am importing.

Thankfully pvoutput is correct as this is summed/aggregated on the website after being sent up via two separate api calls.

I am really impressed with all the improvements. Thanks for everyone's hard work here.

nagydavid commented 2 years ago

I am going on holiday, so I will have time to tinker, can you please guide me, what additional integration you would like with home assistant? @solmoller

LeighAS commented 2 years ago

image managed to create a binary sensor in home assist today (PV monitor disconnected) which will detect whether the last update time was over 45 secs ago. This should be a quick way of me finding out at a glance whether the usb to rs485 stick as been disturbed and is no longer collecting infos. I think this has been the issue since the start and today was the first time this had broken since sorting out the inverters both onto a single rpi on the same rs485 bus. The reason i caught it was that i had shifted a 12v battery for charging and that was under the rpi which was then an obvious timestamp for me to show why id stopped getting solar data. Anyway i should be able to automate some trigger to notify me when this sensor changes outside of night time hours.

nagydavid commented 2 years ago

I have modified the mqtt messages in order to be inline with the timestamp requirements of home assistant. I will update my code somewhere in this week.image

LeighAS commented 2 years ago

nice, that will break my new pv connected widget but its a better way to have it. As an aside The setting page of my binary sensor gives a nice depiction of the uptime of the inverters in green for on and red for off. I can always update the yaml template to adapt to these changes.

image

@nagydavid Any chance you could have a look at the multiple inverters bug for totals? I have got a 3rd eversolar inverter on the way so will be able to test with all 3 eventually

nagydavid commented 2 years ago

Well I only have one inverter, but if you manage to print out the inverters value into a json I will be able to look into it. @solmoller Any suggestions to do that?

solmoller commented 2 years ago

I'll look at it when other projects permit :-)

LeighAS commented 1 year ago

just found a work around for now to my energy dash board issue with the mqtt from the eversolar monitor not being formatted exactly as home assistant expects.

image the combined energy which is the summation of the 2 inverters by the perl code sent via mqtt doesnt have a last_reset.

instead i've found that i can use pvoutput.org integration and that gives me accurate summation of the solar albeit having to round trip the data to and from the pvoutput servers. Its also added together by pvoutput.org.

also in re investigating this i've realised that you can add multiple solar sources and home assistant energy bar graphs end up stacked, so using sensor.pv_total_energy_production and sensor.pv_total_energy_production_2 as inputs i now get accurate totals and nicely stacked graphs. image

Timdebruijn commented 8 months ago

I have modified the mqtt messages in order to be inline with the timestamp requirements of home assistant. I will update my code somewhere in this week.image

Hi! What did you change to get this working? Looks like it's still broken(fresh install)

nagydavid commented 8 months ago

i need to look in to that it was long time ago

Timdebruijn commented 8 months ago

I Think it had something to do with the formatting of the timestamp, currently it's something like: 2024-01-18 17:25:16 But maybe it has to be correctly formatted in ISO 8601: 2024-01-18T17:25:16Z

I've already tried that, but not with any succes.. on line 831: sub get_timestamp { ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime(time); return sprintf( "%04d-%02d-%02dT%02d:%02d:%02dZ", $year + 1900, $mon + 1, $mday, $hour, $min, $sec ); }

Timdebruijn commented 8 months ago

@nagydavid I've tried many things like:

use POSIX qw(strftime);

sub get_timestamp {
    my $timestamp = strftime("%Y-%m-%dT%H:%M:%S%z", localtime(time));
    return $timestamp;
}

Or use POSIX qw(strftime); my $timestamp = strftime("%Y-%m-%dT%H:%M:%SZ", gmtime);

But none of this gets the status in Home assisant other than "Unknown"

Do you have any idea in what direction I should look?

nagydavid commented 8 months ago

I just checked my code, and it runs as intended Screenshot 2024-01-19 at 16 58 25

Update

My bad, I forgot to push my code 2 years ago :) Sorry for that. @Timdebruijn grab the latest version

Timdebruijn commented 8 months ago

@nagydavid Thank you so much!!

I think you still need to remove all the extra + symbols..

nagydavid commented 8 months ago

can you be more specific about the symbols?

Timdebruijn commented 8 months ago

@nagydavid If you look at https://github.com/solmoller/eversolar-monitor/blob/81898e6f225c4ce7edd26aeb560b75f49501dcd9/eversolar.pl#L1265

You can see that you've added the + symbols to the code.

nagydavid commented 8 months ago

@Timdebruijn it is fixed.

solmoller commented 7 months ago

I just looked at this today, and my data is present i HA, but not on the energy Dashboard.

nagydavid commented 7 months ago

Funny, I added long time ago and it works beautifully. image

nagydavid commented 7 months ago

@solmoller If you r using the mqtt integration then PV Total Energy Production adheres to the requirements regarding device_class and state_class. So if you add that entity to ur dashboard it should work.

tobiasnorbo commented 5 months ago

Hi Guys, @nagydavid and @Timdebruijn

Could some of you make a pastebin of the changes to the ini file, and maybe discribe the setup of mosquito MQTT broker, so it is easier for people like me to follow in your foot steps and start improving on what has already been created?

Would be highly appreciated.

Thanks :)

solmoller commented 5 months ago

GitHub can compare the file versions for you :-)

Br Henrik

tors. 2. maj 2024 22.21 skrev tobiasnorbo @.***>:

Hi Guys, @nagydavid https://github.com/nagydavid and @Timdebruijn https://github.com/Timdebruijn

Could some of you make a pastebin of the changes to the ini file, and maybe discribe the setup of mosquito MQTT broker, so it is easier for people like me to follow in your foot steps and start improving on what has already been created?

Would be highly appreciated.

Thanks :)

— Reply to this email directly, view it on GitHub https://github.com/solmoller/eversolar-monitor/issues/59#issuecomment-2091489688, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQL6ED7TOGISOGPQNNLJNDZAKN6DAVCNFSM5Y4MA6L2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBZGE2DQOJWHA4A . You are receiving this because you were mentioned.Message ID: @.***>

tobiasnorbo commented 5 months ago

sudo apt install -y mosquitto mosquitto-clients

just read this in the comments of the perl script. definitely missed that. also now the sun is down i think i'm missing the light too.

I am not able to install this on the RPI2, that I am running the script on. Also I have to write: sudo apt-get install -y mosquitto mosquitto-clients

Screenshot 2024-05-03 at 20 08 12
nagydavid commented 5 months ago

@tobiasnorbo it is written in your error message: update or do the fix missing. By the way if you have some linux related problem, try chatgpt it is quite good pointing you the answer. Just copy the full answer and it will tell you in detail, what you should do.

tobiasnorbo commented 5 months ago

Sorry, I should have written that as well. This is the messages I get when trying to update and fix. Doesn't seem to work.

If you have a tip please let me know. otherwise I will get chatgpt to help.

Screenshot 2024-05-03 at 20 30 00
tobiasnorbo commented 5 months ago

Just an update for anybody getting to this point as well. If you consider using the software in HA, then you cannot use the img file. You will need an up to date OS.

Therefore I will suggest to run it on a PC, that are also running your HA instance or a newer RPI, since you need to go through the full process anyways, if you wish to go for HA integration.

If you do this, please consider making a img file for a newer RPI, which can be used for future users of the software. I'm not sure people will go for a RPI2 in the future, knowing this, so I will not make an img file for my RPI2 setup, when it is up and running.