salewis38 / palm

Automations for GivEnergy inverter, sets daily target SoC, schedules API calls and logs data on PVOutput.org
GNU General Public License v3.0
12 stars 5 forks source link

Getting error with latest version? TypeError: can only concatenate str #9

Closed Boffinboy closed 1 year ago

Boffinboy commented 1 year ago

Hi there, I have been running palm_soc very nicely on my Synology in a docker container for a while now. I decided it was time to update with your latest, which now deprecates palm_soc.

Unfortunately I am getting an error, not sure what is causing it. It looks like it is not getting the right load history info? See below what comes up in the log before the container stops: File "/pi/palm/palm_unmodified.py", line 1020, in ge.get_load_hist() File "/pi/palm/palm_unmodified.py", line 202, in get_load_hist logger.error("Invalid response: "+ resp.status_code)


TypeError: can only concatenate str (not "int") to st
salewis38 commented 1 year ago

Hi, should be fixed in today's version... the logger library is quite fussy and I missed a couple of string conversions when I migrated to it... sorry about that. The bothersome line would only be called if palm.py fails to download the load history as you indicate.

Boffinboy commented 1 year ago

Thank you. I will try again. I’m a bit confused why it wouldn’t be able to pull the load data - any ideas what could prevent that? It pulled it no problem in the version I was using previously. Has the way the data is pulled changed? I checked my Givenergy account and API key in the settings file and both seem correct.

salewis38 commented 1 year ago

No changes to how load data is collected. It's possible that you just got unlucky and the GE server wasn't playing.

On Sun, 18 Jun 2023, 07:21 Boffinboy, @.***> wrote:

Thank you. I will try again. I’m a bit confused why it wouldn’t be able to pull the load data - any ideas what could prevent that? It pulled it no problem in the version I was using previously. Has the way the data is pulled changed? I checked my Givenergy account and API key in the settings file and both seem correct.

— Reply to this email directly, view it on GitHub https://github.com/salewis38/palm/issues/9#issuecomment-1595980403, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALAPCY2DKJRF7NNJYUJF22DXL2M5XANCNFSM6AAAAAAZKNJHRM . You are receiving this because you commented.Message ID: @.***>

Boffinboy commented 1 year ago

For whatever reason I still get the same error, even with your latest modifications. Is there a difference in behaviour between palm and palm_soc? I have found in the new version that palm_soc get the data, but palm does not. I am able to successfully use soc, but this is not a long term solution if you are deprecating it.

With palm I can see that it is not pulling the data from GivEnergy when it tries to contact the API (note I am pulling from 7 days before): https://api.givenergy.cloud:443 "GET /v1/inverter/CEMYINVERTER/data-points/2023-06-11?page=1&pageSize=2000 HTTP/1.1" 401 None stdout

I know the API and inverter account number are correct, as they work in the older version of palm_soc I have been using. I did notice in the template settings file there are no longer spaces either side of the key=“APIKEY” - but I have tried adding them both back in and I still have the same issue.

I am also wondering if it’s the logging capability. You may remember I am running on Synology and docker, so if that uses a different package I need to install that in the container. Is there any extra package required vs palm SoC?

salewis38 commented 1 year ago

The 401 error indicates a problem with the authentication credentials that you're sending to the GE server. It's not related to the the 7-day change (tried that) or the logger (it wouldn't get this far).

Downloading palm.py and the template settings.py from Github and editing only the Solcast and GE sections of the file worked as expected here in once mode:

DEBUG:urllib3.connectionpool:https://api.givenergy.cloud:443 "GET /v1/inverter/CExxxx/data-points/2023-06-11?page=1&pageSize=2000 HTTP/1.1" 200 None INFO:PALM:Load Calc Summary: 7.2[0.2, 0.8, 0.2, 0.2, 0.1, 0.0, 0.2, 0.1, 0.1, 0.1, 0.1, 0.2, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.1, 0.3, 0.0, 0.2, 0.1, 0.1, 0.2, 1.3, 1.6, 0.2, 0.3, 0.1, 0.2, 0.2, 0.5, 0.3, 0.5, 0.7, 0.5, 0.9, 0.3, 0.2, 0.3, 0.3, 0.3, 0.2, 0.7, 0.2, 0.3, 0.3]

There are a few differences in the latest settings.py, such as the longer GE.base_load to work with 30-minute calculations, but they would throw a different error.

Please try the above and edit a fresh settings.py with your API key, etc. I would hope that fixes the problem.

Boffinboy commented 1 year ago

Thanks again for looking into this. I did try re-editing the settings.py fresh. Presumably the credentials must be working OK though because palm_soc using the same settings file (not the old version I was using) is able to pull the data fine? To be clear, I downloaded fresh from GitHub, edited settings file and tried running both palm and palm_soc. Soc works, default palm does not. Do the two read or pass through the credentials in a different way from the settings file?

salewis38 commented 1 year ago

The get_load_hist code is identical in both versions... maybe try again in a clean directory/on a different machine?

Going through it tonight, I did spot an unrelated bug, so all was not lost!

Boffinboy commented 1 year ago

Odd! I will try again next weekend, got a bit of a crazy week ahead. Will use the soc version for now. Thanks as usual for helping.

salewis38 commented 1 year ago

No problem. I had some time on my hands yesterday so have improved the historical load forecasting - v0.10.0 reads from a table in settings.py... the forecast consumption now uses a weighted average of arbitrary length, so can easily be set to the same day last week, etc.

Boffinboy commented 1 year ago

Looks like an excellent addition! Hopefully I can find time at weekend to get the standard palm version working.

Boffinboy commented 1 year ago

Seems to be working, will test overnight!

Boffinboy commented 1 year ago

Closing this as all working fine