lobocobra / sonoff-shutter

add to arendst sonoff project the capability to operate shutters
GNU General Public License v3.0
5 stars 2 forks source link

Shutter movement only while button pressed #3

Open HGBAXXTER opened 6 years ago

HGBAXXTER commented 6 years ago

Lobocobra, thanks a lot for your excellent mod of the tasmota firmware. It is exactly what I was looking for.

However, what I would like to have is that on button press, the shutters only move, while the buttons are held down. It somewhat works when pressed for a longer time. However, a single short press on the buttons always drives the shutter the full way.

I reduced the pulsetime to some small value, however, it always seems to be reset to a higher value (seems to be ShutterMaxDSec + 5). Is it possible maintain a custom pulsetime?

Thanks for your support.

PS: I am running the firmware on a 4CH Pro.

PPS: I just read through #1 and understand the logic behind it. However, I would still be interested whether there is a solution or work-around.

lobocobra commented 6 years ago

Hi @HGBAXXTER

I agree with you that the miss-use of the pulestime needs to be changed. I currently work on a more general usability of the mod, as I want also to be able to calculate how much water I use in the garden with this mod. In addition I plan to merge my POW mod for my heating into this new one. => As this will take a bit too long for your case, I will add a work-around for you, by adding a new command. So you can set your desired pulsetime as the base pulsetime.

I will call it ShutStdPulseTDsec. ==> each reset will be done to your Shutter_Pulse Std, which should fix your issue.

Btw, did you know that with the pro you can buy a cheap internechno switch YWT-8500 and connect your buttons to the 433mhz capability? ==> So you do not need to have the ugly device near the shutter but can hide it somewhere.

lobocobra commented 6 years ago

Done, please check if it works as expected. => Config is reset with this upgrade! Ensure you have saved your settings.

localhost61 commented 6 years ago

@lobocobra This is where I hide my dual R2, and a CH4 will fit too:

Sonoff in place

The only drawback is that I need a 6 wires cable between the wall switch and the sonoff (Live, Neutral, Earth, Up, Dn, Gnd) where I used to have 4 wires (Up, Dn, Neutral, Earth)

lobocobra commented 6 years ago

@localhost61
Looks like a clean solution.

HGBAXXTER commented 6 years ago

@lobocobra Thanks a lot for your effort and your latest commit. I tried it but I do not get it to work as expected.

After OTA update, I configured from scratch:

With these settings, I expected that when pressing button1 very shortly, the relay will only be switched for 0.1s. Only permanent button press will lead to permanent relay switching (until the maximum runtime of the shutter is reached). However, it only works once after setting pulsetime. When I press button1 a second time, the relay is switched permanently, until 100% position is reached.

Maybe, my configuration is wrong?

PS: There is no urgency for me on this topic.

HGBAXXTER commented 6 years ago

Sorry, I just noticed my mistake. I forgot to set ShutStdPulseTDsec1 1.

Apparently, also my problem seems to be a different one: The Switchmode options do not seem to work with the onboard buttons on the 4Ch Pro. Unlike the Sonoff Dual, it also does not offer other GPIO as headers.

lobocobra commented 6 years ago

ShutStdPulseTDsec1 1 means that the blind goes for 0.1 sec. => Is it that what you wanted? If you want it to run for 1 sec, you need to set it at 10.

But usually I would recommend to set it at 25% or something...

HGBAXXTER commented 6 years ago

It certainly solves my problem (ShutStdPulseTDsec1 1 was an example value, 0.1 sec of course is not useful). I wanted to avoid that just a short button press moves the motor the full range (due to kids in the household, etc.). So, a setting of the pulsetime to somewhat like 25% is a good solution.

However, my original plan was a little different and using pulsetime does not seem to do what I expected it to do. Holding down a button when a value for pulsetime is defined does not switch the relay for the duration of button press but for the duration of pulsetime.

lobocobra commented 6 years ago

How about if you set ShutStdPulseTDsec1 to 0... then Pulsetime is off. => If needed I can adapt the code, as I believe 0 is not allowed as an value. => Just let me know but probably you can do the changes on your own

strizl commented 6 years ago

@localhost61 Thanks for sharing your photo and showing your solution. Looks very professional!

Can I ask you some questions:

Thanks a lot for your help and also thanks to @lobocobra for the great shutter-solution!

