-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GPIO14 as door opening sensor #726
Comments
I used wrong filters for searching, I found similar question just before mine. I'll give it a try therefore I'm closing this subject. |
@witek1308 , can you tell me how you solved this issue? can you upload the link you referenced. I have switches on GPIO14 and 5 with relays on 4 and 12. every time I remove power from the Wemos it triggers the garage door. thanks in advance. |
Will have a look when back at my pc. Please check issue #725 this is where I started. |
ok the issue #438 is exactly what helped me (it's clear instruction what to do) |
thanks is a good step in the right direction for me but cant seem to figure out how to allow home bridge to read the Mqtt message and change the status in home kit - Using sonoff basic as a garage door opener with a reed switch. (need to be able to detect when the manual RF opened is used rather than homekit) |
you need to mount the opening sensor anyways (I did it). Reason: my garage door doesn't have just 2 states: opened and closed. If you press the button during opening you can stop it in between , same when closing. Therefore detecting the button was pressed will not tell you the state if this is what you need (especially if someone pressed the garage door RF or wall button - in my case you can control the door using 3 different ways independently - sonoff, RF remote, wall button) |
thanks for your help -- I agree this seems to be the way to go.. do you have the code you have used for this to work with homebridge and sonoff ? |
There is no code. I use openhab and integrated sonoff via http request
Wysłano z AquaMail dla systemu Android
http://www.aqua-mail.com
…--- Wiadomość oryginalna ---
Od: sabs01 <notifications@github.com>
Data: 21 września 2017 2:34:15 PM
Do: arendst/Sonoff-Tasmota <Sonoff-Tasmota@noreply.github.com>
DW: witek1308 <witek_1308@poczta.onet.pl>, Mention <mention@noreply.github.com>
Temat: Re: [arendst/Sonoff-Tasmota] GPIO14 as door opening sensor (#726)
thanks for your help -- I agree this seems to be the way to go.. do you
have the code you have used for this to work with homebridge and sonoff ?
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#726 (comment)
|
thanks I think I have figured it out - have changed my config.json file to the following : instead of this allows me to read 1 reed switch but need to figure out how to set up pins on the sonoff to read more than 1 switch, and code to read the MQTT topic for any other reed switches?? can anyone help thanks in advance. |
you can define up to 4 GPIOs to be switches (switch1-switch4)
|
thanks David I am a noob at this can you explain how - have tried to configure sonoff as a WEMOS mini and set GPIO3 as switch 2 but no joy? |
what do you mean by 'no joy', do you mean that you can't find where to set the
GPIO as switch2, or that it's not working as expected after you make that
setting?
I seem to remember that GPIO3 is part of the serial port, so you need to disable
serial logging for it to be usable as a generic I/O pin.
|
Thanks David yes I can set GPIO3 to switch2 but cant get it to work in the same way GPIO14 does - you are correct GPIO3 is a serial port- perhaps I need to use a different GPIO to make things simple what do you think? any ideas on how to access other pins on the sonoff basic? or how do I disable serial logging - I am really clueless with this.. |
Mate you are a legend I have disabled serial logging and it works as an I/O pin - reading as cmnd/alarm/POWER2 = TOGGLE |
the sonoff basic doesn't really let you at the pins easily. If you disable the
serial logging, you can try to use those pins as GPIOs for sensors.
otherwise, you need to solder to the pins or use a different module.
|
@witek1308 How do you get Tasmota on your 1 channel inching 5v. Can you please have a look at my issue? |
Can someone please help me im getting into my hairs and its killing me: I changed topic for gpio14 to another one i see it in mqtt.fx it goes to on or to off. In openhab when i call it, it wont show "open" or "closed" state/change on gpio14. this is my setup on openhab: Mqtt.fx: shows this when state to gpio14 is changed: items: // WemosD1-000B9593D topic works fine i can use this to publish cmnd no problem. I have changed the topic for switch2 via console to alarm-000B9593D for the gpio14 swich2 (10)// /* Items to represent the open/closed status of the opener */ //In folder transform i have created en.map i put strings in there to define:// Sitemap: //Please if someone can help me in any way or just point me.// |
I do things like:
Switch sw01 "David's Light" {
mqtt=">[openhab-mqtt:cmnd/sw01/POWER:command:OFF:0],>[openhab-mqtt:cmnd/sw01/POWER:command:ON:1],<[openhab-mqtt:stat/sw01/POWER:state:MAP(binary.map)],<[openhab-mqtt:stat/sw01/POWER:state:MAP(binary.map)]",
autoupdate="false" }
this watches for changes via stat messages, and via tele messages
cat binary.map
1=ON
0=OFF
On=ON
Off=OFF
ON=ON
OFF=OFF
|
Thanks for a hint but it didnt work i tried your way. With state:MAP and no dice wont read. I just dont get it i can switch the items on/off but cant read current state dont get it i had to change topic due to unlinking the gpio14 from gpio5 so 14 dont turn 5 on when closed. |
check the openhab logs, it should tell you where it's having trouble.
|
There is nothing in the logs i have allready checked it in openHABshare/openhab2-logs/ |
then check the mosquitto logs and see what it's showing.
Increase log detail if you need to.
you should see the stat/ or tele/ message arrive at mosquitto and what it is
being delivered to.
Once you have openhab configured to get the correct messages, you should see the
message arrive in openhab and what it does with it.
|
Thanks a million "Paulf007" this one helped me finally im out off the loop. Now i see the state change but im having issue when sensor closes i get two states shown in classic-UI I had to change settings in my module it would not work like basic (with it GPIO rules) so i made them work like this: This is my items code: This is my sitemap code: The sitemap is like it is yours "Paul007" This is my console point out of WemosD1-mini 00:00:17 MQTT: stat/WemosD1-000B9593D/POWER1 = ON |
I made a typo while edit now it works!!! this is the correct sitemap: Switch item=main_gate_gate visibility=[main_gate_stat1=="OFF",main_gate_stat2=="OFF"] mappings=["ON"="Open Gate"] icon="garagedoor" If someone wants to build a GOPENER with arenst tasmota and Wemos D1-mini i can say that it works now i got some greyhairs and restless nights. But got out off it thanks to Paul007. Upper response is full layout od settings after uploading the firmware you have to go to console: Then go and play with openhab.... |
Thank you for that one as well. There is so many features in this firmware that it keeps on amazing me!! |
has anyone encountered an issue when wenos is being trigrerred to open door by itself i checked logs once the wifi was lost onve it was a wemos reboot once it happened when mosquito reboot. Does anyone have an idea how to stop this from happening. |
@bandric1 I have the exact same problem. When my wemos d1 mini is connected to my mqtt server, it all work as it supposed to, but if the wemos loose connection to the mqtt server, my reed switch, act like a real switch, switching the relay. |
@bandric1 I finally got it working. Switch1 will always act like a real switch for relay1 if no mqtt connection. I have made mine with a switch1 not connected to anything. I have then added a reed switch to switch2 and send the command: "switchmode2 2" and "switchtopic2 alarm". now the reed switch return "stat/sonoff/RESULT = {"POWER2":"OFF"}" and "stat/sonoff/RESULT = {"POWER2":"ON"}" without toggle the relay1 :-) |
Great please post screenshots from tasmota web interface and settings from things, items and sitemap. So everyone can benefit. |
I use the Wemos D1 mini with relay shield. The relay is connected to D1 (GPIO5) I have set it up to: The I console I ran the command: Now Relay1 (relay shield) is independent from switch2 (reed switch) even if there is no mqtt connection. When you look at the main menu, there is actually 2 relay and the reed switch is controlling the relay2 which have no physical connection. Now when firing the command cmd/sonoff/POWER1 ON the relay turn on for about 1 sec and the turn off again. The status of POWER2 (reed switch) I am catching in node-red to fire a pushover message to my iPhone telling if the garage door is open or closed. |
I finally got some time tried it u used now latest tasmota firmware but here is something with this firmware that it doesnt like this wemos d1 mini after mosquito restart or device looses wifi or restarts after power loss garage door opens im loosing it i guess i will just give up on this and try other firmware since this is not working for me. |
all my other devices sonoff and esps dont supper from this only the wemos d1 mini does |
Have you set it to: PowerOnState 0 If it’s set to on, it will toggle the relay on restart |
When the ESP8266 is first enabled, the GPIOs go to a known state before any
software gets to do anything to them.
Relays can be wired to be on when the GPIO is low, or when it's high.
If you are having problems with the relays momentarily switching to the wrong
state before going to the correct state via poweronstate, then you need to get a
module that has the relays wired the other way (and in the module config, you
change from relay1 to relay1inv, the inv being for inverted)
for the types of things the sonoffs were designed for, this momentary pulse in
the wrong state doesn't hurt anything, but for opening the garage door, this can
be enough to trigger problems.
|
I changed the wemos d1 module with other one and now it works. Damn i used so much time on this. |
It works as meant thank you guys. Well it did until today now its back to start one after restart or power loss or wifi loss it clicks. I woke up today and garage was wide open. I guess i give up. Will try someone else firmware. |
Does anyone know in terms of sensors if this would work with the above code? |
I believe it will work. Just verify if it is Normally open or Normally close. |
I shall do. I will need a Normally Closed sensor. I also have a seperate relay free on my Sonoff 4CH WIFI Pro R2, I'm assuming I can use this and not GPIO14 on the Sonoff Basics as per this thread. I have tasmota on there. Do you know whats requird Julius to have it function? |
I do not have a Sonoff 4CH. But based on the specs it should work in a similar way that it does on the basic one. Take a look at https://youtu.be/uwFmfC0iJiY |
Yes, I have this unit. |
Here's how I just did without MQTT (Sonoff Basic, Reed sensor on Gpio 14 + Gnd): Module Configuration:
Finally, relay2 status can be queried by Power2 command. Switchmode2 2 (for NO reed, 1 for NC reed) - this way Relay2 status will follow the state of the reed correctly, if by mistake it was software-triggered to an opposite state. Now it's time to write a HomeBridge plugin, which will control the whole logic. |
@i3laze can you explain the virtual relay concept a bit more? I've configured two Sonoff basics for use as garage door openers, with a reed switch on GPIO14. I have them setup in Home Assistant, but when Home Assistant is rebooted, the state of the garage door is not shown. I could set the powerrtain on but then relay1 is cycled on each reboot. I'm wondering if having the virtual relay to store the state could nullify this shortcoming, so that I can still track the state of the garage across reboots. |
Hi @jcconnell To make home assistant read the status of Tasmota when home assistant restarts, it is explained at the wiki in the home assistant part . It is just adding an automation to make all sonoffs inform its status when home assistant starts. |
At Tasmota wiki I meant |
It looks like that is sending a command to the sonoff. How do I read the state of the sensor? The statetopic for the garage door reed sensor is "cmnd/garage_door_status/POWER2" |
If you want Home Assistant to know the state of all your Tasmota devices when Home Assistant starts, just copy and paste (without modifying anything) to your automation.yaml the configuration explained in the wiki at: No need to modify anything neither use retain values in Home asistant nor in the MQTT broker. The internal state of the Tasmota need to be just in Tasmota. The topic sonoffs is a group topic. All Tasmotas have that as default. No matter that you have changed your device topic to garage_door_status. That's why, just copy and paste and should work. I use exactly that and works amaizing. |
Awesome, that works well for my other sonoffs. Thank you. I have a unique use case for the two I'm using as garage door openers though. I need to keep track of the status of a reed sensor connected to GPIO14 on these two Sonoffs. The reed sensor indicates the position of the garage door: Normally closed so 1=open, 0=closed. The relay controls the actuation of the door: 1 sec pulse = pressing the wall mounted button. |
I noticed that the telemetry reports the state of the reed switch on GPIO14. I wonder if it's possible to use that instead? |
Yes, the telemetry is intended for that. You can use that of course. You should have a telemetry like:
So, put in your configuration.yaml sensor:
- platform: mqtt
name: "Humedad Ambiente"
state_topic: "tele/sonoff/SENSOR"
value_template: "{{ value_json['Switch1'] }}" |
Any (web-) command to query switch state without MQTT? UPD: Found. Status 8! Can build on that. No need for relay2 now :)
|
Here is what I have currently:
Would this be the correct implementation to use telemetry as state?
Finally, I've noticed that if I reboot a Sonoff, the item becomes unavailable in HA, but it never becomes available again once the reboot finishes. Any idea why? |
In your last config you are mixing controlling with sensing. Those need to be separated. |
has been a while since someone posted here. I need assistance on getting the GPIO14 to read more than just on or off. I have a gate motor with a dedicated Gate status output. The gate status can be open,close,opening,closing,collision. How do I configure the GPIO to read all those different states and add it to HA. |
Hi, this issue is very old and your question is not directly related to this. Please, open a new discussion posting all the information you have (hardware type, tasmota version, what have you tried, etc), or ask in the support chat. Thanks. |
Hi,
I can't find this anywhere on the internet whether Tasmota on Sonoff basic would support the a door opening sensor on GPIO14, but without impacting the state of relay (use GPIO14 just for reporting the state, ideally over MQTT).
I simply in my garage have one Sonoff Basic with Tasmota (5.5.2) which controls some other thing but is so close to the garage door that wiring will be piece of cake, it would be perfect to report open/close state. Garage door is controlled by "1 channel inching 5v" module running Tasmota too but as I understand this one doesn't have any GPIOs to do the work. Thanks in advance for all hints.
The text was updated successfully, but these errors were encountered: