arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
21.98k stars 4.77k forks source link

How to change the ON/OFF status only once per pulse? #4238

Closed RafVerzet closed 5 years ago

RafVerzet commented 5 years ago

IMPORTANT NOTICE If you do not complete the template below it is likely that your issue will not be addressed. When providing information about your issue please be as extensive as possible so that it can be solved by as little as possible responses.

Make sure these boxes are checked [x] before submitting your issue - Thank you!

(Please, remember to close the issue when the problem has been addressed)

Jason2866 commented 5 years ago

See wiki https://github.com/arendst/Sonoff-Tasmota/wiki/PowerOnState-Configuration https://github.com/arendst/Sonoff-Tasmota/wiki/Button-usage https://github.com/arendst/Sonoff-Tasmota/wiki/Understanding-SwitchMode-and-SwitchTopic

RafVerzet commented 5 years ago

Hello Jason, I have already reviewed these yesterday but I'm getting confused and I don't really understand how I should configure my Sonoff to get it work the way I want.

ascillato commented 5 years ago

Please, share your status 0 output

RafVerzet commented 5 years ago

I'm sorry but I'm not sure what you mean by that... Is it the following you're asking for?

11:31:30 RSL: stat/sonoff4chpro/RESULT = {"POWER1":"ON"} 11:31:30 RSL: stat/sonoff4chpro/POWER1 = ON 11:31:31 RSL: stat/sonoff4chpro/RESULT = {"POWER1":"OFF"} 11:31:31 RSL: stat/sonoff4chpro/POWER1 = OFF

ascillato commented 5 years ago

In the console type

Status 0

And press enter

RafVerzet commented 5 years ago

Ah ok :-)

11:40:40 CMD: status 0 11:40:40 RSL: stat/sonoff4chpro/STATUS = {"Status":{"Module":23,"FriendlyName":["Sonoff","Sonoff2","Sonoff3","Sonoff4"],"Topic":"sonoff4chpro","ButtonTopic":"","Power":0,"PowerOnState":3,"LedState":1,"SaveData":1,"SaveState":1,"ButtonRetain":1,"PowerRetain":0}} 11:40:40 RSL: stat/sonoff4chpro/STATUS1 = {"StatusPRM":{"Baudrate":115200,"GroupTopic":"sonoffs","OtaUrl":"http://sonoff.maddox.co.uk/tasmota/sonoff.bin","RestartReason":"Software/System restart","Uptime":"0T01:17:57","StartupUTC":"2018-11-01T09:22:43","Sleep":0,"BootCount":2,"SaveCount":59,"SaveAddress":"F9000"}} 11:40:40 RSL: stat/sonoff4chpro/STATUS2 = {"StatusFWR":{"Version":"6.2.1","BuildDateTime":"2018-10-30T15:58:50","Boot":6,"Core":"2_30","SDK":"1.5.3(aec24ac9)"}} 11:40:40 RSL: stat/sonoff4chpro/STATUS3 = {"StatusLOG":{"SerialLog":2,"WebLog":2,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["Verzetti",""],"TelePeriod":300,"SetOption":["00008049","55C18000","00000000"]}} 11:40:40 RSL: stat/sonoff4chpro/STATUS4 = {"StatusMEM":{"ProgramSize":472,"Free":528,"Heap":18,"ProgramFlashSize":1024,"FlashSize":1024,"FlashMode":3,"Features":["00000809","0FDAE794","24000000","23B617CE","00000000"]}} 11:40:40 RSL: stat/sonoff4chpro/STATUS5 = {"StatusNET":{"Hostname":"sonoff4chpro-2393","IPAddress":"192.168.8.136","Gateway":"192.168.8.1","Subnetmask":"255.255.255.0","DNSServer":"192.168.8.1","Mac":"60:01:94:A3:69:59","Webserver":2,"WifiConfig":3}} 11:40:40 RSL: stat/sonoff4chpro/STATUS6 = {"StatusMQT":{"MqttHost":"","MqttPort":1883,"MqttClientMask":"DVES%06X","MqttClient":"DVES_A36959","MqttUser":"DVES_USER","MqttType":1,"MAX_PACKET_SIZE":1000,"KEEPALIVE":15}} 11:40:40 RSL: stat/sonoff4chpro/STATUS7 = {"StatusTIM":{"UTC":"Thu Nov 01 10:40:40 2018","Local":"Thu Nov 01 11:40:40 2018","StartDST":"Sun Mar 25 02:00:00 2018","EndDST":"Sun Oct 28 03:00:00 2018","Timezone":1,"Sunrise":"07:37","Sunset":"17:30"}} 11:40:40 RSL: stat/sonoff4chpro/STATUS10 = {"StatusSNS":{"Time":"2018-11-01T11:40:40"}} 11:40:40 RSL: stat/sonoff4chpro/STATUS11 = {"StatusSTS":{"Time":"2018-11-01T11:40:40","Uptime":"0T01:17:57","Vcc":3.222,"POWER1":"OFF","POWER2":"OFF","POWER3":"OFF","POWER4":"OFF","Wifi":{"AP":1,"SSId":"Verzetti","RSSI":100,"APMac":"54:B8:0A:0B:C9:F8"}}} 11:40:40 MQT: Attempting connection...

ascillato commented 5 years ago

Also, please, type

Weblog 4

In order to have more debug messages and also paste the output in the console of the power on and off tha you see

RafVerzet commented 5 years ago

Here is what I get when I type Weblog4

11:42:56 CMD: Weblog4 11:42:56 SRC: WebConsole from 192.168.8.122 11:42:56 RSL: Received Topic /Weblog4, Data Size 0, Data 11:42:56 RSL: Group 0, Index 4, Command WEBLOG, Data 11:42:56 RSL: stat/sonoff4chpro/RESULT = {"WebLog":4} 11:43:01 UPP: Multicast disabled 11:43:01 MQT: Attempting connection...

ascillato commented 5 years ago

The command is Weblog 4

With a space.

That enable more debug information.

After the command try to power on the device and you can see in the console where is the power off coming from

RafVerzet commented 5 years ago

Ah ok: 11:49:47 CMD: weblog 4 11:49:47 SRC: WebConsole from 192.168.8.122 11:49:47 RSL: Received Topic /weblog, Data Size 1, Data 4 11:49:47 RSL: Group 0, Index 1, Command WEBLOG, Data 4 11:49:47 RSL: stat/sonoff4chpro/RESULT = {"WebLog":4} 11:49:49 HTP: Main Menu 11:49:50 SRC: WebGui from 192.168.8.122 11:49:50 RSL: stat/sonoff4chpro/RESULT = {"POWER1":"ON"} 11:49:50 RSL: stat/sonoff4chpro/POWER1 = ON 11:49:50 SRC: PulseTimer 11:49:50 RSL: stat/sonoff4chpro/RESULT = {"POWER1":"OFF"} 11:49:50 RSL: stat/sonoff4chpro/POWER1 = OFF

So as you can see after powering ON the device it goes back to OFF. I want to have this pulse function but not the 2nd status change

ascillato commented 5 years ago

Please, type in the console

Pulsetimer 0

That is why your relay is turning off. You have defined a pulsetimer.

El jue., 1 de nov. de 2018 07:52, RafVerzet notifications@github.com escribió:

Ah ok: 11:49:47 CMD: weblog 4 11:49:47 SRC: WebConsole from 192.168.8.122 11:49:47 RSL: Received Topic /weblog, Data Size 1, Data 4 11:49:47 RSL: Group 0, Index 1, Command WEBLOG, Data 4 11:49:47 RSL: stat/sonoff4chpro/RESULT = {"WebLog":4} 11:49:49 HTP: Main Menu 11:49:50 SRC: WebGui from 192.168.8.122 11:49:50 RSL: stat/sonoff4chpro/RESULT = {"POWER1":"ON"} 11:49:50 RSL: stat/sonoff4chpro/POWER1 = ON 11:49:50 SRC: PulseTimer 11:49:50 RSL: stat/sonoff4chpro/RESULT = {"POWER1":"OFF"} 11:49:50 RSL: stat/sonoff4chpro/POWER1 = OFF

So as you can see after powering ON the device it goes back to OFF. I want to have this pulse function but not the 2nd status change

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/arendst/Sonoff-Tasmota/issues/4238#issuecomment-435004353, or mute the thread https://github.com/notifications/unsubscribe-auth/Ahw-h593GlQM1H0-vwRR6qHYh9OLDm_tks5uqtJigaJpZM4YF7D1 .

