OpenHAB and Moteino?

Started by detroit_johnny, February 28, 2015, 08:19:17 PM

detroit_johnny

Has anyone tried to use Moteino SwitchMote with OpenHAB?  I'm not a very experienced programmer but I tinker and I was able to get this instructable working at http://www.instructables.com/id/Uber-Home-Automation-w-Arduino-Pi/ and I can get incoming RFM69 signals into the RFM gateway and then sent to the Raspberry Pi by posting MQTT messages on the local network.  I can also get Moteino RSSI data onto OpenHAB but cannot control the switches so far (I get payload errors since the messages look different in format than the instructable).

There are some shortcomings to the instructable, the biggest I see is it appears to be only a 1-way (incoming) street to the Raspberry Pi, therefore no Moteinos could ever be commanded on or off using an iPhone app for example.  The other thing is I believe the overall hardware setup of the system is very inefficient.  They call for an Arduino acting as an RFM gateway, then another to be the Ethernet gateway to get MQTT going.  I believe both of those pieces of hardware could be eliminated and the RFM69 HW could be directly wired to the Raspberry Pi GPIO (RFM69HW is 3.3v as is Raspi GPIO).  That means tinkering with the OpenHAB source code which is where I think I'm officially out of my league.  It's a pretty big beast and I'm not sure how I would accomplish this hardware setup.  Maybe it calls for something that OpenHAB calls a "binding" but I'm not deep enough in the rabbit hole yet to know if this is the path to go down.

Thanks in advance for any advice on how to proceed.  I'm hoping to get my Moteino on the network soon!   :)

Felix

Stay tuned, a much more usable and more automatic interface for Moteino based stuff is coming from Low Power Lab. It will only require a few files.

Jasonhector

I have a similar setup to this. Rpi [use the rpi2 as openhab struggles on the rpi1] with a moteino usb plugged in-gateway moteino which translates serial mqtt data coming from the mqtt broker [I use RSMB instead of Mosquitto as it supports MQTT-SN (MQTT for radio networks)] to radio mqtt packets.
Here is some debug logs I posted last week of mqtt messages running over the radio network:  https://lowpowerlab.com/forum/index.php/topic,953.0.html
I have a video somewhere of how I control all the switchmote leds and SSR [switch all off an all on with a single openhab click]

The moteino gateway can be discarded if the RFM69 lib is ported to RPI and this has been done but I hear about reliability issues with that code. Maybe Felix would as a weekend project. ;) I still use a moteino usb as a gateway until the RF69 driver for RPI is more stable.

A single RPI can then run openhab, RSMB and be the gateway to the radio network through SPI.

I should document the rest of my work, here is the first half documented: https://github.com/jasonhector/Mqttsn-Mote-Library/wiki

I still need to update the code on github as well as the documentation. Im almost done with the 'soaking' tests, and then will document.

sumnerboy

Much like Jason I have a Moteino connected to an Arduino + Ethernet clone using I2C. This node is responsible for receiving RF packets from the various 'remote' Moteinos I have around the place, and translating them to MQTT publishes which are sent to my central MQTT broker.

openHAB then subscribes to the various topics on my MQTT broker and viola - I have Moteino sensor data in openHAB ready for integration with my home automation rules.

Interested to hear what these changes are tho Felix!!

Felix

I hope I didn't set expectations too high. My solution is very simple and barebones but focused on usability. There are no bells and whistles but a pretty flexible interface to show whatever you care to see in the way you want to see it.

sumnerboy

Sounds like the ideal solution Felix - simple is best!

Mazzic31

Hi,
Just to let other Openhab users know I also have a working setup with Moteinos / MQTT / Openhab.
I kept Felix's RPI gateway between Openhab and MQTT (which is nice and very convenient for debug or to get detailed info on my nodes).
The publish/subscribe is done by a few additional lines of code in the gateway.js (using MQTT.js).

Paul


Joshua

Hello,

Has there been a posting on controlling Moteino via MQTT or Moteino Gateway? I'm considering dabbling with the Moteinos for my home projects.

