BJReplay / PowerwallService

This windows service can log data from a local Powerwall to a local database and / or an azure database, can control pre-charging during off-peak, and can upload data to PVOutput.
9 stars 0 forks source link

Powerwall charging during peak #2

Closed spoonwzd closed 6 years ago

spoonwzd commented 6 years ago

For some reason my Powerwall has suddenly started charging from the grid during peak.

Entered Charge Mode: SOC=21.23282795928536, Required=45, Shortfall=17500, NewTarget=100, Mode=self_consumption, BackupPercentage=100, APIResult = 202

...even though it successfully stopped charging at 8am.

PS. Only finished setting up at 07:40 this morning, so didn't hit its 45% target by then.

BJReplay commented 6 years ago

What time did it start charging? What were the events around that time (leading up to the event you quoted)? It would have been reporting it was outside operating hours, and then changed it's mind.

A key assumption is that the local time zone on the PC running the service is the local time zone of the array.

spoonwzd commented 6 years ago

Local time on the PC is UTC +00:00

Yesterday I had time-based control functionality enabled on my Powerwall, so I set it up and tried it out last night. It had charged a little overnight, but was only 23% by the time I woke up.

Disappointed with the results, I thought I'd give your tool a try. It was up and running at around 07:50 - 10 minutes before cheap electricity ended.

07:51

In Operation Period: SOC=22.350345220300376, Required=10, Shortfall=17500, NewTarget=100
Current SOC below required setting: SOC=22.350345220300376, Required=10, Shortfall=17500, NewTarget=100
Entered Charge Mode: SOC=22.350345220300376, Required=10, Shortfall=17500, NewTarget=100, Mode=self_consumption, BackupPercentage=100, APIResult = 202

08:01

Exiting Charge Mode: SOC=24.044415972667093, Required=45, Shortfall=0, NewTarget=45
Exited Charge Mode: SOC=24.044415972667093, Required=45, Shortfall=0, NewTarget=45, Mode=self_consumption, BackupPercentage=5, APIResult = 202

08:11 Outside Operation Period: SOC=24.037298028329417

While messing with the SolCast stuff, the service was restarted at 08:16

08:21 Outside Operation Period: SOC=23.64581108975728

09:01

In Operation Period: SOC=21.23282795928536, Required=45, Shortfall=17500, NewTarget=100
Current SOC below required setting: SOC=21.23282795928536, Required=45, Shortfall=17500, NewTarget=100

...and it's been charging ever since. Currently at 58% capacity and still pulling from the grid when PV excess is less than 1.7kW.

BJReplay commented 6 years ago

Ok, first suggestion is to use the app to set it back to a backup percentage of 0 (according to the app), or whatever number you really want - the service doesn't monitor the powerwall's reported mode (because that actually stops it every time you log in) via the local API, so won't see that you've changed it externally.

Second point is that I am guessing there's a bug around handling off peak that crosses midnight together with you being at UTC+0. What times have you defined in the config for the start and end of Peak (TariffPeakStartWeekday, TariffPeakEndWeekday)? If TariffPeakEndWeekday was 9 (instead of 21), that would explain it switching modes.

spoonwzd commented 6 years ago

My only options in the app are Self-powered or Time-Based Control. I do not have (and have never had) the ability to define a backup percentage.

      <setting name="TariffIgnoresDST" serializeAs="String">
        <!--This is HARD to explain
                    Your tariff IGNORES DST (daylight saving time) if peak time starts at one particular time of the year in winter, but a different time in summer
                    For example, CitiPower's peak tariff runs from 7am to 11pm in Winter.
                    But, during daylight saving time, it runs from 8am to midnight.  This is because they, in effect, ignore daylight saving time, so their system 
                    says that - when your clock says 8am in summer - that it is 7am, and the peak period is just starting.
                    This is important: it means that you can't start pre-charging until midnight during DST, but you can keep pre-charging (if required) until 8am.
                    You will need to find the definition of your tariff - look up your network's website and see if you can find it.

                    If you can't find it, play it safe, by setting the start time for peak to the earlier time (say 7am), and the end time to the later time (say midnight), and setting this to false
                    -->
        <value>True</value>
      </setting>
      <setting name="TariffPeakOnWeekends" serializeAs="String">
        <!--Does your tariff have Peak on weekends, or is it all off peak.  If set to true, peak and off peak for weekends are ignored, and the charging window is 9pm to 9am-->
        <value>False</value>
      </setting>
      <setting name="TariffPeakStartWeekday" serializeAs="String">
        <!--What hour does Peak start - put 7 for 7am-->
        <value>7</value>
      </setting>
      <setting name="TariffPeakEndWeekday" serializeAs="String">
        <!--What hour does off-peak start (e.g. when does peak end).  If peak is from 7am to 11pm, the put 23 for 11pm  If it is midnight, please use 0-->
        <value>0</value>
      </setting>
      <setting name="TariffPeakStartWeekend" serializeAs="String">
        <!--If the weekend has peak hours, what is the start hour-->
        <value>7</value>
      </setting>
      <setting name="TariffPeakEndWeekend" serializeAs="String">
        <!--If the weekend has peak hours, what is the start hour for off peak-->
        <value>0</value>
      </setting>
spoonwzd commented 6 years ago

FYI my off-peak tariff is from 00:00 - 07:00 GMT

Currently this works out as 01:00 - 08:00 with BST

spoonwzd commented 6 years ago

Also, regardless of whether or not we're 'in operation period' why is it still charging when a new target is set below the SoC?

In Operation Period: SOC=64.9583600256246, Required=45, Shortfall=368.875, NewTarget=47.73241

image

spoonwzd commented 6 years ago

Altered config so that it used 1am instead of midnight, but it still thinks we're 'in operation period'

BJReplay commented 6 years ago

Thanks for the additional info; several thoughts

At this stage, I'd suggest you run turn off the service, and then through the configuration wizard to re-set-up the powerwall to get it back to a supported state.

spoonwzd commented 6 years ago

Ok will do.

FYI: I've just tried setting TariffPeakEndWeekday to 23 and so far it is correctly reporting the operation period:

Outside Operation Period: SOC=76.15488646878782

To me this looks like it has issues with the operation period window when you hit or cross into a new day.

Of course, I'm now stuck in getting to 100% charge, so will try and reset the Powerwall until we find a fix! Happy to help troubleshoot in any way I can...

spoonwzd commented 6 years ago

Service stopped and re-run through the configuration wizard - the Powerwall is STILL pulling from the grid to charge up to 100%! Any other ideas on how I stop it?

spoonwzd commented 6 years ago

I think my Backup Percentage is stuck at 100%.

Been following the guidelines here to send JSON to the Powerwall using curl so a I change the backup percentage, but for the life of me I cannot get it to authenticate.

curl -s -i -X POST -H "Content-Type: application/json" -d '{"username":"","password":"ST000000006","force_sm_off":false}' "http://192.168.78.144/api/login/Basic"

..but instead of getting the expected authentication token, I get:

{"code":401,"error":"Invalid Credentials","message":"Login Error"}

Definitely using the right password (it works in the Powerwall wizard) so no idea why it's not working.

So it's 9pm, 100% SoC and home loads covered by the grid, not the Powerwall. Not a successful day! :)

BJReplay commented 6 years ago

Highest priority new feature is a "reset on service startup to specific mode" - I might even try to smash that together before work today.

Your login requests looks OK.

Second High Priority task is to update the readme to say "don't try this" if your official app doesn't allow you to set a self-consumption backup percentage.

spoonwzd commented 6 years ago

It's cool - I knew the risks before I started down this avenue!

Backup mode isn't available as a feature in the UK and its not been approved for grid usage, but I'm fairly sure battery reserves and stuff still work. (Soon after I got my Powerwall I had issues with it charging from 0%, so Tesla set the reserve so that it never dropped below 5% in the API).

I'm sure we can make it work, and am in it for the long haul if you are. :) Time-based control decisions based on weather conditions is EXACTLY what I need and what Tesla's current implementation doesn't offer.

Thanks for giving it priority. I'll be up for a few more hours if you want me to do more testing.

BJReplay commented 6 years ago

Standby...

BJReplay commented 6 years ago

About to upload a new EXE.

BJReplay commented 6 years ago

In anticipation, please add the following to your .config file `

True self_consumption 5

`

Or whatever your minimum backup percentage you want is.

spoonwzd commented 6 years ago

Done!

BJReplay commented 6 years ago

Grab this https://github.com/BJReplay/PowerwallService/blob/master/PowerwallService.exe Stop your service Drop this file over the top (unblock as required) Start your service Look for event id 600 in the event log just after starting - it will report success or failure

spoonwzd commented 6 years ago

On it

spoonwzd commented 6 years ago

Set PW Mode: Mode=self_consumption, BackupPercentage=5, APIResult = 202

Battery now discharging! 👍

BJReplay commented 6 years ago

By the way, having slept on it, the midnight start for off-peak combined with DST may have confused the start / stop time settings; my off-peak starts at 11pm, shifting to midnight during DST, and I tested around DST and non-DST aware modes with start times of 11pm (23) and midnight 0, but I may not have correctly tested midnight as specified plus DST. Will add some unit tests for this.

spoonwzd commented 6 years ago

Thanks. I've shifted my config to 11pm (23) and 7am (7), so I guess we'll see what happens in about 20 minutes.

spoonwzd commented 6 years ago

BST still messing with my head. I meant 1hr 20 minutes

facepalm

spoonwzd commented 6 years ago

Ok, so far so good.

In Operation Period: SOC=88.62812033283551, Required=41, Shortfall=0, NewTarget=41

Let's see what it looks like in the morning. Thanks again for all your help.

spoonwzd commented 6 years ago

It's morning here now, and things seem to have been running nicely overnight with it estimating the PV generation and occasionally tweaking the target SoC which never dropped to that level anyway.

In Operation Period: SOC=31.391792902354027, Required=10, Shortfall=1330.055, NewTarget=19.85226

We've just passed over into the peak period now. So far so good.

Outside Operation Period: SOC=32.08875613398762

With any luck it won't freak out at 9am again now that I've avoided using midnight. Watch this space.

BJReplay commented 6 years ago

Sounds good so far.

The fact that it's now working is a good sign that the error is around the midnight setting, so I can focus on that.

And if it does freak out - just re-start the service :)

If it is any consolation, I'm going to be running my battery flat tonight and on grid at peak rates because the forecast overnight for 18.5kWh of generation was out by 8.5kWh, and I aggressively reduced my safety margins for pre-charging because the last few nights were unnecessarily pre-charging, the exporting to the grid the next day.

spoonwzd commented 6 years ago

Home for lunch. Have checked the events for the last 3.5 hours and they all happily report outside operation period. No freakyness around 9am or anything, so the you're probably right about the midnight issue.

I too think I'm going to be exporting to the grid at this rate - already up to 75% SoC and still another 7kW expected according to the SolCast estimate. I think I'll go turn on an appliance :)

Of course, it's an unfair test of your tool as it was still 20% above the required SoC by the time we exited the operation period. Tonight will be a fairer test.

spoonwzd commented 6 years ago

I wouldn't be too concerned about one day being out - the forecast is an estimate and the weather is unpredictable by nature. Your tool can only react to the data it is fed, and no amount of margin will cover all eventualities.

I plan to use IFTTT or something similar to increase home power consumption when certain SoC thresholds are met when there's likely to be PV generation I cannot store. Something along the lines of powering up the washing machine ahead of the off-peak schedule, or automating the GPU power settings on my crypto mining efforts. Still in the ideas phase at the moment, but I think it has legs and will be even more prevalent when I get my 5kW inverter.

BJReplay commented 6 years ago

Well I found what I thought might have caused it - but I can't see how it did.

Then, unless I refactor the code, I can't build unit tests (my service class and my main class are the same). However, I've just stepped through in debug mode with the service running on my dev PC simulating:

There's a bit of code attempting to work around the off peak period changing during off peak - specifically around transitions from weekend to weekday, and daylight saving to standard time.

I figured the easiest way to do that was simply to check the operating hours on each call to check the SOC and forecast, and adjust as required.

That meant setting the operating period has to be able to set the start and end of the period when a) both start and end are in the future, b) while start is in the past and end is in the future (and changing the time if daylight savings starts or end while in the operating period), as well as, c) once we reach the end of the operating period, set it forward to the next day.

In order to avoid pushing the operating period foward, just in case we should now be shutting down the charge mode, I don't push it forward until one hour after the operating period has ended (allowing a one hour buffer for charge setting to detect that it has not yet exited charge mode but should do so - perhaps because the powerwall didn't respond to the first attempt to exit charge mode) - so, in your case, 9am local time.

There was a bug - in the last hour (8am to 9am), it would set the start date back a day, and leave the end date at 8am that day.

However, the charge setting routine should have still said "I'm outside the operating period - because now is > than 8am today which was the end time".

I can't reconcile what I've seen stepping through the code around that 9am point with what you had logged. However, I'm inclined to chalk this up to gremlins for the moment, and request that you manage DST by adjusting the config settings twice a year - set TariffIgnoresDST to False, PeakEnd to 1 and PeakStart to 8 during summer time, and back to 0 and 7 during winter.

spoonwzd commented 6 years ago

In advance of a pending fix, I have disabled TariffIgnoresDST and have used 1am and 8am for the TariffPeak options which match the current UK DST (BST).

In theory this should avoid the midnight problem and fit correctly with my off-peak tariff times.

Oh, like you said. :)

spoonwzd commented 6 years ago

Well this is odd - just saved the settings and restarted the service.

It thinks it's in operation period again!

In Operation Period: SOC=87.2768650878316, Required=45, Shortfall=0, NewTarget=45

My config is correct, right?

      <setting name="TariffIgnoresDST" serializeAs="String">
        <!--This is HARD to explain
                    Your tariff IGNORES DST (daylight saving time) if peak time starts at one particular time of the year in winter, but a different time in summer
                    For example, CitiPower's peak tariff runs from 7am to 11pm in Winter.
                    But, during daylight saving time, it runs from 8am to midnight.  This is because they, in effect, ignore daylight saving time, so their system 
                    says that - when your clock says 8am in summer - that it is 7am, and the peak period is just starting.
                    This is important: it means that you can't start pre-charging until midnight during DST, but you can keep pre-charging (if required) until 8am.
                    You will need to find the definition of your tariff - look up your network's website and see if you can find it.

                    If you can't find it, play it safe, by setting the start time for peak to the earlier time (say 7am), and the end time to the later time (say midnight), and setting this to false
                    -->
        <value>False</value>
      </setting>
      <setting name="TariffPeakOnWeekends" serializeAs="String">
        <!--Does your tariff have Peak on weekends, or is it all off peak.  If set to true, peak and off peak for weekends are ignored, and the charging window is 9pm to 9am-->
        <value>False</value>
      </setting>
      <setting name="TariffPeakStartWeekday" serializeAs="String">
        <!--What hour does Peak start - put 7 for 7am-->
        <value>8</value>
      </setting>
      <setting name="TariffPeakEndWeekday" serializeAs="String">
        <!--What hour does off-peak start (e.g. when does peak end).  If peak is from 7am to 11pm, the put 23 for 11pm  If it is midnight, please use 0-->
        <value>1</value>
      </setting>
      <setting name="TariffPeakStartWeekend" serializeAs="String">
        <!--If the weekend has peak hours, what is the start hour-->
        <value>8</value>
      </setting>
      <setting name="TariffPeakEndWeekend" serializeAs="String">
        <!--If the weekend has peak hours, what is the start hour for off peak-->
        <value>1</value>
      </setting>
BJReplay commented 6 years ago

OK, that's another clue - this occurred last time just after a restart? It's just gone 1pm there now?

Config looks OK.

I'm going to bed now, but I'd be interested to see if the next report (in 10 minutes) still says it's in the operation period, or it has decided it isn't.

If that's the case, the issue might be around initialisation; I've got several startup tasks that I start on a new thread so the actual service start is snappy, and I thought I'd ensured that timer based tasks are not enabled until the startup tasks have completed, but I might have a race condition that could possibly explain this.

If that's the case, a critical section around setting the operation hours should fix this. I will have to add logging to setting the operation hours though to see if that's the cause.

spoonwzd commented 6 years ago

Yes, happened last time after a restart. Perhaps the first start actually. It has just gone 1pm here, yes.

I actually stopped it and set it back to 23, and the next report said it was out of operation period as expected. I've just set it back again now, so will report back!

I was also wondering if it might be a good idea to periodically set the target while out of operation period, because as it stands right now my Powerwall will only discharge to the previously set target of 45% SoC. Is this correct?

spoonwzd commented 6 years ago

3 reports since startup - all reporting in operation period and setting a target of 45% SoC.

I'll leave it for now and see if it changes, but I'll probably revert the settings back if the battery doesn't discharge below 45%.

See you on the other side. ;)

spoonwzd commented 6 years ago

FYI: PwS has reported in operation period all day with a target set at 45%.

I've just forced it back to self consumption at 5%, re-enabled IgnoreDST and configured the tariff times at 7 & 23 hours. At least this way it will will only have a 1-hour window of opportunity to charge from peak and finish at the correct time while still behaving correctly.

Is is possible to configure time at finer intervals than 1 hour? 23:55 seems a good fix :)

In regards to PV generation estimates, my SolCast settings said I should have generated in the region of 20kWh today, whereas my PV actually generated nearly 30kWh, which is eerily identical in underestimate to your own overestimate the previous day. Despite all my best efforts, I still ended up exporting nearly 6kWh to the grid!

BJReplay commented 6 years ago

Re setting of 45% - that will be the sum of your overnight load percentage and morning buffer percentage. When it exit's charge mode, it sets the backup percentage to the greater of 5% or your minimum backup percentage setting.

Re the 23:55 suggestion - I want to stick with whole hours for the moment - adding minutes to it will only make this trickier. In any case, the service exits from charge mode at the first check in the last 20 minutes of off peak - so that could be as early as 6:40 am (7:40am BST) or as late as 6:69 - but should happen at least once during that period - and ideally twice, in case the PW doesn't accept the request the first time.

