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

Feature Proposal: Detect short interruption of mains #25

Open
rnauber opened this issue Apr 29, 2021 · 6 comments
Open

Feature Proposal: Detect short interruption of mains #25

rnauber opened this issue Apr 29, 2021 · 6 comments

Comments

@rnauber
Copy link

rnauber commented Apr 29, 2021

Hi @jamesturton,

I like to retrofit some mechanical switches to become "smart" with the Shelly Dimmer 2. However, as I cannot fit them inside the switch box, I came up with this idea:

Screenshot from 2021-04-29 23-49-23

The retrofit adds the Shelly to the lamp (where there is ample space in the lampshade). In the switch box, a simple wire bridge is added. This means, that the Shelly is powered all the time, except for a brief period during switching.

I like to ask, if you could add a mechanism for detecting these brief interruptions to the firmware? I have not investigated their precise length, but they seem quite short, as they do not reset Shelly's ESP.
Detecting the interruptions would allow to infer the state of the mechanical switch and use it for controlling the light.

What do you think?

Best,
Richard

@rbswift
Copy link

rbswift commented Apr 29, 2021

I do something similar but have replaced the rocker switches with momentary, normally closed switches. PowerOnState 2 is probably what you are looking for. It's a core Tasmota feature, not specific to the dimmer firmware. You'll need to be sure power is removed for long enough for the device to power down of course. Booting is quite fast so that's good. Also look out for SetOption36 and SetOption65.

@rnauber
Copy link
Author

rnauber commented Apr 30, 2021

I do something similar but have replaced the rocker switches with momentary, normally closed switches. PowerOnState 2 is probably what you are looking for. It's a core Tasmota feature, not specific to the dimmer firmware. You'll need to be sure power is removed for long enough for the device to power down of course.

And that is exactly the problem, as I want to use the very brief interruption that occurs when switching a toggle switch. As I wrote earlier, it does not reset/reboot the ESP.

@jamesturton
Copy link
Owner

This is an interesting proposal and I can see the benefit it would have to your setup.
If this was implemented I wonder about the reliability of the detection. I think some good first steps would be:

  • Determine exactly how long it takes for the ESP to restart after being disconnected.
  • Determine how long of a 'pulse' is generated from a switch in this configuration (test multiple brands of switch to see if it is consistent)
  • See if the pulse of this length is detectable by the STM

@Jason2866
Copy link
Contributor

If the ESP reboots it will take a few seconds until it is online again.
Perfect would be if the interrupt is very short so that the ESP does not reboot.
Needs testing...
If this is the case STM should detect (if possible) and do the magic.
Intersting in real world will be if and how many ghost switching will happen

@rbswift
Copy link

rbswift commented May 2, 2021

The delay to get online typically doesn’t matter much. Toggling the light on/off is sub-second fast.

A problem with a very short interruption is that it could easily be falsely triggered by switching in the supply network.

If you can replace your switch with a momentary push button, normally closed switch mechanism then poweronstate toggle works brilliantly and also has the advantage that the switch doesn’t sometimes appear to be ‘on’ when the light is actually switched off due to automation/ remote control. Did you try this or is it not possible to replace your switch?

@rnauber
Copy link
Author

rnauber commented May 2, 2021

The delay to get online typically doesn’t matter much. Toggling the light on/off is sub-second fast.

A problem with a very short interruption is that it could easily be falsely triggered by switching in the supply network.

Yes, but I hope that is rare enough to be tolerated.

If you can replace your switch with a momentary push button, normally closed switch mechanism then poweronstate toggle works brilliantly and also has the advantage that the switch doesn’t sometimes appear to be ‘on’ when the light is actually switched off due to automation/ remote control. Did you try this or is it not possible to replace your switch?

My particular switches can not be modified that easy.
But in general, if you can have an normally closed momentary switch that would be the best option.

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

No branches or pull requests

4 participants