Change state when template sensor state changes

Hello!
I have an input boolean sensor that I want to change status to “on” for 10seconds (after 10sec, back to “off”) when my template sensor time last update changes. State on this sensor is time and can’t use “to” and “from” for this.

How the heck do I do that? Can someone please help me?

Not 100% sure I understand what you’re asking, but I think you can just use a normal state trigger, just don’t specify to: or from:.

Thank you. I Will try this, but if that works how do I change the state on the input boolean to “on” and then back to “off” after 10sec?

You can do that with a timer or just add a delay for 10 sec in your automation

It’s this I don’t understand how I do. I don’t see what I should use in the deep downs during creation of the automation.

do a search on forum, lots of examples here :

Turning the input_boolean on when a sensor changes is easy. The turning off part is not as obvious because it depends on exactly how you want that to work. Do you just want the input_boolean to turn be turned off 10 seconds after it is turned on, no matter how it is turned on? Or do you just want it to be turned off 10 seconds after it is turned on due to the sensor changing? And what if the sensor changes again during the 10 second period? Do you want the 10 second period to continue, or do you want it to restart?

Depending on how you answer those questions I can provide you an example. Also, what is the entity_id of the sensor and the input_boolean?

Oh thank you.
I would like it to turn off after 10seconds after it turns on. Whenever it turns on. This is for a doorbell. When I press the doorbell button, timestamp of my sensor change. And when that happens i want the input boolean to switch to on. Then after 10sec it should turn of and be ready for the next press of the doorbell button.
I’m i understandably?

Ok, that’s pretty easy. But you didn’t specify the enity_id’s of the input boolean and sensor, so I’ll just make up something that you can replace with the actual entity_id’s.

This will use two automations. One that turns on the input boolean when the sensor changes state. The other turns the input boolean off 10 seconds after it turns on.

- trigger:
    platform: state
    entity_id: sensor.doorbell
  action:
    service: input_boolean.turn_on
    entity_id: input_boolean.doorbell
- trigger:
    platform: state
    entity_id: input_boolean.doorbell
    to: 'on'
    for:
      seconds: 10
  action:
    service: input_boolean.turn_off
    entity_id: input_boolean.doorbell

Thank you :hugs:
This worked like a charm. Wasnt so hard as I thought. I made it harder than it was in my head. Did not know there was an input_boolean.turn_on/off for that. Now I now :grin:

Yeah, it’s not documented all that well. If you look at the end of the doc page, it does kind of mention it in an offhand kind of way. :slight_smile: