LowPowerLab Forum

Software support => Pi Gateway => Topic started by: GregMo on February 20, 2017, 12:23:27 PM

Title: Moteino recieve gateway "modes"/states on reset?
Post by: GregMo on February 20, 2017, 12:23:27 PM
Hi there

I'm plodding along with a implementing a variation of a mote which merely controls a few relays. Its basically a cut down version of the switchmote code without all the sync features (which are amazing, just unnecessary for me) and config helpers.

How would I go about implementing that the pi gateway sends the the last set state for each of the relays attached to the specific moteino? In the event the power is tripped, I would like the pi gateway to resend the last states of the relays after it receives the "start" message a particular node.

I hope this makes sense. Any suggestions would be appreciated.

Regards
Greg
Title: Re: Moteino recieve gateway "modes"/states on reset?
Post by: Felix on February 21, 2017, 12:34:32 PM
Hi Greg,

Great question - this is supported via the serverExecute function of an event.
Basically all you gotta do is create your own event in the exports.events object.
Add this code in your own user metrics js file under _userMetrics folder.

There are many examples how to do it in that collection in the master metrics.js (https://github.com/LowPowerLab/RaspberryPi-Gateway/blob/master/metrics.js), just look for the exports.events and specifically the serverExecute.

Perfect examples to follow are: