hi @kabongsteve
my sonoff is back online
so…I replaced the line of code you suggested, but when I send any cover command only the first time the relay is switched on and off, then the rolling shutter goes fully open or fully closed always
@B1G You said you replaced “the line of code”. I mentioned you had to do it twice, the second time at line 1761.
But, apart from that I’ve re-checked the code and I think i found a new place for change
Line 1704 is where the relay is normally turned off, so this one needs to bounce the relay as well.
Hopefully the following will work for you
Replace
power &= (POWER_MASK ^ (3 << (cover * 2)));
SetDevicePower(power);
with
byte device = 2 * cover;
if (cover_direction[cover] > 0)
device += 1;
power_t mask = (1 << device);
power |= mask;
SetDevicePower(power);
delay(100);
SetDevicePower(power);
Hi @alesaund,
You should be able to do the following to verify what is going on.
From the console on the sonoff do a
SwitchTopic Switch
This should cause the “pressing” of either switch to send a MQTT message INSTEAD of operating the Cover.
This will tell us whether you get a message for the press, the release or both, and that that will help to debug what is going on.
You could also add debug code around line 2404, where the switch code calls the ExecuteCommandCover to make sure that is what is causing the cover to move.
with the last update, when send cover 0 the relay goes on and off, then after the pulsetime, in my case 22, the relay goes on and off again and the position starts to decrement to 0, and after other 22 sec the relay goes on and remains on
@B1G So my question is how does the original switches work on the system. If they are momentary action, then I’d assume you press and it starts moving, and then automatically stops when finished.
If pressed a second time while moving then it stops, but perhaps the second press is NOT required when going to fully open, or fully closed.
If this is the case, then this would possibly explain the second press causing it to close again.
If this is the case you have a more complex scenario, where you only want the stopping press, when not going fully open or fully closed.
Have you turned on the Debug log level to see the output from the cover code?
You may need to add some debug code like the existing debug code below, at each point where the relay on/off is done to see which one is causing the always on at the end.
@kabongsteve since i have a second temporized relay connected after the sonoff (i know that i don’t need it now with the sonoff, but it was installed before and i want to leave it, in case the sonoff doesn’t work) and the original switch has two position up and down all momentary . I only need to press one time up or down and the cover starts to move, till it’s fully open or closed, so the first on and off. If i want to stop the cover before is fully open and closed i need to press again the same up or down, so the second on off for the sonoff, only in this case.
Now i’m not at home, for the next week i can’t do other tests.
Hi @kabongsteve !
I purchased 4CH Pro R2’s. I flashed them with Tasmota, and intend to flash your version asap as they will serve for covers. Do I understand correctly that there is basically no reason to choose the 4CH Pro (R2) over the regular 4CH, or Sonoff dual, because the on-board functions are useless, but it will still work?
TIA
Hi @B1G and all,
I have updated a new version to github.
This version supports a setoption23 to turn on/off momentary button mode.
This means it will toggle the relays as if a momentary switches at start and end of travel.
Except when closing or opening, then only the first toggle. hardcoded to 250ms, which should be enough.
This should work for all those who are using the sonoff to pretend to be the standard up/down switches of a cover.
Hi @BTC,
I believe the advantage of the Pro/R2 is that the relays are separated and can switch any voltage, wheras the 4CH is like the 2CH and others and they simply switch mains voltage on/off.
But yes, with the Tasmota or my firmware the additional hardware features of the Pro is somewhat unnecessary
Hi @kabongsteve,
It’s fantastic! Thanks for you work.
Now the cover moves as it should for my case, but …
I set pulsetime1 to 24 and pulsetime2 to 0, and for example cover 50 is more like 25-30% of the aperture and stops in a different position if it’s completely open or completely closed … should I better adjust pulsetime values?
I think I’m in a very particular condition because when the cover is completely open and I close it, it starts moving immediately and when it touch the ground it’s closed but not fully, vice versa when it’s completely closed and I open it, the cover starts moving immediately but for 2 seconds it does not rise from the floor.
I made a video to explain better
And if I send a cover command with the same value multiple times, the cover continues to move on the same direction instead of staying still
I’d say it was more like 3 seconds. So the issue you have is you need +3 seconds, when starting from closed, but +0 seconds when moving from any other position.
At line 1740, there is
int16_t extra = Settings.pulse_timer[cover + (devices_present / 2)];
between it and like 1766 remove all lines that + or - extra;
then add
if (position ==0) pulse_timer[cover] += extra;
Also around like 1743, you could do a check and if difference between cover_position and position < 2 (ie very small movement) then simply return from the function and do nothing.
then set your pulsetime1 to 20 and pulsetime2 to 3, or there abouts
and it’s working, but when closing from 100 to 50%, the cover is a little more opened than when I open it from 0 to 50. The closing speed is higher then the opening speed.
Looking at your log output, it seems the cover 65, doesn’t pule ON, only pulse Off (which will actually be a pulse on and thus move it all the way open
The code below will have to be changed
if (abs(cover_position[cover] - position) < 2) return;
ie when it doesn’t have to move, then we have to clear the pulse_timer;
Its going to be way too complex to deal with differing speeds. The system is really only guesstimating where the blind is, so accuracy doesn’t exist, just something to give some idea of the relative position.
If you really need it accurate, then you’ll have get the opening position timing right, then always fully close, then re-open to get it to the right spot.
it’s a great job!
really what needs sonoff for covers I have tested your vesrion and it’s fine.
I have programed switchmode1 2 and switchmode2 2 to keep old wall switch behavious only when I open or close until “ON” or “OFF” positions the sonoff comes back automaticly to the last position set, in the other hand all other positions are fine.
I think in my case should take out 10% extra time for close, because full open “ON” returns systematicly back to 90