# Automate Relay Control with Tasmota's Timer Feature

```plaintext
//turn off Rule1
Rule1 0

//Clear Rule1
Rule1 ""

//Rule to turn on relay on boot and then toggle the state every 1800 seconds
Rule1 on System#Boot do backlog RuleTimer1 1800; Power1 ON endon on Rules#Timer=1 do backlog Power1 Toggle; RuleTimer1 1800 endon

//turn on Rule1
Rule1 1
```

[Rules](https://tasmota.github.io/docs/Rules/)

[Timers](https://tasmota.github.io/docs/Timers/)

[Commands](https://tasmota.github.io/docs/Commands/)

```plaintext
//Version 2

Rule1
ON System#Boot DO Power1 1 ENDON
ON Power1#State=1 DO RuleTimer1 1800 ENDON
ON Rules#Timer=1 DO Power1 0 ENDON
ON Power1#State=0 DO RuleTimer2 1800 ENDON
ON Rules#Timer=2 DO Power1 1 ENDON
```