Thank you.

JA

Felix

I don't know of an update.
But basically the hardware is platform agnostic. You can use the hardware with whatever firmware/software you want as long as it supports the available radios I am offering. RFM69 is pretty commonly used in openhab implementations as far as I can tell.

Stevo

I've been trying to work out how to get traffic into and out of OpenHAB.

I know Felix has a (great!) working gateway for getting data from the remote nodes into the RPi. I've downloaded the relevant files, and have a working system. Now, it must be possible to get the data out of Felix's gateway and into OpenHAB. OpenHAB and Felix's gateway should be able to reside on the same RPi, and just communicate with each other. Perhaps MQTT fits in between the two.

I must admit I am stuck, despite spending several days looking around this and other forums. Perhaps I am looking at the wrong details (can't see the forest for the trees?).

Does anyone have any pointers on how to go about getting Moteinos to talk to OpenHAB? Felix's gateway is pretty slick, so that could stay (it would be better if it did stay), but I would like to know how to get data into and out of OpenHAB from the Moteinos.

joelucid

I use openhab on my server. I can't say that I'm very happy about it but it works until I have time to build something better. I have built a simple gw app that reads from serial and breaks down each packet and sends each value on via mqtt. Then any interested app (like openhab) can just hook into the mqtt broker to receive these updates.

This model scales nicely to my new approach of using esp8266 based gateways to bridge rfm69 to wifi. The esp8266 can speak mqtt directly and I just eliminate the serial/mqtt gateway. The esp8266 is dirt cheap so I can run several of these to support multiple frequencies and/or bandwidth settings.

To use this model with Felix gateway you'd have to forward packets on to mqtt in the gateway or modify the gateway to listen to a mqtt broker and create that serial/mqtt gateway I used to have. I don't think there's a way to make it run out of the box.

WhiteHare

That approach has a powerful elegance to it.  Once you bridge to MQTT you can instantly get tremendous leverage in the cloud (e.g. adafruit.io) , and that seems to argue for bridging as quickly as you can.  The beauty of it is that it's not either-or, so progress doesn't need to deadlock because of turf battles over which ring is going to rule them all.  Rather, it's very complementary to openhab or a Mightyhat Pi home automation server or whatever it is that you want to do.

joelucid

QuoteThat approach has a powerful elegance to it.  Once you bridge to MQTT you can instantly get tremendous leverage in the cloud (e.g. adafruit.io) , and that seems to argue for bridging as quickly as you can.

That might be true but I'm not really thinking about it that way. I just want to get ip packets from a to b with little overhead. And I want to keep the gw as simple and low maintenance as possible.

It remains to be seen if that can be achieved with a esp8266 - but it is certainly a challenge with a raspberry where there is so much that can go wrong. From corrupted flash cards via faulty wifi adapters to buggy power supplies. What you didn't correctly shut your gw down? Well unfortunately now it's corrupted etc.

joelucid

That said I think for many applications it is indeed best to just run any other software in the cloud to minimize cost and maintenance. The approach has its limits - like being unable to open the garage when the Internet is down. But on the other hand it also doesn't open when the power is down. At some point that will become a valid analogy.

syrinxtech

Quote from: joelucid on March 26, 2016, 02:55:21 PM
That said I think for many applications it is indeed best to just run any other software in the cloud to minimize cost and maintenance. The approach has its limits - like being unable to open the garage when the Internet is down. But on the other hand it also doesn't open when the power is down. At some point that will become a valid analogy.

Good point @joelucid,

I think that underscores the critical need for all gateway products, either h/w or s/w-based, to allow for both global and local IP address access.  Like you said, it's nice to be able to access cool tools over the Internet, but what happens when the Internet is down?  Well, if the gateway can still be accessed using local IP addressing, you can get back access to that service.  But, like you said, if you lose power then you had better have sufficient UPS capabilities.  We keep adding layers of redundancy, which is good.  Eventually you have to accept the fact that one day you might have to go over and manually lift the garage door.  :(