lobocobra commented 6 years ago

@strizl master branch Please make sure you use the master branch, when you test it. Localhost61 confirmed that it works with a dual (see #1), if you encounter issues, I will of course adapt the code.

ONoffcounter branch This branch will in future merge my 3 projects into one:

strizl commented 6 years ago

Thank you very much, @lobocobra ! Great work! I will test and give feedback if I encounter problems.

In the other post (#1) you wrote: "If you use the dual at the end, I would recommend you then to disable the CH4 interlock mode. In the next version this is done with setoption81."

Thanks a lot!

lobocobra commented 6 years ago

Hi Strizl

In your case you should set following options:

When using a 2channel, setoption14 is already giving you all you need and setoption81 becomes obsolete, as it splits your channesl by 2.

strizl commented 6 years ago

Thanks so far for your reply!

localhost61 commented 6 years ago

@strizl

lobocobra commented 6 years ago

@localhost61 I assume that you did not check the code for a while....

It is ensured that the UP command reaches 0% and DOWN reaches 100%. I use the solution daily and my shutter allways reach the end positions, when I push the buttons.

For UP/DOWN pulsetime is not used by the mod, only for GOposition. It even enables you to set a standard PULSETIME, which prevents that by accitdental manual change of pulsetime it is set back to the right value. In your described case this would be either PULSETIME 0 or PULSETIME = duration of full run-time. Without this function, your shutter could stop somewhere in the middle if you sent once an MQTT pulsetime command and forgot to reset it. Any solution that does not control the SONOFF pulsetime, will sooner or later fail to reach the end position. => My solution prevents this

@strizl Please let me know if you have issues with the configuration.

lobocobra commented 6 years ago

Please read my text first before you answer. The code does exactly this. => But there is really no need you use my code!

So why do you take it so personal? I will remove your text as it is no added value to the solution itself.

strizl commented 6 years ago

Hi @lobocobra

I tested your sonoff-shutter-release on a 4CH Pro and DUAL R2 device and I'm quite happy with it. It works fine and you did great work - thank you! Also the percentage function is a nice thing ;-)

I have only one little trouble regarding Sonoff DUAL R2: When I press a hardware button of the 4CHPro (e.g. UP or DOWN of 1 shutter) for A LONGER TIME, it drives the motor as long as I press the button. When I press it shortly, the shutter closes or opens completely (0% or 100%). That's a very nice function and exactly the thing I wanted to have! ;-)

But on the DUAL R2 this function also works with the 1 hardware key (single short press --> shutter completely up, double short press --> shutter completely down, single long press --> motor drives up till button release, double long press --> motor drives down till button release). So the function itselfs works exactly the same way - great!

But on the DUAL R2 you have an header to connect external BUTTONS. I wanted to use them to attach a wall mounted double-pushbutton to drive the shutter also externally. But with these buttons the function doesn't work. They drive the motor only up or down as long as I press the button. I think because of the following reason: the internal hardware button is attached to GPIO10, the header for external buttons is attached to GPIO0 and GPIO09. I think the function is only implemented for the internal hardware button, not for the header. In Tasmota I set GPIO0 to "09 Switch 1" and GPIO9 to "10 Switch2".

Is there a way to adapt these in the code or do I maybe have to set special or other settings in Tasmota?

Would be great to get some help. Thank you very much for your efforts! Kind regards, strizl

lobocobra commented 6 years ago

@strizl I have currently no DUAL R2 (but will probably order some), to test it my own, but there must be an easy solution. As the mod is not touching at all this function, it should be an issue on the Firmware to be fixed.

To understand your issue in detail.... The problem is, that the external buttons do not go fully UP/DOWN if you press once, but they function as expected if you press continously. Basically you want be able to move the shutter by long press or have it fully up/down when pressed once (or twice). All is ok as long it is the same everywhere... => right?

Could you try this

The solution is then either to search for a fix in the basic firmware, which might be usefull for all or to use the new script function within SONOFF, or that I add a hack. => What I probably could do easily is to programm a double push

So let's see what is the outcome of your test and then progress.

strizl commented 6 years ago

Hi @lobocobra

Sorry for my late reply. Thank you very much for your help and details so far!

I will investigate, do the recommended checks and come back to you. Unfortunately, I'm very busy at the moment, but hopefully I have a free time slot the upcoming weeks.

Kind regards, strizl