ratgdo / mqtt-ratgdo

ratgdo via mqtt
GNU General Public License v2.0
85 stars 20 forks source link

Repurpose open/close/light terminals for reed switch? #9

Closed lukescott closed 11 months ago

lukescott commented 1 year ago

I know the Ratgdo knows the door open/close state when in operation. What isn't clear to me is if it knows the door state when it is manually opened/closed (forced open).

The Ratgdo has triggers for open/close/light used to trigger these actions without needing WiFi. Could there could be an option to repurpose one of these terminals to read the state of a reed switch? And preferably report it as a different sensor. That way if the door was forced open the Ratgdo could report on it.

Previously I used a Z-Wave MIMO Lite w/ the reed switch to open / close the door. I could potentially keep the sensor plugged into that still, but I'm short an outlet. And it would be cleaner if the Ratgdo had a way to utilize the switch.

dbrewer-wdc commented 1 year ago

I'm not a programmer by profession but I can get around the code ok. I've used Arduino IDE in the past and I have this project compiling on that platform for now. I have a goal to get PlatformIO working as well as VS Code, which is an editing environment that has a PlatformIO plugin. The reason I stuck with Arduino IDE for now is that it will download the compiled code to the ratgdo or ESP device. It will even do it over the air. And if attached serially, as soon as it is done loading, it starts up and you have your attached serial port. With that said, there were many pittfalls. In the platform.ini file included in this project, it will tell you which versions of the libraries to use as well as some compile time options that I had to hardcode into the code and libraries...not the best way to go. But if you know your way around a programming environment, PlatformIO or VS Code might be the way to go.

As for what you want to do, sure, that would be pretty simple. I don't think you need an OPEN and CLOSE button. I changed mine to just TOGGLE for the switches; however, for MQTT commands, I still use open and close. Seems more appropriate for automation. And now I use the CLOSE input for another feature. But yeah, a reed switch input would be perfect.

BR

lukescott commented 1 year ago

@dbrewer-wdc I opened an issue here asking for a contribution doc. So you would say compiling and updating the firmware is fairly straight forward? I just want to make sure I don't end up bricking it.

I am a programmer for my day job, but I'm more on the web software / server end. I haven't done anything with Arduino.

dbrewer-wdc commented 1 year ago

@lukescott. I don't know how you can brick it, but I'm sure it is possible. The ESP device is pretty cheap...it is a D1 Mini and you can get them on Amazon. However, unless you do something drastic to it, I think there is little chance of bricking it. With the Arduino IDE, which I motioned in the other post, there are quite a few gotchas to getting it to compile correctly, but if you look at the platform.ini file, it tells you which libraries to use and some compile options you'll need. The Arduino IDE can auto download the image after the compile. However, there are a few things you have to do to set it up. I'm sure PlatformIO is better and probably does all the same things...but actually reads the platform.ini file. I'd suggest finding a tutorial on YouTube programming a D1 Mini with PlatfomIO. Yup, there is. I searched, "d1 mini with platformio" on YouTube and a got quite a few short videos. I didn't watch any, but I will soon. Right now, I have it compiling so I'm just sticking with Arduino IDE for the remainder of this project.

BR

CrazyCoder commented 11 months ago

The firmware has support for open/close reed switches, which work in dry contact mode for stupid GDO without security. I'm using exactly this setup for my Genie GDO, and it can detect a manual door open and close

PaulWieland commented 11 months ago

A security + 1 or 2 door will not update the door status if it is manually opened because the GDO head tracks the position of the chain and door trolly, not the actual door position.

The reed switch inputs only work in dry contact mode which can't be used with Security + openers. For Security + openers, these terminals are inputs for controlling the door with dry contacts.

To get them to be inputs for updating door status would require a bunch of work in the firmware since there will be a conflict between what the GDO is reporting and what the reed switches are reporting. That's not something I want to add to the official firmware since it will create a lot of confusion and support issues.

It's open source though so feel free to modify your own fork.

dbrewer-wdc commented 11 months ago

@PaulWieland that sounds reasonable. However, it does seem there are a number of doors like mine where the wall switch does not request the door status (38). Having a reed switch would be the best alternative for this scenario. Perhaps just assume reed switch mode for the door input upon power up unless the input is toggled a few times in rapid succession indicating a button is present....or some other variation.

I'd have offered up that code, but I currently use another ESP32 that monitors the door through a reed switch and issues a doorstatus MQTT command to the ratgdo (modified code with a new doorstatus command) so it can report to home assistant the correct door status. And just one reed switch is sufficient.

For my opener, a 40 command comes back with 80 from the opener when the door is moving and 00 when it isn't. So if you wanted to know open closed opening or closing, that still could be determined, but I think just open/close is enough.

lukescott commented 11 months ago

I don't even need the reed switch to be the door status. If it could report as an independent sensor / device that would go a long way for me in using it as a security sensor. I could hook this up to a different device, but being able to wire it to the Ratgdo would be more convenient.

dbrewer-wdc commented 11 months ago

@lukescott , yes, you could do that quite simply. But that would definitely be your custom code. You would need to create a new sensor status and then a report status via MQTT. If you have Homeassistant, you can even modify the home assistant code to report a new boolean sensor. Were you able to get the environment to compile?

PaulWieland commented 11 months ago

@PaulWieland that sounds reasonable. However, it does seem there are a number of doors like mine where the wall switch does not request the door status (38). Having a reed switch would be the best alternative for this scenario. Perhaps just assume reed switch mode for the door input upon power up unless the input is toggled a few times in rapid succession indicating a button is present....or some other variation.

If you want to use reed switches, then just change your control protocol in ratgdo to dry contact mode. The reed switches are then wired to the trigger door inputs. (see wiring diagram)