Hi Blacky! Thanks for the amazing blueprint and the support you provide here.
I recently enabled my first automation from this blueprint. I now noticed that it seems to consume a lot of RAM causing HA to become unresponsive. It seems there is a related infinite recursion / stackover flow. In more detail, I observed the following:
First, I had configured the automation without toggle helper (1 motion sensor, one light entity, dynamic lighting mode 13). When the motion sensor was triggered frequently, RAM usage went from 25% up to around 80-90%.
In the screenshot above, I restarted HA at 19:15, but RAM usage went up again afterwards.
In the log, I discovered critical log messages such as this:
Logger: homeassistant.helpers.script
Source: helpers/script.py:1015
First ocurrence: 20:02:12 (1 ocurrences)
Last logged: 20:02:12
Until condition [{'value_template': Template<template=({{ ((dynamic_lighting_boolean == []) and (expand(light_entities) | selectattr('state', '==', 'off') | list | count > 0)) or ((dynamic_lighting_boolean != []) and (is_state(dynamic_lighting_boolean, 'off'))) }}) renders=42132>, 'condition': 'template'}] in script `Flur Sensor Light: Choose at step 1: default: Parallel actions for dynamic lighting and normal lights: parallel 1: Choose at step 15: 13 - Dynamic Lighting - Time Controlled - Brightness` terminated because it looped 10000 times
This is the infinite recursion / stackoverflow I mentioned above. More observations on that later.
Then, I disabled the automation. The RAM did not go up. When I enabled it again and triggered the motion sensor, RAM usage raised again, and the errors occurred again.
Due to a recommendation from a friend, I then added a toggle helper. (Previously, I figured I do not need a toggle helper because I did not trigger my own scenes or scripts.) This changed the behavior to the following:
One “cluster” of triggering the motion sensor still causes RAM usage to raise, but only up to around 45%. Interestingly, at exactly the point where the rise stops, I see the stackoverflow message.
Later, I triggered the motion sensor again, which added another 25% until it encountered the error again.
So, from my outside perspective I suppose the following happens:
- There is an underlying infinite recursion (apparently related to dynamic lighting guessing from the error message), which quickly takes up a lot of RAM while the recursions pile up.
- Without toggle helper, multiple instances of the automation overlap, so the RAM usage quickly gets pretty high.
- With toggle helper, only one instance of the automation runs at a time. When the instance is killed due to the high number of recursions, the RAM usage rise stops. However, it seems that the resources are not properly freed (might be a Python thing?). So the next instance of the automation adds another step until it crashes again.
On a side note, it seems that the RAM that was covered one is not freed quickly. Restarting HA brought the RAM back down to ~25%. But it seemed the system only forcefully freed RAM when the usage was very high (~90%). However, but I did not observe that for more than half an hour, so it might be different after more time.
tl;dr: It seems that in my setup, the automation enters an infinite recursion, which consumes a lot of RAM until it hits a stack overflow.
Dear Blacky, do you have any ideas on that topic? Sorry for the long post, but I hope it was possible to follow along.
For completeness, I am using version 7.6 of the blueprint. Here is the YAML of my automation:
Click to expand
alias: Flur Sensor Light
description: ""
use_blueprint:
path: Blackshome/sensor-light.yaml
input:
motion_trigger:
- binary_sensor.flur_bewegungsmelder_bewegung
light_switch:
entity_id:
- light.flur_licht_leuchte
time_delay: 1
include_light_control:
- use_transition
- use_colour_temperature
- use_brightness
light_transition_off: 5
light_transition_on: 0.5
light_colour_temperature: 3400
include_night_lights: night_lights_enabled
night_lights:
entity_id:
- light.flur_licht_leuchte
night_time_delay: 0
include_night_light_control:
- use_brightness
- use_colour_temperature
- use_transition
night_light_colour_temperature: 1900
night_light_brightness: 1
night_light_transition_off: 10
night_lights_conditions:
- time_enabled
night_lights_before_time: "05:30:00"
include_light_colour_control: use_colour_temperature
include_night_light_colour_control: use_colour_temperature
include_dynamic_lighting: enable_time_controled_colour_brightness
dynamic_lighting_max_colour_temp: 3400
dynamic_lighting_min_colour_temp: 2500
dynamic_lighting_time_start_morning: "05:30:00"
dynamic_lighting_time_end_morning: "06:30:00"
dynamic_lighting_time_end_evening: "00:00:00"
dynamic_lighting_heartbeat: 5
dynamic_lighting_time_start_evening: "19:00:00"
night_lights_after_time: "23:00:00"
dynamic_lighting_min_brightness: 99
boolean_scenes_scripts: input_boolean.flur_sensor_light_toggle_helper
I appreciate any help! I would really love to get the blueprint to work stably in my setup, since so many work and love already went into it! Let me know if I can provide more info or test anything specific.
Best, Rhidus