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

SwitchMode question for toggling wall switches #1221

Closed
danielsoar opened this issue Nov 19, 2017 · 17 comments
Closed

SwitchMode question for toggling wall switches #1221

danielsoar opened this issue Nov 19, 2017 · 17 comments
Labels
stale Action - Issue left behind - Used by the BOT to call for attention

Comments

@danielsoar
Copy link

Hi Guys, Love Tasmota but have an issue.

I have played with switchmode and currently have it set to:

#define SWITCH_MODE FOLLOW

the doco in switchmode doco has not been updated to include pushbuttonhold/_INV but from reading in here I think that just includes a long press for second button input back to MQTT to perform a second action.

My issue is that I have physical toggle switches around the house connected to the sonoff boxes and the mqtt can toggle a state change on the relay from any state the physical switch was in, but to get the lights to turn on from the switch again once its changed state from software if the software does not match the switch state anymore I need to flick the switch twice to get it to 'catch up' again. Bad terminology I know but hopefully you get my point.

This is not helping the WAF (Wife acceptance factor) of my home automation system. Since the home automation system knows which state it is in, is it possible to turn a toggle switch into a pushbutton by monitoring the edge change high to low OR low to high and using that as a PB?

I really didn't want to change all the switches in the house to bell press if possible as I have custom slim wall plates that fit on architraves so I wanted to leave the switches as they were if possible for aesthetic reasons.

I was hoping that either this is already implemented and I have just missed how to achieve it?

If not implemented yet, perhaps it is not too complex to implement and it would help alot of people who want to use this for lighting allowing them to use their current hardware switches assigned to a GPIO as a pushbutton that does edge detection.

Really appreciate the help and sorry if this is a double up question.

@kenmcc
Copy link

kenmcc commented Nov 20, 2017

I think you and I are trying to do something very similar:

#1194

@arendst
Copy link
Owner

arendst commented Nov 21, 2017

How about switchmode 0 (Toggle).

@kenmcc
Copy link

kenmcc commented Nov 21, 2017

i think the issue with toggle is that his switches are non retractive, so you flip it up to turn on, flip it down to turn off, like a normal light switch. The buttons on the unit though are retractive, and they expect you to close the contact to turn on the relay, and again close the contact to turn off the relay.

So to turn off the relay, he has to firstly flip (back to off i guess) the switch to break the circuit, then flip it back on again at which point the contact is closed and the relay toggles again.

What he's looking for i think is to detect a state change of the switch, either from open to closed, or from closed to open

@arendst
Copy link
Owner

arendst commented Nov 21, 2017

How about switchmode 3 (Pushbutton)

@danielsoar
Copy link
Author

Yeah, pushbutton is looking for a momentary low to high signal to change the state of the relay, if i used that i would have to flick my switch twice to get a change. I am looking for a solution to flick the switch once for a state change (monitors and uses both low to high AND high to low as a pushbutton input)

arendst added a commit that referenced this issue Nov 22, 2017
5.9.1h
 * Patch library I2Cdevlib-Core for esp8266-core 2.4.0-rc2
 * Add
