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

Trouble setting up on synology #2

Closed Boffinboy closed 1 year ago

Boffinboy commented 1 year ago

Sorry to post here - I posted on the forums, but you may not have seen. I finally got my battery installed and whilst I’m on E7 and not Flux I was planning to set up your palm to run on my Synology NAS. Unfortunately I’m struggling! I was hoping to run it as a scheduled task, but it’s not working. When I try to run via SSH I get an error about a missing module - presumably the version of Python on the NAS lacks some extra needed bits and pieces.

I think I should probably be running it with Python in a Docker container, but that’s beyond my capabilities at the moment…. I have a few things running in Docker, but those were straightforward to setup as they were already standalone containers.

I also wanted to ask what the second charge slot feature is, and whether that can be disabled if not using it? Is that intended for use with Flux, and if so - how does it work?

Any advice much welcomed!

salewis38 commented 1 year ago

Hi, The code should run straight from the command prompt and doesn't need Docker. Can you be more specific on the error messages? What version of python are you using?

Boffinboy commented 1 year ago

Thanks. I am using Python3, which I downloaded the native packed for. Specific error is:

Traceback (most recent call last): File "palm_soc.py", line 9, in import requests ModuleNotFoundError: No module named 'requests'

On Mon, 3 Apr 2023 at 22:55, salewis38 @.***> wrote:

Hi, The code should run straight from the command prompt and doesn't need Docker. Can you be more specific on the error messages? What version of python are you using?

— Reply to this email directly, view it on GitHub https://github.com/salewis38/palm/issues/2#issuecomment-1495036741, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD6MBADPENYSVVI4L6L45X3W7NBOFANCNFSM6AAAAAAWR24CIM . You are receiving this because you authored the thread.Message ID: @.***>

salewis38 commented 1 year ago

You need to install the requests library (it's a standard library to handle http requests). Have a quick Google for how to do this with Synology, you may first need to install pip.

Boffinboy commented 1 year ago

Thank you very much. Will let you know if any issues. Sorry to keep bothering you but the other question I had was re: the extra charging session, which isn’t fully explained in the readme. Do I need to do anything to disable that eg set start and end time the same, or comment out something? I am on E7 so it wouldn’t make sense to do, unless I move to Flux over summer.

I do have one final question, which is that I have one day of the week that I tend to do washing on and therefore has higher use during the daytime. I guess I could create some kind of argument that says “when it’s going to be a Tuesday, assume a higher load” but this isn’t something I could do without editing the SOC a script I assume?

On Tue, 4 Apr 2023 at 10:04, salewis38 @.***> wrote:

You need to install the requests library (it's a standard library to handle http requests). Have a quick Google for how to do this with Synology, you may first need to install pip.

— Reply to this email directly, view it on GitHub https://github.com/salewis38/palm/issues/2#issuecomment-1495609945, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD6MBABZTVBAHPUXUNFZQ4LW7PP2DANCNFSM6AAAAAAWR24CIM . You are receiving this because you authored the thread.Message ID: @.***>

salewis38 commented 1 year ago

The extra charging session is a couple of lines in the main loop at the bottom of the code. From what I recall, I made it conditional on winter and high CO2 so wouldn't expect it to trigger at present (and chances are you'll already have a full battery)

For a Tuesday special, you could amend the routine that sets target SoC. It already sets a higher limit in the shoulder months, so an extra clause to include Tuesdays is quite feasible.

Boffinboy commented 1 year ago

Thank you for all your help. Will see if I can figure it out and tweak over long weekend. It’s been 20 years since I did any kind of scripting or coding and this is outside my comfort zone! I’m assuming I can just comment out that part. Adding a “boost” day will require more brainpower I suspect.

Boffinboy commented 1 year ago

Sorry, one further silly question. Can I just run this on a schedule once daily? or do I have to find a way to run as a service on Synology?

salewis38 commented 1 year ago

It was designed to run as a service so that it restarts automatically after a reboot but you could equally run as a command. It will still do the sums as late as possible for best accuracy.

On Tue, 4 Apr 2023, 19:16 Boffinboy, @.***> wrote:

Sorry, one further silly question. Can I just run this on a schedule once daily? or do I have to find a way to run as a service on Synology?

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

Boffinboy commented 1 year ago

Sadly it looks to throw more errors, even after installing PIP and the module.

PALM... PV Automated Load Manager Version: v0.8.4dSoC Command line options (only one can be used): -t | --test | test mode (12x speed, no external server writes) -d | --debug | debug mode, extra verbose Info; Running in test mode... 12x speed, no external server writes Info; Entering main loop... Traceback (most recent call last): File "palm_soc.py", line 96, in init response = requests.request('GET', url, headers=headers, json=payload) AttributeError: module 'requests' has no attribute 'request'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "palm_soc.py", line 550, in ge: GivEnergyObj = GivEnergyObj() File "palm_soc.py", line 97, in init except requests.exceptions.RequestException as error: AttributeError: module 'requests' has no attribute 'exceptions'

salewis38 commented 1 year ago

Hmm. The most common cause of this issue is a local file named requests.py, which is getting imported instead of the requests library. I'm also assuming that you've not changed "import requests" at line 9 in any way?

On Tue, 4 Apr 2023, 21:24 Boffinboy, @.***> wrote:

Sadly it looks to throw more errors, even after installing PIP and the module.

PALM... PV Automated Load Manager Version: v0.8.4dSoC Command line options (only one can be used): -t | --test | test mode (12x speed, no external server writes) -d | --debug | debug mode, extra verbose Info; Running in test mode... 12x speed, no external server writes Info; Entering main loop... Traceback (most recent call last): File "palm_soc.py", line 96, in init response = requests.request('GET', url, headers=headers, json=payload) AttributeError: module 'requests' has no attribute 'request'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "palm_soc.py", line 550, in ge: GivEnergyObj = GivEnergyObj() File "palm_soc.py", line 97, in init except requests.exceptions.RequestException as error: AttributeError: module 'requests' has no attribute 'exceptions'

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

Boffinboy commented 1 year ago

I haven’t changed line 9 and can’t seem to find a requests file anywhere that could cause the issue. The only thing I did have to do was put in the last and Lon in settings for open weather map, because even with only using palm_soc it threw an error without those

salewis38 commented 1 year ago

I've downloaded the exact code from GitHub today and run it on Windows (Python 3.9.5) and a Raspberry Pi (Python 3.9.2) without a problem. Maybe get it up & running on a different machine so you're in a known good state before setting it up on the NAS?

If it helps (and you'd be comfortable with it) you could send me your settings.py file and I could confirm it runs from here.

Boffinboy commented 1 year ago

Thanks. Let me see if I can find some time to give it another go over the weekend on a windows box. I think it’s likely due to the NAS, lots of people seem to suggest running a Python Docker container on Synology to avoid issues with modules etc. but I do this stuff so infrequently it takes a lot of brainpower to get it to work!

Boffinboy commented 1 year ago

So, if I create a Docker container with python in, add the requests module, and then run the script in there - works fine. For whatever reason if I try the same with the native Synology version of Python I get the errors I described above. I am a complete Docker novice, but I think I need to make a Docker file to put running the script into an image, which I can then containerise and then all should work….

Boffinboy commented 1 year ago

Happy Easter weekend! I think I have managed to get this up and running. I guess I will find out tonight - I (think) I have adjusted to loop to run a few hours before the off-peak period by editing the offset in the main loop time definitions to -300 rather than -5 to allow me to manually override before bed if I want a full charge for certain days. As far as I could tell it only writes to the inverter once a day?

I was trying to understand the coding around the shoulder months - if I read the logic correctly that provides for a higher floor than summer?

Thank you for all of your help, and for writing and making available such a cool app

salewis38 commented 1 year ago

Glad to hear you're up and running (and also to learn a bit about the quirks of Synology).

Changing the offset should work fine, although the Solcast forecast is more accurate nearer the time. Without the extra charge during the afternoon Cosy period, it's just the one daily inverter write that's needed.

The "shoulder" function is as you describe and allows for less predictable generation and higher usage either side of winter.

On Sat, 8 Apr 2023, 08:01 Boffinboy, @.***> wrote:

Happy Easter weekend! I think I have managed to get this up and running. I guess I will find out tonight - I (think) I have adjusted to loop to run a few hours before the off-peak period by editing the offset in the main loop time definitions to -300 rather than -5 to allow me to manually override before bed if I want a full charge for certain days. As far as I could tell it only writes to the inverter once a day?

I was trying to understand the coding around the shoulder months - if I read the logic correctly that provides for a higher floor than summer?

Thank you for all of your help, and for writing and making available such a cool app

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

Boffinboy commented 1 year ago

Sadly it didn’t set the charge level! I wonder if I made an error changing the time offset. I also commented out the the lines relating to the second top up charge period. Could either of these things cause an issue?

I’ve tried re-running now without the edit to the time offset. Is the charge instructions only sent that one time before the off peak period? Or is it also meant to be sent when the script is initialised?

Crossing fingers it works this time round

Boffinboy commented 1 year ago

Worked tonight overnight, but seemed to trigger 1h later than the E7 window ie triggered at 2:30 instead of 1:30. Wondering if that’s just some kind of timestamp issue ie they are in UTC not BST

salewis38 commented 1 year ago

Check your system time and location. The code automatically makes the shift from GMT to BST.

On Sun, 9 Apr 2023, 04:32 Boffinboy, @.***> wrote:

Worked tonight overnight, but seemed to trigger 1h later than the E7 window ie triggered at 2:30 instead of 1:30. Wondering if that’s just some kind of timestamp issue ie they are in UTC not BST

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

Boffinboy commented 1 year ago

Thanks. Have passed through an environment variable to the container that tells it to use London timezone. I suspect that might have been the issue.

Boffinboy commented 1 year ago

Environment variable has fixed it! I have found I cannot set the charge estimate to run several hours earlier - I wonder if it’s because I am trying to get it to run before midnight and therefore on a different day? I am using the timing as standard now. I can always top up the battery in the AM manually before a E7 hours finish if I know it will be a high utilisation day. What a great little program, big thanks to you for writing it and making it available.

Boffinboy commented 1 year ago

Hi there, just to say this has been working fantastically! One wrinkle I have is that because I have a particular day that has high usage the battery charges heavily for the following day. I was thinking about modifying to make use of the “standard” i.e. average usage, which I would put in the settings file. I had a couple of questions 1) I was unsure of the format in the settings file, is it per hour? There is a backslash \ part way through I was unclear on, and 2) trying to figure out if / where I can comment out to force it to use those default data. Would it be OK to comment out the definition section fo “get_load_history” after line 186, or will that break things later?