RafVerzet commented 5 years ago

No sorry you miss understood what I want to achieve. I do want to use the pulse function so that the relais works as dry contact. What I do not want is to have the status changed back to what it was before I press the button. Example of what I want:

Then

Does it make sense?

ascillato commented 5 years ago

Sorry that is not supported. Tasmota needs to know all the time the real status of the relay.

RafVerzet commented 5 years ago

ah damn... Is there a workaround that you might think of?

ascillato commented 5 years ago

Use a home automation software, and do your custom rules there. Home Assistant for examples supports all that.

RafVerzet commented 5 years ago

I'll take a look at it. Thanks!

ascillato commented 5 years ago

I have another idea.

Update to last Tasmota version.

Leave pulsetimer configuration as you had before. Pulsetimer 10 I think

Define any free gpio in module config as relay5. Define the friendly name that you want to use with Alexa to that relay 5 (we will use that virtual relay as memory).

Then go to the console for setting Tasmota rules.

Rule1 1 Rule1 on Power5#state do power1 1 endon

RafVerzet commented 5 years ago

Ok I’ll update to the version 6.3.0 and re set the PulseTimer to 1 but then you lost me :-)

Le 1 nov. 2018 à 12:59, Adrian Scillato notifications@github.com a écrit :

I have another idea.

Update to last Tasmota version.

Leave pulsetimer configuration as you had before. Pulsetimer 1 I think

Define any free gpio in module config as relay5. Define the friendly name that you want to use with Alexa to that relay 5 (we will use that virtual relay as memory).

Then go to the console for setting Tasmota rules.

Rule1 1 Rule1 on Power5#state do power1 1 endon

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/arendst/Sonoff-Tasmota/issues/4238#issuecomment-435019038, or mute the thread https://github.com/notifications/unsubscribe-auth/AmVNumUTUrRGGQt9xCVzmQ-fr3SYZFlIks5uquIHgaJpZM4YF7D1.

RafVerzet commented 5 years ago

So here is where I am now. I flashed the sonoff 4ch with the last tasmota firmware version Set the relay 1 back to pulsetime1 1 then checked the GPIO and here is what I get:

14:21:15 CMD: gpios 14:21:15 RSL: stat/sonoff4chpro/RESULT = {"GPIOs1":["0 (None)","1 (DHT11)","2 (AM2301)","3 (SI7021)","4 (DS18x20)","5 (I2C SCL)","6 (I2C SDA)","7 (WS2812)","8 (IRsend)","9 (Switch1)","10 (Switch2)","11 (Switch3)","12 (Switch4)","13 (Switch5)","14 (Switch6)","15 (Switch7)","16 (Switch8)","25 (Relay5)","26 (Relay6)","27 (Relay7)","28 (Relay8)","33 (Relay5i)","34 (Relay6i)","35 (Relay7i)","36 (Relay8i)","37 (PWM1)","38 (PWM2)","39 (PWM3)","40 (PWM4)","41 (PWM5)"]} 14:21:15 RSL: stat/sonoff4chpro/RESULT = {"GPIOs2":["42 (Counter1)","43 (Counter2)","44 (Counter3)","45 (Counter4)","46 (PWM1i)","47 (PWM2i)","48 (PWM3i)","49 (PWM4i)","50 (PWM5i)","51 (IRrecv)","53 (Led2)","54 (Led3)","55 (Led4)","57 (Led2i)","58 (Led3i)","59 (Led4i)","60 (MHZ Tx)","61 (MHZ Rx)","62 (PZEM0XX Tx)","63 (PZEM004 Rx)","64 (SAir Tx)","65 (SAir Rx)","69 (PMS5003)","70 (SDS0X1 Rx)","71 (SerBr Tx)","72 (SerBr Rx)","73 (SR04 Tri)","74 (SR04 Ech)"]} 14:21:15 RSL: stat/sonoff4chpro/RESULT = {"GPIOs3":["82 (Switch1n)","83 (Switch2n)","84 (Switch3n)","85 (Switch4n)","86 (Switch5n)","87 (Switch6n)","88 (Switch7n)","89 (Switch8n)","90 (Button1n)","91 (Button2n)","92 (Button3n)","93 (Button4n)","94 (Counter1n)","95 (Counter2n)","96 (Counter3n)","97 (Counter4n)","98 (PZEM016 Rx)","99 (PZEM017 Rx)","100 (MP3 Player)","101 (SDS0X1 Tx)","102 (HX711 SCK)","103 (HX711 DAT)","104 (TX20)","105 (RFSend)","106 (RFrecv)"]} 14:21:15 RSL: stat/sonoff4chpro/RESULT = {"GPIOs4":["107 (Tuya Tx)","108 (Tuya Rx)"]} 14:21:21 MQT: Attempting connection... 14:21:22 DNS: Query done. MQTT services found 0 14:21:23 UPP: Multicast (re)joined 14:21:23 CMD: gpio 14:21:23 RSL: stat/sonoff4chpro/RESULT = {"GPIO1":"0 (None)","GPIO2":"0 (None)","GPIO3":"0 (None)"}

