Sonoff Basic - default to ON when reconnected

222 views
Skip to first unread message

Jan Stenvall

unread,
Jan 16, 2017, 2:42:42 PM1/16/17
to SonoffUsers
Hello,

First of all I'd like to say thanks for making this great project available for us to use! And in combination with the community, this little sonoff thing is marvelous!

It seems that the relay is not activated (not ON) which means that the lamp or whatever is not lit. This renders my tentatives low on the WAF scale.

Now, I have a question (after searching in the code base), where I can change/manipulate the default state of the relay once the sonoff is hooked up to the mains outlet?

Is this possible at all to do?


Thanks in advance for any suggestion or help!


Best Regards,

//Jan 

Thomas Fänge

unread,
Jan 17, 2017, 3:26:30 AM1/17/17
to SonoffUsers
Hi Jan,

There is a command for this (as well ... ;)):

PowerOnState 13.1.1Turn relay(s) on after power on

According to the Wiki, this will set the default value of the relay (could also be off or last saved value).
(I have not tried it myself, but I guess it should work.)

Best regards,
Thomas

Jan Stenvall

unread,
Jan 17, 2017, 2:30:16 PM1/17/17
to SonoffUsers
Hello Thomas,

(Tack så mycket) Thanks alot for your answer. It led me to search for the OnState character sequence, and I found this in user_config.h:

#define APP_POWERON_STATE      3            // [PowerOnState] Power On Relay state (0 = Off, 1 = On, 2 = Toggle Saved state, 3 = Saved state)


So, I guess that setting the parameter  APP_POWERON_STATE to 1 should do it. I'll test that and post the results tomorrow.

Thanks again!

//Jan

Thomas Fänge

unread,
Jan 17, 2017, 2:42:16 PM1/17/17
to SonoffUsers
Hej Jan!

Kul att hjälpa till!

Yes, you could change the default value that way, but don't forget to update CFG_HOLDER, otherwise the changes are not updated.
Easier is maybe just to send a MQTT message and update the settings, only needed to be done once.

Cheers,
Thomas

Jan Stenvall

unread,
Jan 18, 2017, 2:18:31 PM1/18/17
to SonoffUsers
Hello,

Outstanding piece of software!

I did as you mentioned, I executed the command and it worked like charm! Excellent!

However I did have some difficulties understanding how to execute the command. As an info to for other users (or beginners like me), to execute the command you can either use an mqtt client to send the info to the sonoff device. You can also use the console available on the device. The command is in my case (1 == power on after reconnect) 

cmnd/<devicename>/PowerOnState 1

A big thanks to all that makes this piece of software, and equally a big the guys on the forum!

//Jan
Reply all
Reply to author
Forward
0 new messages