salewis38 commented 1 year ago

The simplest approach might be to modify the routine which gets the history to use the data for the same day the previous week. Change the offset and you should be done.

On Sat, 22 Apr 2023, 12:53 Boffinboy, @.***> wrote:

Hi there, just to say this has been working fantastically! One wrinkle I have is that because I have a particular day that has high usage the battery charges heavily for the following day. I was thinking about modifying to make use of the “standard” i.e. average usage, which I would put in the settings file. I had a couple of questions 1) I was unsure of the format in the settings file, is it per hour? There is a backslash \ part way through I was unclear on, and 2) trying to figure out if / where I can comment out to force it to use those default data. Would it be OK to comment out the definition section fo “get_load_history” after line 186, or will that break things later?

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

Boffinboy commented 1 year ago

Thanks. Is that the day delta on line 189? Sorry for being a bit clueless.

salewis38 commented 1 year ago

Or maybe that should be six!

On 22/04/2023 12:53, Boffinboy wrote:

Hi there, just to say this has been working fantastically! One wrinkle I have is that because I have a particular day that has high usage the battery charges heavily for the following day. I was thinking about modifying to make use of the “standard” i.e. average usage, which I would put in the settings file. I had a couple of questions 1) I was unsure of the format in the settings file, is it per hour? There is a backslash \ part way through I was unclear on, and 2) trying to figure out if / where I can comment out to force it to use those default data. Would it be OK to comment out the definition section fo “get_load_history” after line 186, or will that break things later?

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

Boffinboy commented 1 year ago

Or maybe that should be six!

sorry not sure which part you’re referring to? Think a message might have not come through!

I am thinking you mean change the 0 to 6 in line 189 below (and remove the if else), which presumably gives the day a week before? Or should it be 7?

day_delta = 0 if (TIME_NOW_MINS_VAR > 1430) else 1 # Use latest full day

salewis38 commented 1 year ago

Hi, Would you be able & willing to put together a few notes on how you got palm.py up and running on your Synology NAS? I'd like to expand the readme section with instructions for multiple platforms.

