Total number of lights ON excluding a specific device

In addition to using entity_id instead of entity, I recommend you take this opportunity to convert your Template Sensor from legacy format to modern format.

For more information, refer to this guide:
Deprecation of legacy template entities in 2025.12

Thank you, I’ll take a look at that in the future, but tbh it scares me a lot the idea of having to rewrite what’s already working and I can potentially bork.