Node-RED / MQTT API

Hi there,

I’ve made some Node-RED nodes that interfaces to Cayenne using the MQTT API. I think they’re ready for Beta use.

So, is there any interest in such nodes? If there is I’ll go through the Node-RED packing and publish them…

/michael

1 Like

I think this is a great idea, and I was actually planning on doing this myself. What do you have so far?

  1. A Configuration Node that
  • references a Node-RED MQTT Broker.
  • stores Cayenne username and client id.
  1. A Sensor Node that
  • references the Configuration Node.
  • stores channel id.
  • stores sensor type and sensor data unit (drop-down lists).
  1. An “automatic” Actuator Node.
  • references the Configuration Node.
  • stores channel id.
  • stores actuator type and actuator data unit (drop-down lists).
  • one output (message data from Cayenne).
  • automatically sends reply and response back to Cayenne.
  1. An “manual” Actuator Node
  • references the Configuration Node.
  • stores channel id.
  • stores actuator type and actuator data unit (drop-down lists).
  • one output (message data from Cayenne).
  • one input (reply to send to Cayenne).

The nodes build the MQTT topics themselves, pack/unpack message data to/from Cayenne format.

I can start by sharing the code on my OneDrive, then later on the “full monty” (GitHub, NPM)… ?

Beta-testers/help would be appriciated :slight_smile:

/michael

1 Like

If you want to post a link to the code I’ll try it out and let you know what I think. We can combine ideas to make it as easy and efficient as possible. Not sure if you saw it yet or not, but I made a write up on using Node-RED as a local server with generic nodes over here Using Node-RED as a Local Fallback Server - #2 by mike306dt and some custom nodes would go perfectly to simplify things.

1 Like

I LOVE it!! I think Cayenne + Node Red can be extremely powerful! Killer!

Here we go :slight_smile:

https://1drv.ms/f/s!Aibhyn1twn1Lg49seyiWdna1XW_maQ

1 Like

This looks fantastic, thanks for the tag Adam and mikejac - great work!

Hold your horses: There’s something that prevents Node-RED to successfully deploy changes when these nodes are in use - investigating …

/michael

I actually haven’t had a chance to look yet. Tonight I should have some time do sit down and install them.

Code update!

Note: In order to test all this, I had to use ‘npm link’ as described here: http://nodered.org/docs/creating-nodes/packagin, “Testing a node module locally”.

Code updated again!

/michael

Just had a chance to load up the node but didn’t test much yet. I had a look around and noticed a couple things:

I don’t think the server config is necessary. If the MQTT username/password/client ID is requested then the server information is known
Data type/unit is not supported for actuators, so they can be removed there. Also, maintaining the list of supported data types is going to be a hassle, might be better to just leave it as a text field unless you don’t mind (or at least create a enter your own type/unit).

Overall it looks great, has a lot of ideas I was going to work on. Nice job! Hopefully I’ll get to actually test it tomorrow.

-what if I want to use a DHCP enabled WiFi/router -downported to my “main” Internet WiFi/router?

I want to keep my IoT and my Internet segregated/segmented. I prefer my IoT router to communicate inside my IoT WiFi/Ethernet LAN only (excepting my WiFi tablets).

Internet is NOT an option for me. Not available for my primary residence in the near future. I’m building the home now! Hughes Satellite Internet sucks. The latency makes VoIP impracticle. We need that Google Blimp!

Cayenne is a cloud service, so at that point Cayenne is out of the question.

I am really curious how to hear everyone’s thoughts about what possibilities people could see by connecting Node Red and Cayenne. Could Cayenne ingest Node Red flows? or does Cayenne become a Node in Node Red? I am quite familiar with Cayenne, but I am only slightly familiar with Node Red, but on the surface they seem so complimentary. Thoughts?

Tis why I’m hoping for MQTT server, within my LAN. Mosquitto

I’m just saying that without internet you’re not going to be able to use Cayenne. You can certainly make your own custom local MQTT environment to suit your needs though.

trying to wrap my brain around cayenne, node-red, and mqtt.

If I understand correctly from my research, you can just use node-red, mosquitto, and a simple web interface to do what cayenne mostly does but locally.

even if you have cayenne and your internet goes down node-red will keep things going for you and allow you access and control through local lan.

I like cayenne.
Super easy to setup and is getting me where i need to be in as little time as possible but it might not work for some.

I’m running a Mosquito broker at home (on an OdroidC1). All my ‘things’ connect to this broker. On the broker I have created a MQTT bridge to Cayenne. Then, in Node-RED I use my own MQTT broker to connect to. So I need to store username and client id for use by the Cayenne nodes.

Yes, I noticed that no datatype/units are sent from Cayenne when actuators are, well, activated. On the other hand, datatypes/units are described on this page: http://www.cayenne-mydevices.com/docs/#bring-your-own-thing-api under “Supported Data Types”. Oh well.

As for the sensors: yes, it could be a hassle to maintain, on the other hand it makes life easier when configuring a node :slight_smile:

If I understand correctly from my research, you can just use node-red, mosquitto, and a simple web interface to do what cayenne mostly does but locally.

Sure. But I think you’ll have to look long-and-hard for a web-interface that works as well as what Cayenne provides. Also, if you got something running at home, you’re gonna have to grant access to it from the entire Internet thereby exposing yourself. With Cayenne that’s not your problem, it’s Cayennes. (This is simplified, I know.)