ascillato commented 5 years ago

are you using all the relays in your sonoff 4ch pro?

ascillato commented 5 years ago

Ok, I will asume you are not using the relay 4, so we will use the relay 4 as memory for knowing the state of the device you are controlling.

Now, Click in configuration click in Extra configuration write in friendly name 4 the name you want to say to alexa to control your device.

Then go to the console and type:

Rule1 1
Rule1 on Power4#state do power1 1 endon
RafVerzet commented 5 years ago

I can live with 3 relais but I need the 3 relais working the same way with the pulse time. I did what you said earlier and I ended up with a 5th virtual relay that works as I want but doesn't show up in Alexa

RafVerzet commented 5 years ago

So basically I did the

rule1 1 Rule1 on Power5#state do power1 1 endon

ascillato commented 5 years ago

Tasmota by default, only supports 4 friendly names for Alexa. Sorry.

In your case, you will need 7 names. For achieving that, you need to modify the code and compile by yourself.

There is an old issue where that was asked and Theo has explained how to do that.

ascillato commented 5 years ago

What device are you controlling that needs that inching behaviour?

ascillato commented 5 years ago

What happens if you leave your relay on?

RafVerzet commented 5 years ago

I don't think I will be able to do that, modifying the code. Do you by change know how I can read about this old issue? The purpose for me is to use the sonoff as dry contact to pilot my home domotica system. The system has 16 inputs which work as NO contacts. The sonoff will pilot the contact. the system needs pulse to recognise an action on the input that why I need this.

RafVerzet commented 5 years ago

anyhow, thank you very much for your time! I really appreciated your help

ascillato commented 5 years ago

ok.

In your case, with Tasmota as it is, you will be able to control 2 outputs (relay 1 and relay 2) and the other 2 relays (relay 3 and relay 4) could be used as memory of the other relays.

This workaround is because the use you want to do to your sonoff ch4 pro is not standard. Those devices + Tasmota is meant to direct control devices.

benzino77 commented 5 years ago

By pressing button you meant physical button or the button in the webgui? If you are talking about physical button then try this: set blinktime 2, blinkcount 1 then write the rule:

on button1#state=2 do 
backlog power1 3; delay 5;power1 2 
endon

Every time you push the button it will do a blink/pulse, and after that change the state of the relay to the opposite value: if it was ON it will be OFF after blinking/pulsing, and if it was OFF it will be ON after blinking/pulsing.

RafVerzet commented 5 years ago

Hello Benzino77, thank you for your reply. Actually I ment the button in the webgui or via voice control with Alexa. I want to try your code but it seems that I'm not doing the right thing. Here is what I get:

18:35:03 CMD: on button1#state=2 do backlog power1 3; delay 5;power1 2 endon 18:35:03 RSL: stat/sonoff4chpro/RESULT = {"Command":"Unknown"}

benzino77 commented 5 years ago

You have to use a rule command. All commands you have to do:

blinktime 2
blinkcount 1
rule1 on button1#state=2 do backlog power1 3; delay 5;power1 2 endon
rule1 1

But it will only work with physical button. To make it work via webgui/alexa @ascillato solution with storing relay state with unused/virtual relays will do the trick for you.

RafVerzet commented 5 years ago

Hi Benzino77, sorry for my late reply I haven't been home for the past few days. Thank you for your inputs, I'll give it a try this weekend!