Shinyshoes, on 12 Nov 2018 - 19:16, said:
Shinyshoes, on 12 Nov 2018 - 19:16, said:
Shinyshoes, on 12 Nov 2018 - 19:16, said:
123, Did you post your SysEventBroker module anywhere? I wouldn't mind taking a stab at it. OpenHAB has some drivers I'd like to take advantage of.....
So far only @etc6849 has been actively using SyseventBroker. Over the summer we worked together, offline, to refine SyseventBroker. I didn't get much feedback in this forum so I skipped posting updates about the latest greatest version of SyseventBroker.
But since you asked, I've attached the latest version of SyseventBroker and its important companion, namely the Premise-MQTT flow for Node-Red. Both are needed to make Premise fluent in MQTT.
FWIW, I have an RPi running OpenHAB with a Mosquitto MQTT Broker. To install the broker, I used openhabian-config and select the option to install the MQTT broker.
If you have a dimmer like this: Home.MasterBedroom.Bathroom.Sconces
Being a dimmer, it will have two MQTT state topics:
It will also have two MQTT command topics:
Basically, you control the light using its command topic and receive its status via the state topic. SyseventBroker has an Export function that can export most of your Premise home objects into an openHAB Items file. This save you the hassle of manually transcribing all of your Premise objects into openHAB format.
Here's some documentation to help gain a better understanding of what SyseventBroker does, what's needed to make the magic happen, and how to install everything.
SyseventBroker is a Module that provides Premise with the ability to communicate via MQTT.
SyseventBroker sends Premise's sysevents (state-changes) to an MQTT Broker (state topic) and receives MQTT messages as sysevents (command topic). It uses Node-Red as a middle-man to handle actual MQTT communications. The system works like this:
1. SyseventBroker listens for sysevents occurring on supported devices (currently all standard Home devices, except MediaZone and Keypads).
2. The sysevent is converted into a JSON string.
3. The JSON string is sent, via TCP, to Node-Red.
4. A Node-Red flow converts JSON into MQTT format and publishes it to an MQTT Broker (state topic).
Information can travel in the opposite direction as well.
1. The Node-Red flow is subscribed to all Premise-related MQTT topics (i.e. it listens for MQTT messages intended for Premise).
2. It converts a received MQTT message (command topic), from the MQTT Broker, into a simpler format and sends it, via TCP, to SyseventBroker.
3. SyseventBroker validates the received information and uses it to control Home devices (dim a light, adjust thermostat setpoint, arm security system, etc).
SyseventBroker transforms a device&amp;rsquo;s path and property into an MQTT topic. Here are examples of how Premise properties appear as MQTT topics. Notice all characters are lower-case and there's no leading slash.
CONVERT AND VALIDATE
SyseventBroker can convert all outbound messages according to one's preferred Units of Measurement. For example, Premise can convert all outbound temperature values into Celsius (for use in MQTT) and convert inbound values back to Fahrenheit. It also validates all incoming values. If it receives an invalid value, it rejects it, and then sends the current, correct value back to MQTT. For example, to turn a light on/off, the valid values are 1 and 0, respectively. If SyseventBroker receives any other value, it ignores it and sends the light's current value.
SyseventBroker offers a Heartbeat function to monitor its connection with Node-Red. It sends a heartbeat message to Node-Red which replies with an acknowledgement. If there is no reply by the third heartbeat, SyseventBroker enables its Communication Failure property and logs a Premise Event.
SyseventBroker supports Status Requests for a single device or all devices. Here are the MQTT topics for the two types of status request (single and all):
Upon initial configuration, it is recommended to send the status of all devices to the MQTT Broker. The message&amp;rsquo;s payload (value) is configured to be retained by the Broker. Now the Broker knows the status of every Premise device. When an MQTT client connects to the Broker and subscribes to Premise-related topics, it will immediately receive the status of all Premise devices.
Installation involves importing the Premise-MQTT flow into Node-Red and configuring it to connect to your MQTT Broker. In Premise, a Lantronix UDS10 is created to provide TCP communication with Node-Red. Lastly, the SyseventBroker Module is imported into Premise and configured.
1. MQTT Broker
MQTT communications require an MQTT Broker. Eclipse's Mosquitto is a free, open-source version available for Linux, Windows, and OSX (www.mosquitto.org).
It is described as the "Visual wiring tool for the Internet of Things" and serves as the middle-man between Premise and MQTT. Node-Red is available for Linux, Windows, and OSX (www.nodered.org).
HOW TO IMPORT THE PREMISE-MQTT FLOW INTO NODE-RED.
1. Open the Premise-MQTT file in a text editor. Select and copy all content.
2. Switch to the Node-Red editor.
3. If needed, click the "+" tab to create a new flow (empty canvas; no nodes).
4. Click (Hamburger) Menu > Import > Clipboard.
5. Paste into popup window and click Import.
6. Click on the canvas to anchor the flow.
HOW TO CONFIGURE THE FLOW'S MQTT CONNECTION.
1. Double-click the MQTT node (upper right in flow).
2. Click pencil icon.
3. On Connection tab:
a. Enter Name to identify the node (such as the host name of your MQTT Broker).
b. Enter Server. This is the MQTT Broker's host name or IP address.
c. Enter Client ID. Choose a unique name to identify the MQTT session.
4. On Security tab:
a. Enter Username (if your MQTT Broker requires authentication otherwise leave fields blank).
b. Enter Password.
5. Click Update, then click Done.
6. Click Deploy to commit all the changes.
The MQTT node should indicate "connected". If not, double-check all information you entered.
If the MQTT node connected, the flow is now operational and awaiting a TCP connection on port 5100 (default). Most of the flow's Debug nodes are disabled. They can be enabled to examine how messages are processed.
HOW TO CONFIGURE WINDOWS.
Use Windows Firewall to confirm Premise Server has access to Private Network. SyseventBroker will use TCP port 5100.
HOW TO CONFIGURE PREMISE
1. Ensure the Lantronix driver is installed.
2. Create a New > UDS10.
3. Set its Name to SyseventBroker (for convenience; it can be any name you wish).
4. Set IPAddress to the address of the machine hosting the MQTT Broker.
5. Set IPPort to 5100.
6. Import SyseventBroker.xdo.
7. Create Devices > CustomDevices > New > SyseventBroker.
HOW TO CONFIGURE SYSEVENTBROKER
- Double-click Port, select Devices > Lantronix > SyseventBroker.
- Confirm PortStatus indicates "Port(Opened)".
- Scroll to UnitsOfMeasurement and indicate your preferred units for communicating with MQTT.
- Click SendStatus to transmit the current status of all devices to MQTT.
- Optionally enable Heartbeat.
- The default Heartbeat interval is 30 seconds. If you wish to change it, navigate to Modules > SyseventBroker > Broker > Timers > HeartbeatTimer.
The Module contains two Script Macros:
Generates a list (in Debugview) of all Home devices containing a DeviceStatus method. These are devices that are (ostensibly) supported by SyseventBroker. All Lighting, Appliance, HVAC, Security, Safety, and Scene objects are supported.
Generates a list (in Debugview) of all Home devices that do not contain a DeviceStatus method. These are devices that are (ostensibly) not supported by SyseventBroker. MediaZone and Keypad objects are (currently) not supported nor are any custom devices.
There's one more thing you'll need for openHAB and that's Transforms. Premise sends 1 and 0 for True and False but openHAB wants to see ON and OFF (for a Swtich). So in openHAB's Paper UI, go to Add-Ons > Transformations and install MAP-Transformation (it makes the service available to openHAB). Then you create a file in the transforms folder containing the conversion from 1 to On and 0 to OFF. You'll need another transformation file to convert in the other direction from OFF to 0 and ON to 1. To spare you this hassle, I've attached all the transformation files I've created.
Edited by 123, 14 November 2018 - 01:04 PM.