Automatic creation of helpers for blueprints

Hi all,

I was wondering if it is possible to automate the creation of helpers in home assistant.
I have created a blueprint that i use to automate all my lights.
Each light can be turned off/on with a hardware button, webhook, or motion.
If the light is turned on with a hardware button, it doesn’t automatically turn off. If it is turned on with motion it does. It also doesn’t turn off when the vacuum is vacuuming (because it needs a minimum of light to plot it’s path properly).

I accomplish all this with some “memory” helpers.
The issue is, i need ± 6 helpers to do this. It is kind of cumbersome to create helpers manually for each light i want to automate. Is there a way i can do this with a script that i need to provide minimal input? Preferably in a way i can change things via the UI, like add entities to ex: a motion group?

I marked the helpers in red.

1 Like

Not exactly like creating helpers via code, but there’s something I think you can try (from what I’ve read, since I haven’t tried it…):

Hi. 2 years later and it’s still on my mind. Thanks for the reply. But starting to mess with python scripts is beyond scope i’m willing to dig in. Maybe 2 years ago i might have enjoyed doing that. But since i am spoiled now by using my blueprint for 2 years, i’m not looking forward to messing around with code. Also, i want my blueprint to be usable by people that have no clue what they are doing. In my opinion that’s what blueprints are for. Click, click, click save.

anyway, is there a place here where i can post suggestions?

Helpers are great, but my entire house is completely automated. i’m using 3 philips hue bridges to control all my devices. And that’s just the lights. the helper section is a big mess because it grew organically. When i come up with new smart functionality for my blueprint, i need to create 20 to 30 new helpers because i added 1 thing in my blueprint.

It would be great if the blueprints would just support helpers within the blueprint scope, like method variables that only live in the scope of a method in other programming languages. However, they should be persistent when the restore checkbox is checked. Not like the “delay” actions. The helpers really need to be saved like a “normal” helper.
So when a new blueprint is created, a button to add “required” helpers, defined in the blueprint, would go a long way. Even suggest names based on other input data in the blueprint. Or when a blueprint is updated a “add missing helpers” button. Something like that.

I enjoy converting friends to home assistant and suggesting them to use my blueprint to control the lights. Because in my opinion it’s a great blueprint that’s smart enough to account for a lot of variables. it uses a motion group to turn on the lights, so multiple motion sensors can be used. It uses another group to collect the lux value of sensors and takes the max lux value so it can decide if it’s dark enough to turn on the lights (depending on where the sun shines 1 sensor might be really dark but it’s actually light in the room). It takes into account if the lights can actually be turned on “automated mode”. it takes into account if my vacuum cleaner is running around. It’s based on pictures to detect where it is, so it needs lights. This triggers the lights to turn on and ignore all turn off commands. Once the vacuum is done, the light control is released (counter helper that is increased). But other entities can also trigger the lockout (counter). there are 3 timers, 1 for turning off the lights if started by automation, 1 for turning off the lights if turned on by the wall button. The 3rd timer is the dimming timer. The lights dim at a certain point to indicate they are about to be turned off (time to wave around those hands boys!). The thing is, if the lights are started from another automation, those timers’s don’t kick in because i don’t want to complicate my other automations by having to start those timers. besides, my vacuum for example is never finished before the timer. So the timer doesn’t turn off the lights because the vacuum increases the lockout counter. I tried to solve this with a trigger in the condition that if no motion is detected after let’s say 30 minutes, the lights should turn off. But when no one is in the room, there was no motion in the first place. Or when i reboot HA for maintenance. Lights might stay on for the entire day because they were turned on but i haven’t triggered any motion in that room anymore.

I want to keep improving my blueprint for my own convenience but that means i have 20 to 30 helpers that i need to create manually again. And the next time i want to make it even smarter, i’m again faced with such a tedious task. at this point it prevents me from making the blueprint smarter. call me lazy but at some point, messing around with the “internals” gets tedious and i just want things to work easily.

Anyway, this is a really incoherent brain dump on a friday afternoon. hope it makes sense.

TLDR: define helpers in the blueprint. have buttons to create them combined with some friday afternoon ranting :slight_smile:

Use MQTT discovery to create entities is my favorite way to do it in blueprints that I share.
Example:

There is also this. Add the template, and create whatever you want on the fly…

Come back in a couple of years and let me know if these have helped you.