Switch off Sonoff Light Switch after certain amount of time

2,422 views
Skip to first unread message

Jeandre de Beer

unread,
May 2, 2018, 7:18:29 AM5/2/18
to SonoffUsers
Hi Everyone

I want to be able to switch off my sonoff light switch after a certain amount of time. I also want to have more than one schedule - for instance during the day - the light must switch off after 5 minutes - during the evening after 10 minutes.  Is there any way of doing this?  I have been linking ewelink with IFTTT and then IFTTT with Stringify - that is so many links that it does not work reliably.

Thanks for your assistance.

Phil

unread,
May 2, 2018, 9:12:12 AM5/2/18
to SonoffUsers
Hi,

With the tasmota firmware you can set the PulseTime setting to switch the device off atfer a period of 'on running'   

to use Tasmota effectively you need a mqtt broker and some sort of control system,  this could be a few scripts you schedule to run when needed or a full blown system like openhab..


to achieve your requirement you will need something to determine when its day or night, and then publish the mqtt topic to change the pulsetime setting on your device accordingly.

could be as simple as scheduling a couple of timed scripts to publish the pulsetime change..




gmac42

unread,
May 2, 2018, 9:57:14 AM5/2/18
to SonoffUsers
Hi,

you can do that with Tasmota even without an MQTT server, I think.
Use a combination of timers and rules to set the appropriate pulsetime.
I haven't tried it yet, but something like this should do the trick:

Timer1 {"Arm":1,"Time":"08:00","Window":0,"Days":"SMTWTFS","Repeat":1,"Action":3}
Timer2 {"Arm":1,"Time":"20:00","Window":0,"Days":"SMTWTFS","Repeat":1,"Action":3}
Rule on Clock#Timer=1 do pulsetime 400 endon on Clock#Timer=2 do pulsetime 700 endon
Rule 1

I think you can even use sunrise / sunset events for timers, if you configure your location correctly.

Best regards
Gert

gmac42

unread,
May 2, 2018, 10:15:19 AM5/2/18
to SonoffUsers
Hi again,

however, in the likely case that you do have an MQTT server, it might be better to use cron (or whatever you prefer) and publish the pulsetime command with retention, so that the sonoff device always gets the correct value even if it was powered off when the timer would have triggered.

Best regards
Gert

Jeandre de Beer

unread,
May 2, 2018, 10:19:18 AM5/2/18
to SonoffUsers
Thanks for all the replies,

I have not flashed my unit with tasmota yet - So that should be the start?

What do I need after flashing the device - must I load smart home server software?

gmac42

unread,
May 3, 2018, 9:41:20 AM5/3/18
to SonoffUsers
Hi,

provided you are comfortable with losing the manufacturer's cloud services (and probably running your own smart home server), that would be the way to go, yes.

When flashed with Tasmota, your devices will be cut off the official sonoff cloud services. I think most Tasmota users use their own MQTT server (like mosquitto) in conjunction with smart home server software like Home Assistant, Domoticz or OpenHAB.
A lightweight approach would be to have only the mosquitto server and send control messages from one of the many MQTT client apps for your mobile operating system of choice. (I like "MQTT Dash" for Android, for example.)
But even that is not strictly necessary; you can also control Tasmota simply via HTTP if you like.

Best regards
Gert

Jeandre de Beer

unread,
May 6, 2018, 5:26:45 AM5/6/18
to SonoffUsers
Thanks - I have installed openhab2 - must I use MQTT server to connect sonoff to openhab?
Reply all
Reply to author
Forward
0 new messages