Hi everyone,
I’m having trouble with a Node-RED subflow I created to control my lights based on a circadian rhythm. The subflow is designed to update the lights every 30 seconds, adjusting brightness and color temperature throughout the day. It has conditions to stop adjustments if I manually change the lights, and it also allows me to set minimum/maximum brightness and color temperature.
To make this more flexible, I designed it so that any number of light entities can be connected to the subflow’s input, and it stores these entities for ongoing updates. It also includes a virtual light entity that represents the subflow’s current status, showing the average brightness and color temperature of all the connected lights.
To avoid infinite loops when updating the virtual entity and the real lights, I implemented a system of “busy” flags. I also have a lot of function nodes with asynchronous outputs (using node.send
) that I make sure to terminate properly (using node.done
).
The flow works fine initially, but after a few days, Node-RED starts using a lot of CPU, and the subflow seems to get stuck in a loop, constantly sending update messages to the lights. The only way to fix it is to restart Node-RED. I’ve monitored the RAM usage, and it remains stable, so I don’t think it’s a memory leak.
Here’s my setup:
- Home Assistant version: 2024.11.4
- Node-RED version: 18.1.1
- Installation method: HA OS
- Hardware: HP EliteDesk 800 G4, Intel Core i5-8500, 16 GB RAM DDR4, 512 GB SSD
Here’s my Node-RED flow:
https://github.com/Seba-VT/SVT-Light-Controller/blob/main/SVT-Light-Controller
I have a few questions:
- Are there any common reasons why a Node-RED flow might start consuming excessive CPU after running for a few days?
- Could the interaction between the virtual light entity and the real light entities be contributing to this problem, even with the ‘busy’ flags?
- Is it possible that my use of asynchronous outputs in the function nodes is somehow related to the CPU usage spike?
If anyone has experience with similar issues or has any suggestions on how to debug this further, I would greatly appreciate your input!