option PUSHBUTTON_TOGGLE (SwitchMode 7) to allow toggling on any switch
change (#1221)
 * Fix DHT sensor timeout recognition by distinguish
"signal already there" from "timeout" (#1233)
@arendst
Copy link
Owner

arendst commented Nov 22, 2017

Try the latest version 5.9.1h which provides switchmode 7. I think this is what you were looking for.

@danielsoar
Copy link
Author

So the concept is right but its still buggy.

The switch works and the software works but they dont work together.

If I use switchmode 7
switch off = relay on
switch on = relay off
software toggle on with switch on and the relay goes on.
BUT if i now turn the switch off nothing happens, I then need to toggle the switch again (turn it on) to get the relay to change state.

So the software works regardless of the switch state but the switch only works if the software left it in the correct follow state. I really just want the switch rising or falling edge to toggle the relay state.

@danielsoar
Copy link
Author

having slept on it overnight I am convinced that the intention of switch-mode 7 is described correctly in the change notes.

So either I don't have it turned on, or there is a small bug in the edge detection logic using that as a toggle.

Would it be helpful for anyone else to feature request that we could select the switch-mode from the web interface?

I have reflashed my sonoffs (basic, 4chan-pro, pow) with 5.9.1i and they kept their names and settings, although they show the updated firmware version in the information tab.

Is it possible that even though I selected mode 7 in the config, when I re-flashed they retained their old switchmode? I ask because they kept some of their other settings after the update (friendly name etc)

How is the best way to check what switch-mode they are currently in - and yes, can we (pretty please) get it to be changeable via the web interface perhaps under where we allocate the GPIO to a particular switch.

so ie: GPIO4 -select- Pushbutton 1
switchmode -select 7 PUSHBUTTON_TOGGLE

Maybe even for completism switch topic could be selectable after this? (or put it on the MQTT page)

At the very least, if there is some technical reason why selecting the mode on the fly is hard, could we have the currently selected switchmode (and topic) displayed on the information page of the web interface to make it easy to check/verify?

Really appreciate your time looking into this @arendst your firmware for these cheap switches is awesome!

-Dan

@davidelang
Copy link
Collaborator

davidelang commented Nov 27, 2017 via email

@danielsoar
Copy link
Author

That is helpful thankyou I will try holding the button down or sending a mqtt reset value tonight after work - do you know if there is any way to check what the current setting is running on the unit (for switchmode)
It was more a suspicion than a statement, but I am unsure how to check.

@arendst
Copy link
Owner

arendst commented Nov 27, 2017

Read the wiki and learn about commands used to configure your system without reflashing or changing almost nothing in user_config.h

Use the web console to enter commands.

Welcome in the 2017s...

If debounce is the problem try to move the switch code in sonoff.ino from 0.05 second to the 0.1 second area and try again.

arendst added a commit that referenced this issue Dec 1, 2017
5.10.0 20171201
 * Upgrade library ArduinoJson to 5.11.2
 * Upgrade
library IRRemoteEsp8266 to 2.2.1 + 2 commits but disabled some protocols
(code size reduction)
 * Upgrade library NeoPixelBus to 2.2.9
 * Upgrade
library OneWire to 2.3.3 + 6 commits and disabled CRC lookup-table
(#define ONEWIRE_CRC8_TABLE 0) (code size reduction)
 * Update library
PubSubClient to 2.6 + 9 commits and additional delay (#790)
 * Update
core_esp8266_wiring_digital.c to latest (staged) level
 * Patch library
I2Cdevlib-Core for esp8266-core 2.4.0-rc2 compatibility
 * Remove
command EnergyReset 1..3 now replaced by ENergyReset1 to EnergyReset3
 *
Remove spaces in JSON messages (code size reduction)
 * Renamed
xsns_05_ds18x20.ino to xsns_05_ds18x20_legacy.ino still using library
OneWire and providing dynamic sensor scan
 * Fix possible iram1_0_seg
compile error by shrinking ICACHE_RAM_ATTR code usage
 * Fix PWM
watchdog timeout if Dimmer is set to 100 or Color set to 0xFF (#1146)
 *
Fix Sonoff Bridge Learn Mode hang caused by unrecognised RF code
(#1181)
 * Fix blank console log window by using XML character encoding
(#1187)
 * Fix wrong response name for command HlwISet (#1214)
 * Fix
DHT type sensor timeout recognition by distinguish "signal already
there" from "timeout" (#1233)
 * Add fixed color options 1..12 to
command Color
 * Add + (plus) and - (minus) to commands Dimmer
(+10/-10), Speed and Scheme
 * Add + (plus) and - (minus) to command
Color to select 1 out of 12 preset colors
 * Add + (plus) and - (minus)
to command Ct to control ColdWarm led ColorTemperature (+34/-34)
 * Add
commands EnergyReset1 0..42500, EnergyReset2 0..42500 and EnergyReset3
0..42500000
 *  to (Re)set Energy Today, Yesterday or Total respectively
in Wh (#406, #685, #1202)
 * Add optional ADS1115 driver as alternative
for unsupported I2Cdevlib in esp8266-core 2.4.0-rc2
 * Add support for
INA219 Voltage and Current sensor to be enabled in user_config.h with
define USE_INA219
 * Add support for Arilux LC11 (Clearing RF home code
when selecting no Arilux module)
 * Add support for WS2812 RGBW
ledstrips to be enabled in user_config.h with define USE_WS2812_CTYPE
(#1156)
 * Add SettingsSaveAll routine to command SaveData to be used
before controlled power down (#1202)
 * Add option PUSHBUTTON_TOGGLE
(SwitchMode 7) to allow toggling on any switch change (#1221)
 * Add new
xdrv_05_ds18x20.ino free from library OneWire and add the following
features:
 *  Add support for DS1822
 *  Add forced setting of 12-bit
resolution for selected device types (#1222)
 *  Add read temperature
retry counter (#1215)
 *  Fix lost sensors by performing sensor probe at
restart only thereby removing dynamic sensor probe (#1215)
 *  Fix
sensor address sorting using ascending sort on sensor type followed by
sensor address
 *  Rewrite JSON resulting in shorter message allowing
more sensors in default firmware image:
 *
"DS18B20-1":{"Id":"00000483C23A","Temperature":19.5},"DS18B20-2":{"Id":"0000048EC44C","Temperature":19.6}

* Add additional define in user_config.h to select either single sensor
(defines disabled), new multi sensor (USE_DS18X20) or legacy multi
sensor (USE_DS18X20_LEGACY)
 * Add clock support for more different
pixel counts (#1226)
 * Add support for Sonoff Dual R2 (#1249)
 * Add
FriendlyName to web page tab and add program information to web page
footer (#1275)
@puppetmaster886
Copy link

puppetmaster886 commented Jan 27, 2018

I there any difference between switchmode 7 and switchmode 0?
Even the code looks the same to me...

      if (button != lastwallswitch[i]) {
.....
        switch (Settings.switchmode[i]) {
        case TOGGLE:
          switchflag = 2;                // Toggle
          break;
......
        case PUSHBUTTON_TOGGLE:
          if (button != lastwallswitch[i]) {
            switchflag = 2;              // Toggle with any pushbutton change
          }
          break;

@davidelang
Copy link
Collaborator

davidelang commented Jan 28, 2018 via email

@majherek
Copy link

majherek commented Feb 16, 2018

Hi,

IMHO PUSHBUTTON_TOGGLE doesn't work on my sonoff basic. A make modification like this: http://support.iteadstudio.com/support/discussions/topics/11000003087/page/last. And connect wall switch to additional connector (blue one).

When I set PUSHBUTTON_TOGGLE it keeps like SwitchMode = 0 -> it change state only whe the blacku push button in pushed. When I release it, the state dosn't change. Can anybody confirmed that PUSHBUTTON_TOGGLE is working correctly?

@DNA99
Copy link

DNA99 commented Feb 25, 2018

Is it possible to have the sonoff power an LED indicator light (when the lights are switched off) so that it will indicate the lights are switched off and also act as a night light to show where the switches are?

@stale
Copy link

stale bot commented Jun 6, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Action - Issue left behind - Used by the BOT to call for attention label Jun 6, 2018
@stale
Copy link

stale bot commented Jun 21, 2018

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem.

@stale stale bot closed this as completed Jun 21, 2018
curzon01 pushed a commit to curzon01/Tasmota that referenced this issue Sep 6, 2018
5.9.1h
 * Patch library I2Cdevlib-Core for esp8266-core 2.4.0-rc2
 * Add
option PUSHBUTTON_TOGGLE (SwitchMode 7) to allow toggling on any switch
change (arendst#1221)
 * Fix DHT sensor timeout recognition by distinguish
"signal already there" from "timeout" (arendst#1233)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Action - Issue left behind - Used by the BOT to call for attention
Projects
None yet
Development

No branches or pull requests

7 participants