Author Topic: gateway customization add RF controlled outlets  (Read 1572 times)

loseymark

  • Jr. Member
  • **
  • Posts: 60
  • Country: us
gateway customization add RF controlled outlets
« on: July 29, 2016, 04:39:28 PM »
I had existing garage sensors tied into a home web page running on a Raspberry PI before I implemented my Moteino PI Gateway. I also had an idea to implement some other PI controlled "sensors" like an email interface to my security system status and RF controlled outlets for turning on surveillance cameras implemented with R-PIs.

I liked the Gateway Dashboard a lot because of the security and the UI design, which worked well on various devices including a R-PI with a 7" touchscreen.

I decided to customize the Gateway Dashboard with several objectives in mind. First, my customizations had to be simple because I have no node.js or javascript experience and not a lot of time. Next, I wanted the modifications to be modular so I could easily upgrade the gateway and incorporate my changes. I only wanted to add functionality and not change any existing code or functionality. Finally it had to interface with my R-PI implementation and python programming.

On the R-PI I had an existing garage door monitor based on a PI in the garage interfaced with a home web page. In my PI environment I use Pyro - Python Remote Objects which allows me to do remote procedure calls from one PI to another.

I added a PI to the mix that I call pimote that will interface with the gateway via a moteinoUSB. The pimote sketch receives serial commands from pimote and uses radio.setAddress to act like a separate moteino node for all of the pimote managed "sensors".

I used the instructable below to have pimote control several RF outlet devices from Etekcity and Foval. I have thirteen outlets managed via pimote. https://www.samkear.com/hardware/control-power-outlets-wirelessly-raspberry-pi

Finally I have a home security system with no way to interface into the gateway except that it sends an email whenever events occur. I used fetchmail on the PI to write an e-mail parser that intercepts the security system emails and displays the status on a gateway node.

To modify the gateway I added an icon next to the settings icon that implements a page I called "My Place". I coded a list of my RF Outlets in metrics.js to populate a list of outlets that I can control with on/off commands from the gateway app. Metrics.js isn't really where I want to keep this list, but I needed fast functionality. Eventually it will be a separate json5 file that I can modify like settings.

When an rfoutlet command is selected, a python script gets called via python-shell from gateway.js. This python script does a Pyro call to the rfoutlet controller on the pimote R-PI.

Seems convoluted, but it works well and lets me interface with my PIs and still take advantage of the gateway functionality, UI, and security features.

Attached are screenshots and code snippets for most of the functionality except the mail parser. I can add that if you are interested.