n8henrie / fauxmo

Emulated Belkin WeMo devices that work with the Amazon Echo
https://n8henrie.com/2016/02/fauxmo-home-automation-with-the-amazon-echo-raspberry-pi-and-homeassistant/
Other
377 stars 78 forks source link

Using Fauxmo to control GPIO Relay board #95

Closed Isarian-de-Picardia closed 4 years ago

Isarian-de-Picardia commented 4 years ago

My Issue

I was watching the video here: https://www.youtube.com/watch?v=OQyntQLazMU

This video uses a collection of Python scripts that can be seen here: https://github.com/skiwithpete/relaypi/tree/master/4port

The scripts work fine on their own, but have to be run individually.

Relay 1 plugged into the Raspberry Pi GPIO here: https://i.imgur.com/AlIoygH.png

I was wondering how Fauxmo could be combined with these GPOI scripts to control the relay board with the Echo Dot. Say have each relay register as a Switch on Alexa, then have the on/off state controlled by running script similar to 5a and 5b in that collection for Relay2.

WHYT


Please make sure you've taken these steps before submitting a new issue:

n8henrie commented 4 years ago

Hi!

This should be pretty easy. I would recommend starting with the docs for CommandLinePlugin (note that I just had to rebuild the docs, which hadn't updated with the last major version for some reason). Also please disregard the part about it not being included by default, which is a recent change. I have updated this docstring in the dev branch.

Basically, if you can turn on switch with python scripty1.py and off with python script2.py, you should be able to configure a CommandLinePlugin instance to run /path/to/python /path/to/script1.py as the on_cmd and analogously for the off_cmd.

Alternatively, since the scripts you're referring to are in Python, you could also subclass FauxmoPlugin and have the switch logic embedded into a custom class; for further details check out n8henrie/fauxmo-plugins.