Page 1 of 1

Using MQTT-Node-Red to communicate with LumenCache

Posted: Wed Jan 13, 2021 12:26 pm
by klf
After investigating various home automation (HA) software platforms, I decided I wanted to provide a message based interface to the Lumencache serial interface for my project. This would allow me to take my time deciding on the HA platform and give me some flexibility in evaluating and switching platforms as needed as the technology evolves.

In the IOT space, MQTT appears to be an accepted messaging standard. I've defined MQTT topics for each of the Lumencache serial commands and additional topics for the serial responses. MQTT messages consist of topics and payloads. These messages can be published and subscribed to. For example:

Turn on light zone controlled by switchpuck id 45
set-level:
MQTT topic: LC/command/set-level/45 payload: 128 (range: 0-255)
MQTT reply topic: LC/reply/dim/45 payload: 50
MQTT reply topic: LC/reply/level/45 payload: ON

Note: UI Dimmer items subscribe to the LC/reply/dim/+ messsages, while the UI ON/OFF Switch items subscribe to LC/reply/level/+ messages. Unsolicited LumenCache replies are also captured from the hardware switches and are published as MQTT reply messages.

Configure the restore level of the light zone controlled by switchpuck id 45
set-restore-level:
topic: LC/command/set-restore-level/45 payload: 1 (range: 0-255)
MQTT reply topic: LC/config/45 payload: {45,5,1,2,35,220,1,0,1,0}

Note: For the LC/config/+ messages the payload is set to the actual LumenCache reply string.

I've implemented a gateway prototype using Node-Red and Eclipse Mosquitto. A Node-Red flow subscribes to MQTT messages sent by the HA client processes. The flow also publishes MQTT messages to be subscribed to by the HA clients. I'm currently using openHAB2 as the control system.

Image
Screenshot of openHAB BASIC UI Android app.

Here is the Node-Red flow diagram and flow JSON file.

Image
MQTT-LumenCache Serial Gateway

Node-Red Flow JSON file:
https://anaturalpathtowellness.com/wp-c ... teway.json

Node-Red Flow Description

There are two communication processes in the flow. The first, processes incoming requests from control system. The second, processes incoming serial port replies from LumenCache.

Process Incoming Requests from Control System

"LC/command/+/#: mqtt in node"
Connects to a MQTT broker and subscribes to LumenCache Command messages from the control system.

"transform command: function node"
A function block to transform the received MQTT topic and payload into LumenCache serial protocol format.
It returns a message object containing the LumenCache command.

"delay 200ms: delay node"
Delays each message passing through the node to control the delivery rate on the serial port.

"serial out node"
Provides a connection to an outbound serial port. Only the LumenCache serial command is sent.


Process Incoming Serial Port Replies from LumenCache

"serial in node"
Reads Lumencache reply data from a serial port.

"transform command: function node"
A function block to transform the received LumenCache reply payload into an MQTT reply or config topic
along with a payload containing the status based on the incoming payoad.
It returns a message(s) containing the MQTT replies.

"switch mqtt: mqtt out node"
Connects to a MQTT broker and publishes messages for use by the control system to update switch and dimmer status values.

Here is a document containing descriptions of the MQTT messages.

https://anaturalpathtowellness.com/wp-c ... ateway.txt

Re: Using MQTT-Node-Red to communicate with LumenCache

Posted: Mon Mar 01, 2021 2:55 pm
by klf
Attached are Node-Red Flow JSONs and an MQTT messages document updated to the
01020110.0 LumenCache LibRE Control Protocol (2021-01-15).pdf spec.
download/file.php?id=128&sid=fb4113533d ... 1ee4e6a3e8

https://anaturalpathtowellness.com/wp-c ... otype.json

https://anaturalpathtowellness.com/wp-c ... -01-15.txt

A basic Node Red dashboard has been implemented for LumenCache provisioning.

Image

Image

Image

Image

Image

Image

Image

Image

Re: Using MQTT-Node-Red to communicate with LumenCache

Posted: Tue Mar 16, 2021 3:48 am
by dc
Ken, this is awesome! Seems the UI just needs a little tweaking to get the button management settings and scenes manageable.

Note: we're selling a version of the EGW1 as a DIY model without any locked software. It may include the basic communication bus management and API so the heavy protocol activities are handled.

Guillermo did an amazing job tightening up the messaging sections and auto-discovery and ID assignment and management so that part is automated. Seems we can bring these pieces together soon.

Re: Using MQTT-Node-Red to communicate with LumenCache

Posted: Wed Mar 17, 2021 11:35 am
by dc
Seems popular combination. Just add LC.

https://youtu.be/hBEb_FCLRU8