In your case, there's something very odd going on because it is thinking it is in operation in the middle of the day (as if the constructor of the start time is interpreting 1 as 13 for the hour) - I'm going to need to add logging of some of the internal variables to work out what it is doing, but in the meantime, can you please export the event log around the time you restarted - including the events logged from the restart to the second "In Operation Period" event - seeing the timestamp data from those might assist.

spoonwzd commented 6 years ago

Re; setting of 5% - I understand that if the application is functioning at the time charge mode is exited this will occur, but I actually had an instance this morning where my gateway either rebooted or briefly lost its WiFi connection during the shift in operation period which meant it didn't switch modes.

I've exported all logs since we fixed it last night and attempted to remove as much extraneous information as possible. (Start from the bottom up!). Remember that I've also been messing around with the config a bit this morning (as above) which is why there's so many stop/start events (but I felt it was best to leave them in).

Date and Time | Source | Event ID |  
-- | -- | -- | --
05/04/2018 22:31 | PowerwallService | 503 | Outside Operation Period: SOC=63.041468098726796
05/04/2018 22:21 | PowerwallService | 503 | Outside Operation Period: SOC=64.49249591009318
05/04/2018 22:11 | PowerwallService | 503 | Outside Operation Period: SOC=65.73013727861156
05/04/2018 22:01 | PowerwallService | 503 | Outside Operation Period: SOC=67.80709865566541
05/04/2018 21:51 | PowerwallService | 503 | Outside Operation Period: SOC=69.16565900846433
05/04/2018 21:41 | PowerwallService | 503 | Outside Operation Period: SOC=70.53133224269152
05/04/2018 21:31 | PowerwallService | 503 | Outside Operation Period: SOC=72.07482751262536
05/04/2018 21:21 | PowerwallService | 503 | Outside Operation Period: SOC=73.61832278255922
05/04/2018 21:11 | PowerwallService | 503 | Outside Operation Period: SOC=75.0053346610712
05/04/2018 21:01 | PowerwallService | 503 | Outside Operation Period: SOC=76.40657230243973
05/04/2018 20:51 | PowerwallService | 503 | Outside Operation Period: SOC=79.27306351803115
05/04/2018 20:41 | PowerwallService | 503 | Outside Operation Period: SOC=82.28181236218792
05/04/2018 20:41 | PowerwallService | 111 | Solar Forecast and Charge Monitoring Timer Started
05/04/2018 20:40 | PowerwallService | 109 | One Minute Timer Started
05/04/2018 20:39 | PowerwallService | 108 | Observation Timer Started
05/04/2018 20:39 | PowerwallService | 0 | Service started successfully.
05/04/2018 20:39 | PowerwallService | 101 | Powerwall Service Started
05/04/2018 20:39 | PowerwallService | 100 | Powerwall Service Starting
05/04/2018 20:36 | PowerwallService | 0 | Service stopped successfully.
05/04/2018 20:36 | PowerwallService | 107 | Powerwall Service Stopped
05/04/2018 20:36 | PowerwallService | 106 | Powerwall Service Stoping
05/04/2018 20:31 | PowerwallService | 503 | Outside Operation Period: SOC=84.4370154349527
05/04/2018 20:21 | PowerwallService | 503 | Outside Operation Period: SOC=86.70602461056974
05/04/2018 20:21 | PowerwallService | 111 | Solar Forecast and Charge Monitoring Timer Started
05/04/2018 20:14 | PowerwallService | 109 | One Minute Timer Started
05/04/2018 20:13 | PowerwallService | 108 | Observation Timer Started
05/04/2018 20:13 | PowerwallService | 0 | Service started successfully.
05/04/2018 20:13 | PowerwallService | 101 | Powerwall Service Started
05/04/2018 20:13 | PowerwallService | 100 | Powerwall Service Starting
05/04/2018 20:13 | PowerwallService | 0 | Service stopped successfully.
05/04/2018 20:13 | PowerwallService | 107 | Powerwall Service Stopped
05/04/2018 20:13 | PowerwallService | 106 | Powerwall Service Stoping
05/04/2018 20:11 | PowerwallService | 503 | Outside Operation Period: SOC=87.68760224767053
05/04/2018 20:11 | PowerwallService | 111 | Solar Forecast and Charge Monitoring Timer Started
05/04/2018 20:08 | PowerwallService | 109 | One Minute Timer Started
05/04/2018 20:07 | PowerwallService | 108 | Observation Timer Started
05/04/2018 20:07 | PowerwallService | 600 | Set PW Mode: Mode=self_consumption, BackupPercentage=5, APIResult = 202
05/04/2018 20:07 | PowerwallService | 0 | Service started successfully.
05/04/2018 20:07 | PowerwallService | 101 | Powerwall Service Started
05/04/2018 20:07 | PowerwallService | 100 | Powerwall Service Starting
05/04/2018 20:07 | PowerwallService | 0 | Service stopped successfully.
05/04/2018 20:07 | PowerwallService | 107 | Powerwall Service Stopped
05/04/2018 20:07 | PowerwallService | 106 | Powerwall Service Stoping
05/04/2018 20:06 | Desktop Window Manager | 9009 | The Desktop Window Manager has exited with code (0xd00002fe)
05/04/2018 20:01 | PowerwallService | 500 | In Operation Period: SOC=88.77587310619532, Required=45, Shortfall=0,   NewTarget=45
05/04/2018 19:51 | PowerwallService | 500 | In Operation Period: SOC=90.11309481470944, Required=45, Shortfall=0,   NewTarget=45
05/04/2018 19:41 | PowerwallService | 500 | In Operation Period: SOC=91.32228465751476, Required=45, Shortfall=0,   NewTarget=45
05/04/2018 19:31 | PowerwallService | 500 | In Operation Period: SOC=92.51013585603528, Required=45, Shortfall=0,   NewTarget=45
05/04/2018 19:21 | PowerwallService | 500 | In Operation Period: SOC=93.7193256988406, Required=45, Shortfall=0,   NewTarget=45
05/04/2018 19:11 | PowerwallService | 500 | In Operation Period: SOC=94.67245181022832, Required=45, Shortfall=0,   NewTarget=45
05/04/2018 19:01 | PowerwallService | 500 | In Operation Period: SOC=95.91720606017498, Required=45, Shortfall=0,   NewTarget=45
05/04/2018 18:51 | PowerwallService | 500 | In Operation Period: SOC=95.86030300874884, Required=45, Shortfall=0,   NewTarget=45
05/04/2018 18:41 | PowerwallService | 500 | In Operation Period: SOC=95.98122199302938, Required=45, Shortfall=0,   NewTarget=45
05/04/2018 18:31 | PowerwallService | 500 | In Operation Period: SOC=96.38665623444057, Required=45, Shortfall=0,   NewTarget=45
05/04/2018 18:21 | PowerwallService | 500 | In Operation Period: SOC=96.62849420300164, Required=45, Shortfall=0,   NewTarget=45
05/04/2018 18:11 | PowerwallService | 500 | In Operation Period: SOC=96.70673589871257, Required=45, Shortfall=0,   NewTarget=45
05/04/2018 18:01 | PowerwallService | 500 | In Operation Period: SOC=96.5929297958603, Required=45, Shortfall=0,   NewTarget=45
05/04/2018 17:51 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 17:41 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 17:31 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 17:21 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 17:11 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 17:01 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 16:51 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 16:41 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 16:31 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 16:21 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 16:11 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 16:01 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 15:51 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 15:41 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 15:31 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 15:21 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 15:11 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 15:01 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 14:51 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 14:41 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 14:31 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 14:21 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 14:11 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 14:01 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 13:51 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 13:41 | PowerwallService | 500 | In Operation Period: SOC=100, Required=45, Shortfall=0, NewTarget=45
05/04/2018 13:31 | PowerwallService | 500 | In Operation Period: SOC=96.68586871488515, Required=45, Shortfall=0,   NewTarget=45
05/04/2018 13:21 | PowerwallService | 500 | In Operation Period: SOC=93.62776473934997, Required=45, Shortfall=0,   NewTarget=45
05/04/2018 13:21 | PowerwallService | 111 | Solar Forecast and Charge Monitoring Timer Started
05/04/2018 13:19 | PowerwallService | 109 | One Minute Timer Started
05/04/2018 13:18 | PowerwallService | 108 | Observation Timer Started
05/04/2018 13:18 | PowerwallService | 0 | Service started successfully.
05/04/2018 13:18 | PowerwallService | 101 | Powerwall Service Started
05/04/2018 13:18 | PowerwallService | 100 | Powerwall Service Starting
05/04/2018 13:18 | PowerwallService | 0 | Service stopped successfully.
05/04/2018 13:18 | PowerwallService | 107 | Powerwall Service Stopped
05/04/2018 13:18 | PowerwallService | 106 | Powerwall Service Stoping
05/04/2018 13:11 | PowerwallService | 503 | Outside Operation Period: SOC=90.41319963018277
05/04/2018 13:11 | PowerwallService | 111 | Solar Forecast and Charge Monitoring Timer Started
05/04/2018 13:08 | PowerwallService | 109 | One Minute Timer Started
05/04/2018 13:07 | PowerwallService | 108 | Observation Timer Started
05/04/2018 13:07 | PowerwallService | 0 | Service started successfully.
05/04/2018 13:07 | PowerwallService | 101 | Powerwall Service Started
05/04/2018 13:07 | PowerwallService | 100 | Powerwall Service Starting
05/04/2018 13:07 | PowerwallService | 0 | Service stopped successfully.
05/04/2018 13:07 | PowerwallService | 107 | Powerwall Service Stopped
05/04/2018 13:07 | PowerwallService | 106 | Powerwall Service Stoping
05/04/2018 13:01 | PowerwallService | 500 | In Operation Period: SOC=87.2768650878316, Required=45, Shortfall=0,   NewTarget=45
05/04/2018 13:01 | PowerwallService | 111 | Solar Forecast and Charge Monitoring Timer Started
05/04/2018 12:59 | PowerwallService | 109 | One Minute Timer Started
05/04/2018 12:58 | PowerwallService | 108 | Observation Timer Started
05/04/2018 12:58 | PowerwallService | 0 | Service started successfully.
05/04/2018 12:58 | PowerwallService | 101 | Powerwall Service Started
05/04/2018 12:58 | PowerwallService | 100 | Powerwall Service Starting
05/04/2018 12:58 | PowerwallService | 0 | Service stopped successfully.
05/04/2018 12:58 | PowerwallService | 107 | Powerwall Service Stopped
05/04/2018 12:58 | PowerwallService | 106 | Powerwall Service Stoping
05/04/2018 12:51 | PowerwallService | 503 | Outside Operation Period: SOC=84.42500533390228
05/04/2018 12:41 | PowerwallService | 503 | Outside Operation Period: SOC=82.80349903989759
05/04/2018 12:31 | PowerwallService | 503 | Outside Operation Period: SOC=81.82917288955267
05/04/2018 12:21 | PowerwallService | 503 | Outside Operation Period: SOC=80.14365976815306
05/04/2018 12:11 | PowerwallService | 503 | Outside Operation Period: SOC=78.64305525922765
05/04/2018 12:01 | PowerwallService | 503 | Outside Operation Period: SOC=76.49527060664248
05/04/2018 11:51 | PowerwallService | 503 | Outside Operation Period: SOC=75.89787355095655
05/04/2018 11:41 | PowerwallService | 503 | Outside Operation Period: SOC=73.2664817580542
05/04/2018 11:31 | PowerwallService | 503 | Outside Operation Period: SOC=70.49996444065145
05/04/2018 11:21 | PowerwallService | 503 | Outside Operation Period: SOC=67.79745395064363
05/04/2018 11:11 | PowerwallService | 503 | Outside Operation Period: SOC=65.03093663324087
05/04/2018 11:01 | PowerwallService | 503 | Outside Operation Period: SOC=62.90448758978735
05/04/2018 10:51 | PowerwallService | 503 | Outside Operation Period: SOC=60.62868928241235
05/04/2018 10:41 | PowerwallService | 503 | Outside Operation Period: SOC=58.295996017352955
05/04/2018 10:31 | PowerwallService | 503 | Outside Operation Period: SOC=56.077092667662335
05/04/2018 10:21 | PowerwallService | 503 | Outside Operation Period: SOC=54.01465045160373
05/04/2018 10:11 | PowerwallService | 503 | Outside Operation Period: SOC=51.93798449612403
05/04/2018 10:01 | PowerwallService | 503 | Outside Operation Period: SOC=49.854206670933785
05/04/2018 09:51 | PowerwallService | 503 | Outside Operation Period: SOC=47.83443567313847
05/04/2018 09:41 | PowerwallService | 503 | Outside Operation Period: SOC=45.82888841476424
05/04/2018 09:31 | PowerwallService | 503 | Outside Operation Period: SOC=43.95135481117986
05/04/2018 09:21 | PowerwallService | 503 | Outside Operation Period: SOC=42.19472299267478
05/04/2018 09:11 | PowerwallService | 503 | Outside Operation Period: SOC=40.58744043809118
05/04/2018 09:01 | PowerwallService | 503 | Outside Operation Period: SOC=38.91615105611265
05/04/2018 08:51 | PowerwallService | 503 | Outside Operation Period: SOC=37.42977028660835
05/04/2018 08:41 | PowerwallService | 503 | Outside Operation Period: SOC=36.08562691131498
05/04/2018 08:31 | PowerwallService | 503 | Outside Operation Period: SOC=34.890832799943105
05/04/2018 08:21 | PowerwallService | 503 | Outside Operation Period: SOC=33.83116421307162
05/04/2018 08:11 | PowerwallService | 503 | Outside Operation Period: SOC=32.9492923689638
05/04/2018 08:01 | PowerwallService | 503 | Outside Operation Period: SOC=32.08875613398762
05/04/2018 07:51 | PowerwallService | 500 | In Operation Period: SOC=31.391792902354027, Required=10,   Shortfall=1330.055, NewTarget=19.85226
05/04/2018 07:41 | PowerwallService | 500 | In Operation Period: SOC=31.491359078301684, Required=10,   Shortfall=1372.154, NewTarget=20.16411
05/04/2018 07:31 | PowerwallService | 500 | In Operation Period: SOC=31.15710120190598, Required=10,   Shortfall=404.6563, NewTarget=12.99745
05/04/2018 07:21 | PowerwallService | 500 | In Operation Period: SOC=31.029087547116134, Required=10,   Shortfall=404.6563, NewTarget=12.99745
05/04/2018 07:11 | PowerwallService | 500 | In Operation Period: SOC=31.349121684090747, Required=10,   Shortfall=411.9395, NewTarget=13.0514
05/04/2018 07:01 | PowerwallService | 500 | In Operation Period: SOC=31.95363060948723, Required=10,   Shortfall=411.9336, NewTarget=13.05136
05/04/2018 06:51 | PowerwallService | 500 | In Operation Period: SOC=32.9492923689638, Required=14, Shortfall=0,   NewTarget=14
05/04/2018 06:41 | PowerwallService | 500 | In Operation Period: SOC=34.12986274091458, Required=14, Shortfall=0,   NewTarget=14
05/04/2018 06:31 | PowerwallService | 500 | In Operation Period: SOC=35.40288741910248, Required=14, Shortfall=0,   NewTarget=14
05/04/2018 06:21 | PowerwallService | 500 | In Operation Period: SOC=36.56212218192162, Required=14, Shortfall=0,   NewTarget=14
05/04/2018 06:11 | PowerwallService | 500 | In Operation Period: SOC=37.764028163004056, Required=14, Shortfall=0,   NewTarget=14
05/04/2018 06:01 | PowerwallService | 500 | In Operation Period: SOC=39.04416471090249, Required=14, Shortfall=0,   NewTarget=14
05/04/2018 05:51 | PowerwallService | 500 | In Operation Period: SOC=40.15361638574782, Required=19, Shortfall=0,   NewTarget=19
05/04/2018 05:41 | PowerwallService | 500 | In Operation Period: SOC=41.170613754356026, Required=19, Shortfall=0,   NewTarget=19
05/04/2018 05:31 | PowerwallService | 500 | In Operation Period: SOC=42.315624777754074, Required=19, Shortfall=0,   NewTarget=19
05/04/2018 05:21 | PowerwallService | 500 | In Operation Period: SOC=43.446412061731024, Required=19, Shortfall=0,   NewTarget=19
05/04/2018 05:11 | PowerwallService | 500 | In Operation Period: SOC=44.57008747599744, Required=19, Shortfall=0,   NewTarget=19
05/04/2018 05:01 | PowerwallService | 500 | In Operation Period: SOC=45.62264419315838, Required=19, Shortfall=0,   NewTarget=19
05/04/2018 04:51 | PowerwallService | 500 | In Operation Period: SOC=46.75343147713534, Required=23, Shortfall=0,   NewTarget=23
05/04/2018 04:41 | PowerwallService | 500 | In Operation Period: SOC=47.85577128227011, Required=23, Shortfall=0,   NewTarget=23
05/04/2018 04:31 | PowerwallService | 500 | In Operation Period: SOC=48.97233482682598, Required=23, Shortfall=0,   NewTarget=23
05/04/2018 04:21 | PowerwallService | 500 | In Operation Period: SOC=50.04622715311855, Required=23, Shortfall=0,   NewTarget=23
05/04/2018 04:11 | PowerwallService | 500 | In Operation Period: SOC=51.12723134912168, Required=23, Shortfall=0,   NewTarget=23
05/04/2018 04:01 | PowerwallService | 500 | In Operation Period: SOC=52.236683023967004, Required=23, Shortfall=0,   NewTarget=23
05/04/2018 03:51 | PowerwallService | 500 | In Operation Period: SOC=53.48126022331271, Required=28, Shortfall=0,   NewTarget=28
05/04/2018 03:41 | PowerwallService | 500 | In Operation Period: SOC=54.69738994381623, Required=28, Shortfall=0,   NewTarget=28
05/04/2018 03:31 | PowerwallService | 500 | In Operation Period: SOC=55.778394139819355, Required=28, Shortfall=0,   NewTarget=28
05/04/2018 03:21 | PowerwallService | 500 | In Operation Period: SOC=56.91629329350686, Required=28, Shortfall=0,   NewTarget=28
05/04/2018 03:11 | PowerwallService | 500 | In Operation Period: SOC=58.061304316904916, Required=28, Shortfall=0,   NewTarget=28
05/04/2018 03:01 | PowerwallService | 500 | In Operation Period: SOC=59.163644122039685, Required=28, Shortfall=0,   NewTarget=28
05/04/2018 02:51 | PowerwallService | 500 | In Operation Period: SOC=60.265983927174446, Required=32, Shortfall=0,   NewTarget=32
05/04/2018 02:41 | PowerwallService | 500 | In Operation Period: SOC=61.38254747173032, Required=32, Shortfall=0,   NewTarget=32
05/04/2018 02:31 | PowerwallService | 500 | In Operation Period: SOC=62.4564397980229, Required=32, Shortfall=0,   NewTarget=32
05/04/2018 02:21 | PowerwallService | 500 | In Operation Period: SOC=63.551667733447125, Required=32, Shortfall=0,   NewTarget=32
05/04/2018 02:11 | PowerwallService | 500 | In Operation Period: SOC=64.66111940829245, Required=32, Shortfall=0,   NewTarget=32
05/04/2018 02:01 | PowerwallService | 500 | In Operation Period: SOC=65.75634734371666, Required=32, Shortfall=0,   NewTarget=32
05/04/2018 01:51 | PowerwallService | 500 | In Operation Period: SOC=66.86579901856197, Required=36, Shortfall=0,   NewTarget=36
05/04/2018 01:41 | PowerwallService | 500 | In Operation Period: SOC=67.9610269539862, Required=36, Shortfall=0,   NewTarget=36
05/04/2018 01:31 | PowerwallService | 500 | In Operation Period: SOC=70.22971339165066, Required=36, Shortfall=0,   NewTarget=36
05/04/2018 01:21 | PowerwallService | 500 | In Operation Period: SOC=73.83543133489795, Required=36, Shortfall=0,   NewTarget=36
05/04/2018 01:11 | PowerwallService | 500 | In Operation Period: SOC=76.40281630040538, Required=36, Shortfall=0,   NewTarget=36
05/04/2018 01:01 | PowerwallService | 500 | In Operation Period: SOC=77.53360358438233, Required=36, Shortfall=0,   NewTarget=36
05/04/2018 00:51 | PowerwallService | 500 | In Operation Period: SOC=80.66993812673353, Required=41, Shortfall=0,   NewTarget=41
05/04/2018 00:41 | PowerwallService | 500 | In Operation Period: SOC=83.23732309224094, Required=41, Shortfall=0,   NewTarget=41
05/04/2018 00:31 | PowerwallService | 500 | In Operation Period: SOC=85.67669440295855, Required=41, Shortfall=0,   NewTarget=41
05/04/2018 00:21 | PowerwallService | 500 | In Operation Period: SOC=88.62812033283551, Required=41, Shortfall=0,   NewTarget=41
05/04/2018 00:21 | PowerwallService | 111 | Solar Forecast and Charge Monitoring Timer Started
05/04/2018 00:19 | PowerwallService | 109 | One Minute Timer Started
05/04/2018 00:18 | PowerwallService | 108 | Observation Timer Started
05/04/2018 00:18 | PowerwallService | 0 | Service started successfully.
05/04/2018 00:18 | PowerwallService | 101 | Powerwall Service Started
05/04/2018 00:18 | PowerwallService | 100 | Powerwall Service Starting
05/04/2018 00:18 | PowerwallService | 0 | Service stopped successfully.
05/04/2018 00:18 | PowerwallService | 107 | Powerwall Service Stopped
05/04/2018 00:18 | PowerwallService | 106 | Powerwall Service Stoping
05/04/2018 00:14 | PowerwallService | 109 | One Minute Timer Started
05/04/2018 00:13 | PowerwallService | 108 | Observation Timer Started
05/04/2018 00:13 | PowerwallService | 0 | Service started successfully.
05/04/2018 00:13 | PowerwallService | 101 | Powerwall Service Started
05/04/2018 00:13 | PowerwallService | 100 | Powerwall Service Starting
05/04/2018 00:10 | PowerwallService | 0 | Service stopped successfully.
05/04/2018 00:10 | PowerwallService | 107 | Powerwall Service Stopped
05/04/2018 00:10 | PowerwallService | 106 | Powerwall Service Stoping
05/04/2018 00:10 | PowerwallService | 108 | Observation Timer Started
05/04/2018 00:09 | PowerwallService | 0 | Service started successfully.
05/04/2018 00:09 | PowerwallService | 101 | Powerwall Service Started
05/04/2018 00:09 | PowerwallService | 100 | Powerwall Service Starting
05/04/2018 00:07 | PowerwallService | 0 | Service stopped successfully.
05/04/2018 00:07 | PowerwallService | 107 | Powerwall Service Stopped
05/04/2018 00:07 | PowerwallService | 106 | Powerwall Service Stoping
05/04/2018 00:06 | PowerwallService | 109 | One Minute Timer Started
05/04/2018 00:05 | PowerwallService | 108 | Observation Timer Started
05/04/2018 00:05 | PowerwallService | 0 | Service started successfully.
05/04/2018 00:05 | PowerwallService | 101 | Powerwall Service Started
05/04/2018 00:05 | PowerwallService | 100 | Powerwall Service Starting
05/04/2018 00:05 | PowerwallService | 0 | Service stopped successfully.
05/04/2018 00:05 | PowerwallService | 107 | Powerwall Service Stopped
05/04/2018 00:05 | PowerwallService | 106 | Powerwall Service Stoping
05/04/2018 00:01 | PowerwallService | 500 | In Operation Period: SOC=90.65101387406617, Required=41, Shortfall=0,   NewTarget=41
04/04/2018 23:51 | PowerwallService | 503 | Outside Operation Period: SOC=91.66844539309854
04/04/2018 23:41 | PowerwallService | 503 | Outside Operation Period: SOC=92.72856634649591
04/04/2018 23:31 | PowerwallService | 503 | Outside Operation Period: SOC=93.49697616506582
04/04/2018 23:21 | PowerwallService | 503 | Outside Operation Period: SOC=94.59267164710067
04/04/2018 23:11 | PowerwallService | 503 | Outside Operation Period: SOC=95.64567769477054
04/04/2018 23:01 | PowerwallService | 503 | Outside Operation Period: SOC=96.68445393098541
04/04/2018 22:51 | PowerwallService | 503 | Outside Operation Period: SOC=100
04/04/2018 22:41 | PowerwallService | 503 | Outside Operation Period: SOC=100
04/04/2018 22:41 | PowerwallService | 111 | Solar Forecast and Charge Monitoring Timer Started
04/04/2018 22:34 | PowerwallService | 109 | One Minute Timer Started
04/04/2018 22:33 | PowerwallService | 108 | Observation Timer Started
04/04/2018 22:33 | PowerwallService | 600 | Set PW Mode: Mode=self_consumption, BackupPercentage=5, APIResult = 202
04/04/2018 22:33 | PowerwallService | 0 | Service started successfully.
04/04/2018 22:33 | PowerwallService | 101 | Powerwall Service Started
04/04/2018 22:33 | PowerwallService | 100 | Powerwall Service Starting
04/04/2018 22:32 | PowerwallService | 0 | Service stopped successfully.
04/04/2018 22:32 | PowerwallService | 107 | Powerwall Service Stopped
04/04/2018 22:32 | PowerwallService | 106 | Powerwall Service Stoping
04/04/2018 22:31 | PowerwallService | 503 | Outside Operation Period: SOC=100
spoonwzd commented 6 years ago

Would the incorrect formatting in the PVv12 config affect anything?

      <setting name="PVv12" serializeAs="String">
        <!--The data to send to extended parameter 12 - as above for parameter 7-->
        <value />
      </setting>
BJReplay commented 6 years ago

Thanks for the log. It is clear what is happening, but not why. I'm sure I'll kick myself when I find out what the bug is. I'll add some logging (probably won't happen until tomorrow my time (your Friday evening).

The format for PVv12 is correct - that's one way of specifying an empty string - the other being .

spoonwzd commented 6 years ago

No problem. Thanks for all your efforts.

With the the peak/off-peak times set to 7 & 23 and IgnoreDST enabled, everything worked perfectly last night, and the logs report the end of the pre-charging period, exiting charge mode and then back into self_consumption with a BackupPercentage of 5. All good!

Exited Charge Mode: SOC=13.547148343052198, Required=45, Shortfall=0, NewTarget=45, Mode=self_consumption, BackupPercentage=5, APIResult = 202

Can I ask, what is Target and how does it apply here when in self_consumption @ 5% reserve?

BJReplay commented 6 years ago

Target - when out of operating period / charge mode is somewhat meaningless. In operating period but it is what is set as the backup_reserve_percentage - it is what we want the battery charge to be at the end of off peak - the sum of morning reserve, and shortfall solar generation.