Boffinboy commented 1 year ago

Happy to, might be a couple of weeks. I’d suggest you also include the template Docker file in your code so someone can basically issue one command over SSH to build it, and then they can use the synology GUI to start a container. I’m not particularly familiar with GitHub, but can give it a try if that’s the easiest way to do so. Otherwise I can type out some text and the docker file and you can add? BTW one other feature I wanted to ask about was whether it’s possible to modify the “afternoon boost” to work for Flux, checking the current charge status and boosting to X% if it’s below a certain threshold Y%? Then restoring eco behaviour?

salewis38 commented 1 year ago

Thanks, happy to include the docker file in the repo.

The Flux setting sounds perfectly do-able:

I could be really clever and re-run the SoC prediction at the start of the afternoon Flux period to establish the reserve setting.

On Sun, 25 Jun 2023, 12:23 Boffinboy, @.***> wrote:

Happy to, might be a couple of weeks. I’d suggest you also include the template Docker file in your code so someone can basically issue one command over SSH to build it, and then they can use the synology GUI to start a container. I’m not particularly familiar with GitHub, but can give it a try if that’s the easiest way to do so. Otherwise I can type out some text and the docker file and you can add? BTW one other feature I wanted to ask about was whether it’s possible to modify the “afternoon boost” to work for Flux, checking the current charge status and boosting to X% if it’s below a certain threshold Y%? Then restoring eco behaviour?

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

springfall2008 commented 1 year ago

For Flux the best optimisation is to charge to 100% at cheap rate and then force discharge during the high export rate, but leave enough battery left to make it to the next charge slot.

Boffinboy commented 1 year ago

For Flux the best optimisation is to charge to 100% at cheap rate and then force discharge during the high export rate, but leave enough battery left to make it to the next charge slot.

Makes sense, though personally I'm not sure I'd want to bother with the extra battery cycles for relatively minimal extra benefit. I'm just in the process if switching to Flux so not really had a chance to test or model out properly.

Even a basic feature to boost the reserve to ensure it makes it through the high cost window, or even to the next charge point would be good. I'm quite a high user in the evenings.

salewis38 commented 1 year ago

Export only makes sense if you get paid for it. I'm on deemed export and a heavy winter user with ASHP, so can see the merit in setting an afternoon reserve.

On Sun, 25 Jun 2023, 18:02 Boffinboy, @.***> wrote:

For Flux the best optimisation is to charge to 100% at cheap rate and then force discharge during the high export rate, but leave enough battery left to make it to the next charge slot.

Makes sense, though personally I'm not sure I'd want to bother with the extra battery cycles for relatively minimal extra benefit. I'm just in the process if switching to Flux so not really had a chance to test or model out properly.

Even a basic feature to boost the reserve to ensure it makes it through the high cost window, or even to the next charge point would be good. I'm quite a high user in the evenings.

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

salewis38 commented 1 year ago

The Cosy afternoon boost to a predefined SoC is implemented in the Beta-Cosy code branch. Have a play and see what you think.

On Sun, 25 Jun 2023, 18:02 Boffinboy, @.***> wrote:

For Flux the best optimisation is to charge to 100% at cheap rate and then force discharge during the high export rate, but leave enough battery left to make it to the next charge slot.

Makes sense, though personally I'm not sure I'd want to bother with the extra battery cycles for relatively minimal extra benefit. I'm just in the process if switching to Flux so not really had a chance to test or model out properly.

Even a basic feature to boost the reserve to ensure it makes it through the high cost window, or even to the next charge point would be good. I'm quite a high user in the evenings.

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

Boffinboy commented 1 year ago

Thanks. Won't have a chance to test until tariff switches over to Flux and get some time to tinker. Just to check, is it still dependent on CO2 level? Or if I set the CO2 data flag to "false" in settings will that be disregarded?

salewis38 commented 1 year ago

No longer related to CO2, simply a predetermined SoC at a time of day.

On Sun, 25 Jun 2023, 20:39 Boffinboy, @.***> wrote:

Thanks. Won't have a chance to test until tariff switches over to Flux and get some time to tinker. Just to check, is it still dependent on CO2 level? Or if I set the CO2 data flag to "false" in settings will that be disregarded?

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

Boffinboy commented 1 year ago

