Moteino recieve gateway "modes"/states on reset?

Started by GregMo, February 20, 2017, 12:23:27 PM

GregMo

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

Felix

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, just look for the exports.events and specifically the serverExecute.

Perfect examples to follow are:


  • motionLightON23 - when MOTION is received from a MotionMote, an ON message is sent to another SwitchMote to turn lights ON
  • switchMoteONBUZZ - when a switchmote turns ON, a beep is played on the gateway buzzer