In addition, the pro-rated remaining overnight consumption is added to it to set the target. In the example above, it is simply the sum of your overnight consumption percentage and morning reserve percentage - but outside operation hours, it is not sent to the powerwall.

I should clean up the logging at this point - required, shortfall and newtarget are not relevant outside of operation hours (off peak).

BJReplay commented 6 years ago

Found the bug :)

spoonwzd commented 6 years ago

Woop! Let me at it :)

I've found another bug too - it's the weekend, has gone past 7am UTC and I'm still in operation period.

      <setting name="TariffPeakOnWeekends" serializeAs="String">
        <!--Does your tariff have Peak on weekends, or is it all off peak.  If set to true, peak and off peak for weekends are ignored, and the charging window is 9pm to 9am-->
        <value>False</value>
      </setting>
      <setting name="TariffPeakStartWeekend" serializeAs="String">
        <!--If the weekend has peak hours, what is the start hour-->
        <value>7</value>
      </setting>
      <setting name="TariffPeakEndWeekend" serializeAs="String">
        <!--If the weekend has peak hours, what is the start hour for off peak-->
        <value>23</value>
      </setting>

My tariff is the same at the weekend as it is during the week, but hasn't moved out of period. Config is correct, right?

spoonwzd commented 6 years ago

Forced out of operation, but PwS decided that is was still in operation and started to pull from the grid again. Forced out of operation again and service stopped for now.