I haven’t had a chance to test the Beta version as actually with the great sun at the moment there’s no need! Will be useful as it tapers off and / or if I switch to cost instead of E7 in Winter and use my A2A for heating to reduce gas use.

I have written out some instructions for installing on Synology using Docker below. Let me know if unclear:

Dockerfile to be placed in palm directory, if you place this there it will mean one less step for people

FROM python:3 RUN mkdir -p /palm WORKDIR /palm COPY . . RUN pip install requests

Palm will not run natively on Synology as the installed version of python does not include the relevant packages. Running as a Docker container can help resolve this.

Please note, to make any changes to the image, i.e. updating the settings file, it is most reliable to create a new version of the image with a different name in step 5, otherwise you may find the running Containers don’t use the new version.

  1. Extract palm to a directory on your Synology NAS, and edit the settings file as desired
  2. Go to Control Panel > Terminal & SNMP > Enable SSH service
  3. SSH into your Synology NAS
  4. Navigate to the directory you have extracted palm to using: cd /volume1/your/palm-directory
  5. Create a Docker image using: sudo docker build -t desired-image-name .
  6. Once complete, depending on Synology version go to Docker or Container Manager and select the “Container” menu; the instructions below assume you have Container Manager, the menus are slightly different in Docker, but should still generally match the below
  7. Click “Create” and I’m the Image field select the image you just created
  8. Give the Container a name under “Container name”
  9. Tick “Enable auto restart” if you want palm to load automatically when Synology reboots, or if it experiences an error - this is recommended for typical use
  10. Under “Environment” add a new environment variable called TZ with value Europe/London (or your relevant timezone); this is important to ensure the Container is aware of daylight savings
  11. Under “Execution Command” enter python3 palm.py (note: if you want to pass through any additional arguments you should enter them here as well, e.g. python3 palm.py -o if you want to have a version that you run once, when needed)
  12. Complete the wizard, and the container should start running; you can look at the “Log” tab of the running container each day to check all has worked OK
  13. Return to Control Panel > Terminal & SNMP > Disable SSH service; important to do this for security purposes
salewis38 commented 1 year ago

Thanks - all incorporated!

On Sun, 2023-07-02 at 01:40 -0700, Boffinboy wrote:

I haven’t had a chance to test the Beta version as actually with the great sun at the moment there’s no need! Will be useful as it tapers off and / or if I switch to cost instead of E7 in Winter and use my A2A for heating to reduce gas use. I have written out some instructions for installing on Synology using Docker below. Let me know if unclear: Dockerfile to be placed in palm directory, if you place this there it will mean one less step for people FROM python:3 RUN mkdir -p /palm WORKDIR /palm COPY . . RUN pip install requests Palm will not run natively on Synology as the installed version of python does not include the relevant packages. Running as a Docker container can help resolve this. Please note, to make any changes to the image, i.e. updating the settings file, it is most reliable to create a new version of the image with a different name in step 5, otherwise you may find the running Containers don’t use the new version.    1. Extract palm to a directory on your Synology NAS, and edit the settings file as desired    2. Go to Control Panel > Terminal & SNMP > Enable SSH service    3. SSH into your Synology NAS    4. Navigate to the directory you have extracted palm to using: cd /volume1/your/palm-directory    5. Create a Docker image using: sudo docker build -t desired- image-name .    6. Once complete, depending on Synology version go to Docker or Container Manager and select the “Container” menu; the instructions below assume you have Container Manager, the menus are slightly different in Docker, but should still generally match the below    7. Click “Create” and I’m the Image field select the image you just created    8. Give the Container a name under “Container name”    9. Tick “Enable auto restart” if you want palm to load automatically when Synology reboots, or if it experiences an error - this is recommended for typical use   10. Under “Environment” add a new environment variable called TZ with value Europe/London (or your relevant timezone); this is important to ensure the Container is aware of daylight savings   11. Under “Execution Command” enter python3 palm.py (note: if you want to pass through any additional arguments you should enter them here as well, e.g. python3 palm.py -o if you want to have a version that you run once, when needed)   12. Complete the wizard, and the container should start running; you can look at the “Log” tab of the running container each day to check all has worked OK   13. Return to Control Panel > Terminal & SNMP > Disable SSH service; important to do this for security purposes — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

Boffinboy commented 1 year ago

My pleasure!