ESPHome effect via a Home Assistant Service Call

I created an ESPHome light component that includes a custom effect. That works fine. I would like to call on that effect in a Home Assistant automation, but do not see any Service Calls that would do that. From my research, I should have service calls which start with the esphome domain (e.g. esphome.___), but I do not have any. The specific ESPHome device is enabled for service calls via the configure menu although I think that’s for doing the opposite of what I’m trying to accomplish.

How do I start an ESPHome effect via a Home Assistant Service Call?

To change any settings of a light, brightness/color/preset/effect/etc, use the light.turn_on service.

https://www.home-assistant.io/integrations/light/#service-lightturn_on

Dang it! Rookie mistake. I’ll blame my own expectation bias. Thank you!

@Mikefila Maybe a related question, but for a monochromatic light (e.g. white LED), how do I randomize a pulse? I see there is a random effect, but that is only for colors. I don’t see a way to do it with the light.turn_on service. :wink:

Why do you assume its only for “colors” and why do you assume that monochromatic cant use colors?

If you look at the documentation for light.turn_on:

All those things listed in Bold are the configuration options for light.turn_on. Well technically they’re for the light component in general but they break it down and show you what Light config options are available for each Light Action.

If you only scroll through looking at examples to copy/paste then plan on missing a ton of information and frequently having problems. If you take a moment to read through the config options, all the way at the bottom there is a reward for people who read through it and its name is effect

Because it says as much here and since mono means “one” and chromatic means “color” only the brightness can be changed on a monochromatic light

Putting all that together, if an ESPHome effect called random is only meant to change colors, it would not work on a light with only one color since there’s no color to change.

I’m not interested in the ESPHome light.turn_on function. My original question was answered with the light.turn_on HA service and its nested effects options.

But, for my follow on question…it does appear I can use the lambda effect to create a random brightness effect. I was just surprised that wasn’t already available.

1 Like

Yes, the brightness of a light irregardless of color. You may be right about the random effect not working with a monochromatic light, im not sure because its not something id ever need to do.

Is there a reason you wont or havnt just tried it to find out for sure? You dont need permission or to ask the group first if it will work. Its not illegal, no one will be knocking on your door at 2am, the moon wont fly away from earths gravity… it will be just fine, thats how we all learn.

Whats the difference between using the 2 light.turn_on? Does HA do it with a wink and a smile? One of the best features of esphome is its ability to run with HA or independently without HA. That isnt the case though when people unnecessarily divide it up, controlling this and that via an esp but isolating all controls or automations for HA to run, essentially cutting dependability in half only to find out at the most inconvenient time just how much it does matter

As you astutely pointed out, the documentation tells us what we need to know. The random effect doesn’t offer brightness config options (e.g. min/max brightness) and the description says it changes colors, so I don’t need to “try it out.”

I don’t know what the rest of your reply is going on about. I’m trying to create an effect for a light component that randomly changes a monochromatic light’s brightness within a min and max range. I want that effect to be presented in the HA light card options and available in HA light.turn_on service calls, but I first need to configure it…within ESPHome. As I said, it appears the Lambda Effect is the way to accomplish this, regardless of the state of the moon, your impression that I was asking permission of anyone, or any other such nonsense.

What’s with your lame quips? The forums (and documentation) are here to help people. If you don’t want to do that or prefer to do it in a nasty or immature manner, just move on.

The description of Random effect literally says “makes a transition…to a randomly-chosen color.” Changing from mono white to mono white is not a change in color. However, I went ahead and tried it anyways and you’re right, the effect does randomize the brightness. So, thank you for insisting I give it a try (in your own way). I submitted a PR to fix the documentation as intended.

But, the other options (e.g. min and max brightness) seemingly cannot be chosen at will. Clearly this is what I meant by “brightness config options.”

After trying the random effect to change brightness, I will also want to randomize the transition_length and update_interval, so again the Lambda Effect is probably what I need to experiment with.

Have a good day.

1 Like