Compare your trigger to the documentation. Specifically look at the for portion. Your current for is not correct in your trigger. You’re correctly using for in your condition but not in your trigger. So you can even use your own automation as a guide to help you.
Looks OK to me. If this were my automation, I’d swap the device bits for entity-based alternatives, and write the fors consistently, but this is all aesthetics rather than functionality. I’ve also added an id so it works with the automation debugging tool:
No. Time pattern triggers are a last resort. You could add a third trigger:
- platform: state
entity_id: switch.shelly1_e8db84a93a46
to: "off"
for:
hours: 1
Then you have matching triggers and conditions, such that any of the triggers can fire, but the action will only happen if all the conditions are true.
That code will trigger when the power drops from above 150W to below it, and stays there for 15 mins (not exceeding 150W) — and after that 15 mins, will check if the switch has been on for at least one hour. If it has, it’ll switch off; if not, it’ll give up and wait for the power to cross the threshold again.
If that’s not what you want, work out what you actually do want, and either describe it here or have a go at coding it yourself now you’ve explained it to the duck…