How to diagnose "The service homeassistant.turn_on cannot be called without a target"

In the log I see different:

2024-01-07 14:54:09.884 ERROR (MainThread) [homeassistant.components.homeassistant] The service homeassistant.turn_on cannot be called without a target
2024-01-07 14:54:36.143 ERROR (MainThread) [homeassistant.components.homeassistant] The service homeassistant.turn_off cannot be called without a target
2024-01-07 15:21:27.968 ERROR (MainThread) [homeassistant.components.homeassistant] The service homeassistant.turn_off cannot be called without a target

but I cannot understand what they are related to.
Is there any way to diagnose?
Which is the service that gives an error?

Thank you
M

Search your automations and scripts for: “homeassistant.turn”.

You have forgotten to supply an entity_id in at least two places where you have used these services. Or if using templates the templates are not resolving correctly to an entity_id for these services.

It tells you in the error:

Thank you!

In my automations.yaml there is no homeassistant.turn
I have all switch.turn_

in my blueprint I have:

action:
- service: homeassistant.turn_{{ trigger.to_state.state }}
  target:
    entity_id: '{{ expand(switches) | selectattr("entity_id", "!=", trigger.entity_id)
      | map(attribute="entity_id") | list }}'

I have it in 4 blueprints…

is there a way to see which one is faulty?

I’ve added this in the scripts in the action part:

- service: notify.autolog
  data:
    title: "link_multiple_switches_timer_timeout"
    message: '{{ expand(switches) | selectattr("entity_id", "!=", trigger.entity_id)
      | map(attribute="entity_id") | list }}'

hoping it will log them :slight_smile:

If you manually triggered that automation blueprint it would cause those errors.

Manually triggering an automation skips the triggers and thus there would be no trigger variables for that template.

I’ve checked and it was not manually triggered.
I still have several of them:

2024-12-29 17:48:21.336 ERROR (MainThread) [homeassistant.components.homeassistant] The service homeassistant.turn_on cannot be called without a target
2024-12-29 17:48:21.348 ERROR (MainThread) [homeassistant.components.homeassistant] The service homeassistant.turn_on cannot be called without a target
2024-12-29 17:48:21.349 ERROR (MainThread) [homeassistant.components.homeassistant] The service homeassistant.turn_off cannot be called without a target
2024-12-29 17:48:21.356 ERROR (MainThread) [homeassistant.components.homeassistant] The service homeassistant.turn_off cannot be called without a target

But how can I understand it better?
If the automation is declared on the web interface I cannot search them.
I need to know what was happening when this was triggered

I just got done fighting a similar problem. And, like you, I searched automations.yaml and scripts.yaml and couldn’t find “home_assistant.turn_on”.

So, today for the zillionth time I looked at the logbook to see what was going on at the times that the home_assistant.log reported the error. And one of the things was a fan being turned off with generic turn off (which I don’t use in my automations).

And it finally occurred to me that it was a blueprint for turning on an exhaust fan when my bathroom humidity gets too high. I was using version 1.4 of the blueprint and it’s up to version 2.6. So I redownloaded that blueprint and hopefully the errors will go away.

Maybe you’re up against something like this?

wow!!! for sure this is an area that should get an evolution.
I’m using only a blueprint to switch on/off a light with multiple switches.
All the rest are automations I wrote in the automation menu