mqtt-io icon indicating copy to clipboard operation
mqtt-io copied to clipboard

Digital outputs multiple pin, same topic

Open terminet85 opened this issue 3 years ago • 2 comments

There is any change to turn on/off multiple pin with the same mqtt topic?

RPi.GPIO module should be able to manage it chan_list = [11,12] # add as many channels as you want! # you can tuples instead i.e.: # chan_list = (11,12) GPIO.setup(chan_list, GPIO.OUT)

terminet85 avatar Oct 07 '20 12:10 terminet85

I've made a PR in order to fix schema check. RPi.GPIO are already capable to manage lists, so the problem was only in the config check.

digital_outputs:
  - name: fireplace
    module: raspberrypi
    pin:
       - 17
       - 27
       - 22
       - 5

terminet85 avatar Oct 08 '20 13:10 terminet85

Hi, thanks for your work on this.

It's a good idea, but as far as I'm aware, your PR would break compatibility with all of the other output modules, such as pcf8574 which has a set_pin() implementation of:

    def set_pin(self, pin, value):
        self.io.port[pin] = value

As you can see, the pin value cannot be a list in this example.

In order to implement this, we'd need to establish which modules' underlying libraries are able to take lists of pins and set them all at once, then enable this functionality on just these modules.

As it stands, this is a relatively low priority for me compared to some of the other things on my list, so I wouldn't work on it any time soon, but pull requests to the effect are welcome.

I'll close the existing PR as it stands, but keep this issue open to track any progress.

flyte avatar Oct 17 '20 16:10 flyte