nielsfaber / scheduler-component

Custom component for HA that enables the creation of scheduler entities
GNU General Public License v3.0
622 stars 40 forks source link

Memory Problem #286

Closed AlexandraDemeter closed 11 months ago

AlexandraDemeter commented 11 months ago

Checklist

Card Version

v3.2.15

Component Version

No response

Bug description

I am running HA on a Raspberry Pi 4 and I installed the scheduler card. When the scheduler integration is enabled my memory keeps rising about 2% per minute and when it reaches 100% home assistant reboots and I get the message "Out of memory: Killed process xxxx (python3) etc.". If I disable the integration then the memory stops rising and everything is fine. What could I do to fix this?

Steps to reproduce

I disabled the integration and everything went back to normal.

Additional info

No response

nielsfaber commented 11 months ago

I have no idea about this problem. You are the first and only (out of thousands of users) to report such issue. So I guess it is due to your own usage. I don't think the Raspberry Pi 4 is a problem, I use the same. Perhaps you have a schedule set up which is corruptive, maybe due to time slots that cannot be computed (e.g. start time that is later than the end time)? I suggest to erase all schedules, I would assume that resolves the issue. Make sure you are using latest HA and scheduler-component version.

PS: please distinguish between scheduler-card and scheduler-component, they are 2 separate things. Scheduler-component runs on your raspberry, scheduler-card in your browser.

AlexandraDemeter commented 11 months ago

Thank you for your fast reply! Is it possible to also cause this problem if there are too many schedules? I currently have around 170 of them.

nielsfaber commented 11 months ago

Each schedule requires some calculation so I guess your issue could be related to the amount of schedules. I never had more than 20 myself, I did not test for larger amount. Regardless, I wouldn't expect memory usage to increase over time. Each schedule just keeps a timer towards the next timeslot. I don't see how this could cause memory use to grow. I'm afraid this goes a bit beyond my programming skill. Since you have so many schedules, I assume you have been using the integration for a while and had no issues in the past. Perhaps you can reduce the amount until the issue doesn't show itself?

Out of curiosity: why the large amount of schedules? Is there something I could improve to allow a more compact installation?

AlexandraDemeter commented 11 months ago

I am making this project for someone else and they want to control the lights in 7 areas with Shellys. Each area has 3 phases and they want to control each phase independently. I have 2 scheduler cards: 1 for Monday-Thursday and 1 for Friday-Sunday and 2 modes for controlling the lights with the schedules: one that uses only 2 schedules (for example to turn on the light at 20:00 and turn it off at 06:00) and one that uses 4 schedules (turn on at 20:00 -> turn off at 02:00 -> turn on at 05:00 -> turn off at 06:00). So that's why I have so many of them. This is what the page of one phase looks like: Untitled

AlexandraDemeter commented 11 months ago

I would use the scheme option, that way there would only be 14 schedules in total, but they want to be able to input the hours for turning on/off the light manually. Would it be possible to make a feature that merges the two options, like writing the hours when to turn on/off and automatically make a scheme?

AlexandraDemeter commented 11 months ago

So I have an update. I deleted the schedules I had before and made new ones using the scheme option so I don't have so many anymore. The problem might also have been from the script I was using them in. I feel like an idiot now. Thank you for your help and also for this amazing integration and I'm sorry for this situation. Feel free to close the issue.

nielsfaber commented 11 months ago

Sorry for the delayed response, I was on holidays. Good to hear you found an alternative solution that works for you.

I feel like an idiot now. Thank you for your help and also for this amazing integration and I'm sorry for this situation.

No need for apologies. I think you found a valid issue / limitation of this component. It is always interesting to see the various usage people have for to the card, it helps to find points for improvement.

they want to be able to input the hours for turning on/off the light manually. Would it be possible to make a feature that merges the two options, like writing the hours when to turn on/off and automatically make a scheme?

I agree this would be better (I don't like the card being split between the time scheme and normal single time mode). However it will be a significant change, I estimate it would cost me around week of coding, which I don't have in my free time. So this may come in the future but I cannot give any promises or timeline for it.

I will close this issue since I have no plans or ideas on how to reduce memory use. If other people have issues too, this can be reopened.