flyte / mqtt-io

Expose GPIO modules (Raspberry Pi, Beaglebone, PCF8754, PiFace2 etc.) and digital sensors (LM75 etc.) to an MQTT server for remote control and monitoring.
MIT License
469 stars 159 forks source link

Add local logic to connect inputs to outputs without relying on external control #19

Closed ssjha closed 3 weeks ago

ssjha commented 7 years ago

hi, For my home automation project, i was looking for a way to control a set of relays using mqtt (and Openhab). And as an added feature, i wanted to use a switch array (connected to separate GPIOs on my PI zero) to control these relays. I tried writing my own python program but failed miserably at it. Recently i came across your implementation and tested it. It is working very well in controlling the relays using mqtt and capturing the button press. However, i was trying to find a way to control the relay when a button is pressed.

button 1(GPIO 19) -> "ON" -> publish mqtt status |---> pull up (GPIO 4) to control the relay.

One implementation option is subscribe to the mqtt input status message and send a new output message to switch on. This has to be done by Openhab or any other python routine. Is there any other way to achieve this?

Thanks Sudhansu

flyte commented 7 years ago

Hi Sudhansu,

I wrote a whole explanation as to why I don't want to include this in this project, but the more I think about it, the more I'm leaning towards thinking it's a good idea.

Pros:

Cons:

Things to think about:

Can you think of any other pros/cons/thoughts?

ssjha commented 7 years ago

Hi Ellis Thanks for having a detailed thought about the feature. I understand that implementation will have its complication.

You have listed the pros/cons correctly and I can't think of any additional ones. I believe the primary advantage is with this, the PI module will become a self contained unit and with a small footprint of PI zero/ZeroW, it can be setup as an add-on to the existing controls.

The button behavior can be configurable as it depends on the type of button used.

  1. Follow the switch (0 for OFF, 1 for ON)
  2. Inverse of the switch (1 for OFF, 0 for ON)
  3. Toggle (change the state from ON to OFF and vice versa) This will be inline with the existing functionalities implemented using the inverse and toggle functionality. I am using a push button momentary switch and expect the toggle behavior.
flyte commented 7 years ago

Something else to think about is the switch debounce. I currently use a crude method to double check the input but it doesn't scale well if you have lots of inputs. It would also need to be abstracted and/or have configurable parameters for each input.

Just dropping this here to remind myself while I'm on my phone.

On 1 Aug 2017 9:28 am, "ssjha" notifications@github.com wrote:

Hi Ellis Thanks for having a detailed thought about the feature. I understand that implementation will have its complication.

You have listed the pros/cons correctly and I can't think of any additional ones. I believe the primary advantage is with this, the PI module will become a self contained unit and with a small footprint of PI zero/ZeroW, it can be setup as an add-on to the existing controls.

The button behavior can be configurable as it depends on the type of button used.

  1. Follow the switch (0 for OFF, 1 for ON)
  2. Inverse of the switch (1 for OFF, 0 for ON)
  3. Toggle (change the state from ON to OFF and vice versa) This will be inline with the existing functionalities implemented using the inverse and toggle functionality. I am using a push button momentary switch and expect the toggle behavior.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/flyte/pi-mqtt-gpio/issues/19#issuecomment-319304115, or mute the thread https://github.com/notifications/unsubscribe-auth/ABGZ2FZCs91T4bYzNKPjEu3yq9PhcxM2ks5sTuGhgaJpZM4OoPle .

c3reeman commented 5 years ago

Was there any change on this ? I too am looking to be able to tie an input to an output or multiple outputs, it would be great for simplicity and avoid home assistant clutter

dandantheflyingman commented 2 years ago

I was thinking about this too and would a halfway point be the ability to execute a script locally? So say the correct message comes in on a mqtt topic, and it responds by running a script with a set of parameters?

In a script the user can make it as advanced or as simple as they like.

Does that open any security concerns?