Distinguish between if a sensor has been changed due to automation, sensor template, or manually changed?

I have a use case I am trying to figure out if it’s possible to achieve in HA or not.

Is it possible use distinguish between if a sensor has been changed due to automation, sensor template, or manually changed?
The reason I want to know this is because if it’s changed manually I want to set that the user has overridden the system. If there is an override, I want to keep the sensor in that status until next day.

Any ideas?

Are you talking about a sensor based on the Template Sensor integration? Because an automation can’t change a typical sensor’s state because there’s no standard service call to do it.

Ok, good point. I would say its a template based sensor, so yes automation will not be applicable.

Template Sensors compute their state based on the contents of their template (which typically references other entities). How do you propose to manually change the state value of a Template Sensor?

If you want to change a sensor’s state through an automation there’s a workaround.

Create an input_text and change that value through an automation

Then create a template sensor that has that input_text as its state.

I would hesitate to call it a workaround because that’s what Template Sensors do; they monitor other entities. Moreover, whether the input_text’s value changes via an automation or a user altering it, it’s transparent to the Template Sensor (i.e. it doesn’t know why the entity’s value changed).

1 Like

I do that to have switches on my dashboard to enable or disable various automations. As that caused a lot of extra coding i many places, the items that were repeated alot of places I put into a generic script which is then called by a variety of automations that are separate but hacing the sdame kind of logice required (such as handling motion sensors in different rooms which I treat largely the same way except for timouts, which I also have in the generic script and are alsop adjustable on the dashboard). To make the scripts generic, I am passing several variables to the scripts from each of the related automations. Extra work to struggle through getting it to work, but well worth it!