Same bug?

BJReplay commented 6 years ago

Will be a different bug, but same section of the code - will check it out. Will be a while, sorry, middle of refactoring PW mode setting to also support going into standby on weekends. Might be tonight my time, but maybe not until tomorrow.

spoonwzd commented 6 years ago

Don't sweat it - I can work around the problem manually for now. I understand how personal projects like this develop (I spent so many hours getting the kinks out of my Rainmeter Powerwall skin) - I'm just trying to keep the information flow going as there's a chance that more info might help. Correct me if I'm wrong. ;)

Appreciate all your efforts. Let me know when you need me to test something.

BJReplay commented 6 years ago

All good. Every bit of info helps. And I'm getting something that I suspect I will want to keep using even when Tesla arrange time based control, because this will allow me to do things Tesla's may not allow.

The weekend time setting is an error in my comment in the config file - it should have said Does your tariff have Peak on weekends, or is it all off peak. If set to False, TariffPeakStartWeekend and TariffPeakEndWeekend are ignored, and the charging window is 9pm to 9am

So you need to swap your TariffPeakOnWeekends to True

That said, it would have then suffered the same bug around dealing with 0 to 7 as during peak days.

spoonwzd commented 6 years ago

Config updated and service started - correctly reporting outside operation period again.

BJReplay commented 6 years ago

I think I've got a fix for you, but I want to let it run overnight - I've done a massive re-factor and up until a few minutes ago, it was flipping in and out of charge mode as I've implemented a standby mode to avoid discharging during off-peak, but hadn't correctly handled the logic that tries to return to self-consumption mode after charging. I think it's working, and it's midnight, so time for bed, and I'll have a look tomorrow to see what it has done overnight.

spoonwzd commented 6 years ago

Great news! Not sure what time you get up on a Sunday, but if it's before 9:30 AM we might stand a chance of implementing it here in time for midnight.

Nice work :)