LowPowerLab Forum

Software support => Pi Gateway => Topic started by: wmljames on February 02, 2018, 01:13:45 AM

Title: Alexa echo interface to Gateway for binary state devices needs status command
Post by: wmljames on February 02, 2018, 01:13:45 AM
Background on project:
I have been working on a project that uses a Moteino to drive a step motor to open a dog kennel door.  The foundation for the Moteino is the GarateMote.  The goal was to be able to open the dog kennels remotely via smartphone.  After getting the gateway to work I decided to try to interface with the Alexa echo, and I have been successful. 

Communicating to Alexa:
To communicate to the Alexa, I found a python script on Github (makermusings fauxmo) that emulates a Belkin Wemo smart plugs on the PI.  The only short-coming is that the python script only emulates smart plugs (binary on/off) but for my project it works fine: binary/on is mapped to the GarageMote Open status and all other GarageMote status metrics are mapped to binary/off.

To interface the Gateway with the python Wemo/fauxmo script, I installed a python-shell script from Github (extrabacon/python-shell) that allows running a python shell as a child process to the Gateway’s node.js platform.  I developed the API protocol to send JSON objects between the Wemo/fauxmo script and the Gateway.js nodes that control the binary/on/off and status commands.

The code can work for any gateway node that can be controlled as binary on/off switch.   There are a few places that gateway.js code needs to call the fauxmo JSON API (e.g whenever a node update occurs) and the metrics.js need to show which metrics have a binary attribute and the state 0/1. 

The code also depends on getting the current status of the node devices during initialization.

I can release the code to the project forum (assuming Felix doesn’t have a problem with sharing it) but I thought it would be useful to also get the SwitchMote working first. I have been simulating the Switchmote with my Garagemote since I don’t have a SwitchMote and I’m fairly close. 


My Ask:

I know the basic on/off commands for the 3-buttons on the SwitchMote (btn0:0/1), but I’m not sure what command to send to get the status (on/off) of each button switch.  For the Garage mote, the status command is [node]:STS.  Can anyone tell me what action command can be sent from the gateway to the SwitchMote and the output expected from the SwitchMote to get the on/off status of each button switch?

Title: Re: Alexa echo interface to Gateway for binary state devices needs status command
Post by: Felix on February 02, 2018, 09:36:17 AM
I know the basic on/off commands for the 3-buttons on the SwitchMote (btn0:0/1), but I’m not sure what command to send to get the status (on/off) of each button switch.  For the Garage mote, the status command is [node]:STS.  Can anyone tell me what action command can be sent from the gateway to the SwitchMote and the output expected from the SwitchMote to get the on/off status of each button switch?

@wmljames - there is no status command programmed in the SwitchMote example. You can follow the pattern found in GarageMote to query the status of the 3 buttons. Perhaps something like STS[0,2].

Maybe if I get some time sometime, I can code this up. But hey give it a try.
I would also be interested in adding a SwitchMote configuration option to indicate how many buttons/relays are installed, so the SwitchMote Gateway node UI can be populated accurately when the node is added in the Gateway app.
Title: Re: Alexa echo interface to Gateway for binary state devices needs status command
Post by: mhaggerty on May 26, 2019, 11:10:24 AM
@wmljames

I just published code on GitHub that will allow control of a GarageMote (see: https://github.com/mikehagg/garagemote.alexa ).  It may help with the interface you are working on.