The problem is that your light_target isn’t an entity_id
It’s a more complex object, and is meant to be used with a target property.
There are several ways to get around this:
- make your input selector an entity selector instead of a target selector
- as described here use a template condition to extract the entity_id from the target (something like
{{ expand(light_target.entity_id) | selectattr('state','eq','on') | list | length == 0 }}). In this example light_target is a variable and needs to be declared as such (see here).