Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wall Switch (ON/OFF) #182

Closed
xoseperez opened this issue Aug 12, 2017 · 8 comments
Closed

Wall Switch (ON/OFF) #182

xoseperez opened this issue Aug 12, 2017 · 8 comments
Labels
enhancement New feature or request major

Comments

@xoseperez
Copy link
Owner

Originally reported by: damienyong (Bitbucket: damienyong, GitHub: damienyong)


Hello,
I just discovered your firmware and I'm pretty impressed, looks and feels very clean.
But I'm trying to use my Sonoff 4CH (not-pro) as a Light and Roller shutter switch.

I tried to change the button mode in the settings, but noting changes when I'm choosing a different button mode.

I would love to use the buttons, that the relay is open as long as you press the button, and when you're releasing it it stops.

Is this doable ?

Thank you

@xoseperez
Copy link
Owner Author

Original comment by damienyong (Bitbucket: damienyong, GitHub: damienyong):


Or simply
if GPIO[i] is high do RELAY[i] switch on
if GPIO[i] is low do RELAY[i] switch off

@xoseperez
Copy link
Owner Author

With the current version you can define the button to be a BUTTON_SWITCH, which means it will trigger a click event on every edge, that means if you press the button it will toggle the relay, and when you release it it will toggle the relay again.

In the hardware.ino file find the 4CH board and change the line for your button as follows:

#define BUTTON1_MODE        BUTTON_SWITCH

Mind that the action it performs is "toggle", so it will simply change the state. If you change the state throw others means (web interface or MQTT, for instance) and you leave it ON, then pressing will turn it off and releasing will turn it on again.

Another option is a beta feature I just pushed into the dev branch which allows to map the button events to ON or OFF actions, not just TOGGLE. This means the behaviour of the buttons will be consistent no matter the state of the relay. You would then configure the button like this:

#define BUTTON1_PRESS          BUTTON_MODE_ON
#define BUTTON1_CLICK          BUTTON_MODE_OFF
#define BUTTON1_LNGCLICK       BUTTON_MODE_OFF
#define BUTTON1_LNGLNGCLICK    BUTTON_MODE_OFF

Meaning pressing the button will always turn the relay on, and releasing it (no matter how long after the pressing) will turn it off.

Remember than for this to work you'll need the latest dev branch (commit 66131bb). Will be released with 1.8.4 or 1.9.0, whatever comes first.

@xoseperez
Copy link
Owner Author

Original comment by damienyong (Bitbucket: damienyong, GitHub: damienyong):


Hello thank you very much for your help.
I changed the hardware.h to TOGGLE and now it works.

(but Platformium is a little strrange for a Arduino-IDE person )

@xoseperez
Copy link
Owner Author

Original comment by damienyong (Bitbucket: damienyong, GitHub: damienyong):


Another little thing, can you make the boot-mode of the switches to off ?
Every time I reboot the system, all relays go to "on" mode, but turn of a few secounds later.
This could be quite annoying.

Thank you :)

@xoseperez
Copy link
Owner Author

That's what the "Switch boot mode" option does in the general tab. Set it to "Always OFF" and done.

@xoseperez
Copy link
Owner Author

Release 1.9.0 adds support for ON/OFF actions.

@xoseperez
Copy link
Owner Author

Removing milestone: 1.8.4 (automated comment)

@xoseperez
Copy link
Owner Author

Original comment by J Hendricks (Bitbucket: joeyhza, GitHub: joeyhza):


Hi

To start - I just want to say thanks for all the work put in to this and making life easier for the IOT noobs like myself.

I'm hoping someone can shed some light on my issue regarding run of the mill flip/toggle switches. I have successfully flashed 4x Sonoff Dual switches and all are in line and operational with my HA system and Alexa.

Each switch is run in to the corresponding Button 0 / Button 1 on the header. The only problem i have is if i flip the wall switch to turn the light on or off,I have to flip it twice.

Am I missing something. Reading up on past issues it doesnt appear this is the norm.

I have flashed all 4 switches with the lastest version of the pre-built binary.

Switch sync mode is set to No Synchronisation
Pulse is disabled.

Any help appreciated - wife is giving me the 'look what you broke you idiot' look every time she has to flip a switch twice to turn it on or off. Me .... I don't mind so much :)

@xoseperez xoseperez added major 1.8.3 enhancement New feature or request labels Jan 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request major
Projects
None yet
Development

No branches or pull requests

1 participant