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
22.06k stars 4.78k forks source link

Command to disable relay but still sends MQTT messages #3840

Closed Kiritzai closed 6 years ago

Kiritzai commented 6 years ago

Hi!

First off I want to thank you ( Theo Arends ) for this wonderful software you've been providing us. This is a feature request so lets get down to my story.

I've got an doorbell that is connected with 2 wires to my Sonoff Basic ( GPIO14 and GND ), GPIO14 module is configured as: 12 switch4 and it's working perfectly and to top it off, if the doorbell rings I get an telegram message with a snapshot of the person at the door, pretty handy!

Now occasionally my doorbell will ring late in the evening or very early in the morning. It's pretty loud and my cats will get scared when the doorbell rings, so what I thought is to disable only the GPIO12 relay ( with a command ) on a certain time and enable it again later on the next day, i'm unfortunately unable to find such solution.

I've seen people suggest ButtonTopic or PowerOnState in which case won't work for me, I still want to send MQTT messages.

It's possible that I overlooked something but I'm unable to find this solution so far.

ascillato commented 6 years ago

Hi, you can achieve this behaviour using the rules feature.

Please, check the examples in the wiki.

Thanks.

Kiritzai commented 6 years ago

Thank you!

Although I wish I could've done this with my domoticz rules ( DzVents ) instead of rules on my device itself.

ascillato2 commented 6 years ago

Ok, you are welcome

If you need further assistant you can find us tomorrow in Tasmota chat.

Kiritzai commented 6 years ago

Not sure why you've closed it, i'm requesting a new feature which clearly isn't available 'yet' in tasmota. Feature request: turning off relay with a command that can be changed through URL.

ascillato commented 6 years ago

Hi,

It is already available. You need to use rules in order to make a logic enable/disable for relays. There are several examples in the wiki about the use of rules.

If you need further assistant about rules, you can find us tomorrow in Tasmota chat.

Kiritzai commented 6 years ago

That wasn't very clear for me. Though I didn't found it on the Tasmota wiki rules what I was looking for. I did found it on ESPEasy wiki that its called HTTP Call, so i'm not sure it will work for tasmota.

So does it work for tasmota? http://<someip>/cm?cmnd=event,someevent

Source: ESPeasy

HTTP call

When you enter this first command with the correct IP address in the URL of your browser:

 http://<espeasyip>/control?cmd=event,startwatering
 http://<espeasyip>/control?cmd=event,stopwatering

And have this rule in the addressed ESP:

On startwatering do 
  gpio,12,1 //start watering (open valve)
  timerSet,1,600 //timer 1 set for 10 minutes
endon

On stopwatering do 
  timerSet,1,0 //timer 1 set to halt, used to stop watering before the timer ends!
  gpio,12,0 //stop watering (close valve)
endon

On Rules#Timer=1 do  
   gpio,12,0 //stop watering (close valve)
endOn

Provided that you also have the valve etc, the plants will be happy.

ascillato commented 6 years ago

Hi,

All Tasmota commands can be sent by MQTT, HTTP and SERIAL.

All commands can be sent the same way with syntax: http://sonoff/cm?cmnd=Power%20off (please read the wiki)

All Commands and sintax in the wiki -> https://github.com/arendst/Sonoff-Tasmota/wiki/Commands

Rules: https://github.com/arendst/Sonoff-Tasmota/wiki/Rules#examples

What you have posted is exactly the idea I posted in the first answer. Use rules to make the behaviour you are looking for. Remember that the command's syntax for Tasmota are different. Please, check the wiki.

Kiritzai commented 6 years ago

Seemed the rules didn't work for me at all.

Simple solution for me was ( if anybody is interested ): GPIO set on 12 switch4 ( I'm using a PUSHBUTTON as doorbell )

I've set de switchmode to 2 for switch 4 ( Set switch mode to inverted FOLLOW (0 = On, 1 = Off) )

switchmode4 2

Relay off/disable

To disable Relay GPIO12, type the following in console

switchtopic 1

or HTTP Call/Command:

http://<tasmotaIP>/cm?cmnd=switchtopic4%201
or
http://<tasmotaIP>/cm?&user=<username>&password=<password>&cmnd=switchtopic4%201

Relay on/enable

To enable Relay GPIO12, type the following in console

switchtopic 0

or HTTP Call/Command

http://<tasmotaIP>/cm?cmnd=switchtopic4%200
or
http://<tasmotaIP>/cm?&user=<username>&password=<password>&cmnd=switchtopic4%200

Now I can keep it centralized by using this in DzVents in Domoticz. Just wanted to share this, cause I wasn't the only one that was searching for this.

gericho commented 5 years ago

Thank you to publish your solution but on my Sonoff doesn't work

What it is working for me with a normally open push button

Sonoff basic w/ tasmota v6.60

For Shelly 1 V3 (some bugs i think but you can try)

Now press the phisical button and be sure the relay stays always off when you press the button

Verify MQTT messages works as follow

  • 08:45:26 MQT: stat/yourtopic/RESULT = {"POWER":"ON"}
  • 08:45:26 MQT: stat/yourtopic/POWER = ON
  • 08:45:28 MQT: stat/yourtopic/RESULT = {"POWER":"OFF"}
  • 08:45:28 MQT: stat/yourtopic/POWER = OFF

Now set an HA automation like this one:

- alias: 'Push to ON'
  hide_entity: true
  initial_state: true
  trigger:
    platform: mqtt
    topic: stat/yourtopic/POWER
    payload: 'ON'
  action:
    - service: light.turn_on
      entity_id: light.kitchen

- alias: 'Push to OFF'
  hide_entity: true
  initial_state: true
  trigger:
    platform: mqtt
    topic: stat/yourtopic/POWER
    payload: 'OFF'
  action:
    - service: light.turn_off
      entity_id: light.kitchen

I hope it can help someone