Loop timer started via dashboard switch

Hi,

I´m new to homeassistant, as the ewelink never satisfied me using my sonoffs.
So Homeassistant is now all set and I´m able to power on and off my sonoffs.

I use my sonoffs for my electric heaters, and want them to poweron for 3 min. and bee off for 3 minutes.
I read about loop timers, which are also offered by the ewelink app.
The problem is those Loops can´t be switched on with a button on the dashboard.

For me it is essential, that i just hit a button on the dashboard for each heater and the work with the described loop timer, until i hit the button again and the heaters switsch off and stay off.

Does anybody have a got idea on how to achive this goal?

Sounds pretty easy, actually.

Automation1:
triggers:
switch on
timer2 finish
confirm:
switch on
Actions:
Turn on heater, start timer1 for 3 minutes

Automation2:
Triggers:
switch off
Timer1 finish
Action:
turn off heaters
If switch on: start timer2 for 3 minutes

That’s the logic of how I’d do it (I think - just wrote this quickly, but it sounds right)

Edit:

In thinking about it, this is even simpler (I left the other one up since I hate when people remove stuff, I like to follow their train of thought)

Automation:
Triggers:
switch on
timer finish
actions:
if switch on: toggle heater and start timer for 3 minutes
else: turn off heater

Note that this more compact method would NOT turn off the heater immediately when turning off the switch, but would turn it off when the current 3-minute cycle ends.

Thanks Eex,

i can not try your automation, as it returns
Message malformed: expected dict for dictionary value @ data[‘event_data’]

Maybe I´m just to stupid, since i copy pasted your code into yaml editor and this might just be wrong

What I posted isn’t code, it’s just logic. You need to take that logic and create the automation.

okay, thanks, missunderstood, since it looked like code