Page 1 of 1

sonoff manual control

Posted: Thursday 20 April 2017 19:02
by jackwan1
I created a virtual switch in domoticz for my sonoff(basic) device flashed with espeasy R147

I do not have problem to control the switch via domoticz or apple app Pilot

However, I just realize that manual control switch (GPIO0) is not working properly

I did put in the following standard rules in espeasy
on lightswitch#Switch do
if [status#Switch]=0
gpio,12,1
else
gpio,12,0
endif
endon

I have the following problems

1. If the sonoff is turned on by software, I can press the gpio0 button to turn it off, but cannot turn it on.
2. If the sonoff is turned off by software, I cannot press the button to turn it on
3. If I manually turn off the sonoff, domoticz does not report its been turned off

I am using http to control the switch in domoticz

Please help

Re: sonoff manual control

Posted: Thursday 20 April 2017 21:23
by sincze
Check my post here for a working solution for your rules.

https://www.domoticz.com/forum/viewtopi ... 20#p121751

Re: sonoff manual control

Posted: Friday 21 April 2017 1:59
by jackwan1
Thank you @sincze
I followed your instructions, everything is working. the only thing is that the Domoticz is not updated when I operate manually.
So when you manually operate the switch to turn it on, Domoticz status is still off.

I guess it is only one way street in http command. I guess I have to try Domoticz in mqtt mode and I do have an mqtt server running.

Re: sonoff manual control

Posted: Friday 21 April 2017 13:23
by sincze
jackwan1 wrote:Thank you @sincze
I followed your instructions, everything is working. the only thing is that the Domoticz is not updated when I operate manually.
So when you manually operate the switch to turn it on, Domoticz status is still off.

I guess it is only one way street in http command. I guess I have to try Domoticz in mqtt mode and I do have an mqtt server running.
MMM
I just tried the following.
Light is OFF.
Press the small black button.. the light goes on.. the domoticz icon lights up.
Press the small black button again.. the light goes off .. the the domoticz icon switches off.

Light is OFF.
Press the small black button.. the light goes on.. the domoticz icon lights up.
Press the domoticz light icon.. the light goes out.

Light is OFF.
Press Domoticz light button... light goes on.
Press the black button. light goes out and domoticz icon light goes out as well.

This is working according the specification I would say. Domoticz and physical light are in sync.

Re: sonoff manual control

Posted: Friday 21 April 2017 20:45
by jackwan1
Maybe I did some thing wrong. The thing I am always wondering is that in the Hardware entry(Dummy), should I create One Sonoff per HW entry or can I have many switches per HW entry? I put 3 Sonoffs under one HW entry and the idx I used are the same in Espeasy.

Re: sonoff manual control

Posted: Friday 21 April 2017 21:42
by jackwan1
Here is my setup

I have since added separate HW definitions but still did not work
Rules

on lamp_on do
gpio,12,1
gpio,13,0
endon

on lamp_off do
gpio,12,0
gpio,13,1
endon

on SW_1#Switch do
if [SW_1#Switch]=1
gpio,12,1
gpio,13,0
else
gpio,12,0
gpio,13,1
endif
endon

Re: sonoff manual control

Posted: Friday 21 April 2017 22:04
by Westcott
Hi Jackwan1,

What you seem to have done is created 4 hardware nodes in Domoticz and used their idxes.
What I think you need to do is have just one hardware node 'Sonoff' and create 4 dummy switches in it - Sonoff1-4.
Then use the idxes of these dummy switches in the ESPeasy devices.

Re: sonoff manual control

Posted: Friday 21 April 2017 23:29
by jackwan1
Thanks
But I did exactly as you described before. I created one Dummy Switch and put all virtual sensors (sonoff switches) under that HW switch.
It did not report the correct status of the switch as I described before. The virtual Idx under "device"was entered and did not work

Re: sonoff manual control

Posted: Friday 21 April 2017 23:40
by jackwan1
ok, now I deleted all the settings and start from scratch. The confusion is the Dummy HW idx and the Virtual Switch idx on the device list. Which one I should use in the espeasy? And if they are identical would that cause problems? Like right now the Dummy HW idx is 2 and one of the virtual switch also has idx 2.

Re: sonoff manual control

Posted: Saturday 22 April 2017 0:00
by jackwan1
Ok, its all good. By trial and error, I now know that the idx in "Device" list is going to be used not the idx in the"Hardware" list should be used. The status sync is all good.

Re: sonoff manual control

Posted: Saturday 22 April 2017 10:18
by tontze
HI !

Im really new with ESPEasy and stuff, but i would like to find cheap wall switch that can be controlled via domoticz and its status be updated in domoticz if operated directly. I found this :

https://www.itead.cc/sonoff-touch.html

And :

https://github.com/arendst/Sonoff-MQTT-OTA-Arduino
https://github.com/arendst/Sonoff-Tasmota

Would above thread work with this too ?

Thanks ! -T

Re: sonoff manual control

Posted: Monday 24 April 2017 1:06
by jackwan1
Sonoff Touch is using a different chip esp8265 not esp8266 as all the others.
You need to find the right espeasy version (I believe R148) to flash it and it is difficult to ground the gpio0 when flashing.

https://github.com/davidmpye/Sonoff-Tou ... w-to-flash

Once it is flashed, you should be able to use in Domoticz

I have two, but I am too lazy to pull it from the wall to try

Re: sonoff manual control

Posted: Monday 24 April 2017 19:16
by tontze
ok cool, i ordered one and lets see when it arrives :)

Re: sonoff manual control

Posted: Thursday 27 April 2017 0:47
by jackwan1
Thanks to @sinze who spent the time to set up sonoff switch in Domoticz using the procedures in the following thread:

https://www.domoticz.com/forum/viewtopi ... 20#p121751

It worked fine, but strangely, I receive two prowl notifications each time I turn on and off using Domoticz
Further investigation found that in the Domoticz switch log there were two entries each for on and off
Trial and error found that there is nothing wrong with his Domoticz setup but the Espeasy setting needs to be modified as follows:

1. In ESPeasy devices there should be only ONE switch device entry:
The double entries in Domoticz log is caused by TWO switch Espeasy device entries as defined by @Sincz.
sonoffa.jpg
sonoffa.jpg (233.77 KiB) Viewed 14681 times
2. There is a slight change in the Switch setting:
Please note that Idx in the switch setting is significant, mine is 1, yours could be some thing else. That idx should correspond with your switch(device) setting in the Domoticz
sonoffb.jpg
sonoffb.jpg (251.49 KiB) Viewed 14681 times
There is no change in Espeasy rules as @sinze posted.

Its all good from there

Re: sonoff manual control

Posted: Sunday 23 July 2017 12:52
by corederoma82
Hi guys,
I have a sonoff switch that I have uodated with EaspEasy firmware.
It seems work because when I push the sonoff button, in software the status became 1 and if I re-push the button the status became 0.
I have problem when I connect the Sonoff Switch at my boiler; the voltage is ok, the Sonoff is on and work but when I press the switch button the led boiler is always swtich off.

Thanks

Re: sonoff manual control

Posted: Wednesday 26 July 2017 8:40
by tontze
corederoma82 wrote:Hi guys,
I have a sonoff switch that I have uodated with EaspEasy firmware.
It seems work because when I push the sonoff button, in software the status became 1 and if I re-push the button the status became 0.
I have problem when I connect the Sonoff Switch at my boiler; the voltage is ok, the Sonoff is on and work but when I press the switch button the led boiler is always swtich off.

Thanks
i think you need also switch state of the switch, not only status ? Status is for telling other devices whats is its state ?