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](https://anaturalpathtowellness.com/wp-content/uploads/2023/03/openhab2-basicui.jpeg)
Screenshot of openHAB BASIC UI Android app.
Here is the Node-Red flow diagram and flow JSON file.
![Image](https://anaturalpathtowellness.com/wp-content/uploads/2023/03/Node-Red-Flow.png)
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