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

TglChanOnTgl not reliable on device with AC Frequency Detection (like Moes MS-104B) - change state without input #1142

Open
paede81 opened this issue Mar 25, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@paede81
Copy link

paede81 commented Mar 25, 2024

Describe the bug
If you use a device with AC Frequency Detection (like Moes MS-104B) then TglChanOnTgl is not reliable. It switches the device multiple time a day with toggle the input

Please add something similar then SwitchDebounce 69 to the application (as available in Tasmota)

I believe bug is related to: #753

Firmware:

  • Version: 1.17.496
  • Device: Moes MS-104B
  • Chip/model: BK7231N
  • Device config:
  "pins": {
    "6": "Rel;2",
    "8": "Rel;1",
    "24": "TglChanOnTgl;2",
    "26": "TglChanOnTgl;1"

To Reproduce
Steps to reproduce the behavior:

  1. Set input to TglChanOnTgl
  2. Wait...
  3. Device will change input state with toggling any switch which which is connected

Additional context
Tasmota identified the issue and created a workaround:

AC Frequency Detection Switch~

Some devices, such as BlitzWolf BW-SS5 or Moes MS-104B, use mains frequency detection on their switch inputs. Whenever the connected switch or button is pressed there are 50/60 Hz pulses on the switch input. Inside the switch there's a frequency detection circuit which is connected to a GPIO of the ESP8266 chip which counts those pulses. Prior to Tasmota 8.4 this kind of switching was handled using Counter sensors and scripting which is now simplified.

You can imagine this algorithm as a leaking bucket. Every pulse adds water to the bucket (little more than leaking out in a cycle), but the water is dripping countinously. If the bucket is full, we will treat the switch on. If there's no pulses, the bucket will be empty, and the we will turn off the switch. The size of the bucket is the debouncing time which controls the sensitivity of the algorithm. If the mains frequency is 50 Hz, a whole AC wave is 20 msec long (for 60 Hz it's about 17 msec; 1000 / frequency if we want the result in milliseconds). The exact frequency is not really important, because we add more water for every pulse.

After you have assigned a Switch to the GPIO connected to the AC frequency detection circuit use the 'SwitchDebounce' command to set the number of pulses required for the switch to be recognized as on or off. For example: SwitchDebounce 69 will turn the switch on after three pulses and turn it off after three missing ones (3 * 20 msec is 60 and the last digit must be 9 to activate the AC detection). You will probably have to experiment with the values depending on your AC frequency and the devices frequency detection implementation.

Once the feature is enabled you can use this switch as any regular switch!

Code snipped here:
arendst/Tasmota@7e8c136

@openshwprojects openshwprojects added the enhancement New feature or request label Mar 25, 2024
@openshwprojects
Copy link
Owner

I haven't seen such device yet. I may need to buy one with donation funds if they are sufficient, or is there anyone with such device willing to help with testing?

@paede81
Copy link
Author

paede81 commented Apr 14, 2024

Sorry for the late response
I'm happy to help with testing. I have different device in use with AC Frequency Detection
Currently I'm using this device: https://www.aliexpress.com/item/1005003425831720.html
and this: https://www.aliexpress.com/item/1005006339647483.html

@paede81
Copy link
Author

paede81 commented May 5, 2024

@openshwprojects : can you please flag this issues as a bug as this makes device with ac detection unusable

@rt400
Copy link

rt400 commented Aug 18, 2024

Hi. The problem still here with the latest firmware...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants