Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support miniumum and maxiumum run time #80

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

nicorusti
Copy link

@nicorusti nicorusti commented Jun 16, 2024

Addresses #32 , based on work by @alistair23.

Some work done:

  • merged recent changes
  • Improved template descriptions and added a few more code comments
  • Tested that blueprint works also with Forecast.Solar

@alistair23 would it be ok to contribute your work to the main repository?

Pending issues:

  • README
  • 81c46e1 that slows down automation to once every minute should be removed from this PR, otherwise power measures every minutes might be too coarse
  • run_time counter does not reset to 0 if appliance switches off exactly at 00:00

Improvements:

alistair23 and others added 16 commits July 15, 2023 22:18
This is the first step in addressing
InventoCasa#32
This patch adds support to monitor the total daily runtime of appliances
and prints the information to the user.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
Signed-off-by: Alistair Francis <alistair@alistair23.me>
Signed-off-by: Alistair Francis <alistair@alistair23.me>
Signed-off-by: Alistair Francis <alistair@alistair23.me>
Signed-off-by: Alistair Francis <alistair@alistair23.me>
Signed-off-by: Alistair Francis <alistair@alistair23.me>
Signed-off-by: Alistair Francis <alistair@alistair23.me>
Signed-off-by: Alistair Francis <alistair@alistair23.me>
remove on_time_counter
@alistair23
Copy link
Contributor

@alistair23 would it be ok to contribute your work to the main repository?

Fine with me

@nicorusti
Copy link
Author

@alistair23 I have been running this for a couple of days, and I notice an issue with your control algorithm that is using instant power consumption to estimate remaining power for the day ( introduced in 0220d25) :

Basically this triggers the appliance to turn on as soon as there is a sudden consumption peak, that causes remaining_power to go down, while avg_excess_power stays positive. Then appliance stays on as soon as it can be powered in with some solar energy, and then turn off as soon as there is another peak:
load

I might try using a better metric, maybe average daily power consumption, or average from the last x hours. Let me know if you see the same issue and if you have some ideas

@nicorusti nicorusti marked this pull request as draft June 21, 2024 16:11
@alistair23
Copy link
Contributor

I might try using a better metric, maybe average daily power consumption, or average from the last x hours. Let me know if you see the same issue and if you have some ideas

Ah, good point. An average of the last x hours seems like the best bet

@Kolbi
Copy link

Kolbi commented Jul 10, 2024

push :)

@Kolbi
Copy link

Kolbi commented Jul 29, 2024

@nicorusti no progress? :)

@nicorusti
Copy link
Author

Unfortunately I won't have time to work on this in the next future.
I've been running this code with a pool pump for a month, it works fine with the exception that run_time counter does not reset to 0 if appliance switches off exactly at 00:00.
I think one approach to move forward would be to merge this as it is and leave what I listed as improvement to a future iteration

@Kolbi
Copy link

Kolbi commented Jul 30, 2024

@nicorusti thanks for the update

Do you want to mark this PR as Ready for Merge and note the open point somewhere in README?

@InventoCasa I think it makes sense this 99% solution to merge into repo?

@nicorusti nicorusti marked this pull request as ready for review July 30, 2024 15:31
@Kolbi
Copy link

Kolbi commented Aug 16, 2024

FYI @InventoCasa I'm currently testing @nicorusti version with maximum runtime.

@Kolbi
Copy link

Kolbi commented Aug 19, 2024

Currently I'm not sure if my patch or your version breaks something but in some cases the automation doesn't switch the entities off, need to look into the logs.

@Kolbi
Copy link

Kolbi commented Aug 19, 2024

2024-08-19 06:42:28.447 ERROR (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] Exception in <file.pv_excess_control.on_time> line 699: sunset_time = datetime.datetime.fromisoformat(sunset_string) ^ TypeError: fromisoformat: argument must be str

Code-Line:
sunset_time = datetime.datetime.fromisoformat(sunset_string)

But as far as I'm currently not using minimum time this is not crucial for me.

But
2024-08-17 03:35:28.445 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.tasmota_5 automation.pv (Prio 3)] Home battery charge is sufficient (100/100.0 %) OR remaining solar forecast is higher than remaining capacity of home battery. Calculated average excess power based on >> solar power - load power <<: -308 W 2024-08-17 03:35:28.446 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.tasmota_5 automation.pv (Prio 3)] ran for 0.0 min out of 0.0 min and the current total load is 277.000 Kw. Appliance is projected to use -0.000kWh to meet minimum runtime. With current load the remaining solar power is -4.7kWh 2024-08-17 03:35:28.447 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.tasmota_5 automation.pv (Prio 3)] Average Excess power (-308 W) not high enough to switch on appliance. 2024-08-17 03:35:28.451 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.tasmota_5 (Prio 3)] Appliance is already switched off.

But switch.tasmota_5 had the state on...

@nicorusti
Copy link
Author

nicorusti commented Aug 20, 2024

Code-Line:
sunset_time = datetime.datetime.fromisoformat(sunset_string)

@Kolbi Did you configure time of sunset? (likely this error happened because you had it not set). In 89cf98c I improved the logic to skip checks requireing time of sunset if minimum runtime enforcement is not set. Can you try again with the latest changes and let me know if this fixes the error?

@Kolbi
Copy link

Kolbi commented Aug 21, 2024

@

Code-Line:
sunset_time = datetime.datetime.fromisoformat(sunset_string)

@Kolbi Did you configure time of sunset? (likely this error happened because you had it not set). In 89cf98c I improved the logic to skip checks requireing time of sunset if minimum runtime enforcement is not set. Can you try again with the latest changes and let me know if this fixes the error?

Thanks for the fix, now minimum and maximum runtime is working without this issue.

@nicorusti
Copy link
Author

Great, I now also verified that after aa587fe runtine correctly resets to 0 at midnight (even if appliance turns off).

@InventoCasa , From my side, this PR is now ready to merge. I moved some future improvement points to #89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants