OmniLinkBridge to integrate Home Assistant, SmartThings, Node-RED

rsw686 said:
For full functionality you will need to add a custom_components folder to your config directory and override the following. Links to the pull requests are below, so you can track the status of these being included into the next version of Home Assistant.
alarm_control_panel/mqtt.py Adds night mode
climate/mqtt.py Adds temperature low and high setpoints
 
The climate/mqtt.py custom component is working for me, but HA doesn't seem to be picking up the alarm_control_panel/mqtt.py entry.
 
nFR5PFP.png

 
Code:
"""
This platform enables the possibility to control a MQTT alarm.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/alarm_control_panel.mqtt/
"""
import logging
import re

import voluptuous as vol

from homeassistant.core import callback
import homeassistant.components.alarm_control_panel as alarm
from homeassistant.components import mqtt
from homeassistant.const import (
    STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_NIGHT,
    STATE_ALARM_DISARMED, STATE_ALARM_PENDING, STATE_ALARM_TRIGGERED,
    STATE_UNKNOWN, CONF_NAME, CONF_CODE)
from homeassistant.components.mqtt import (
    ATTR_DISCOVERY_HASH, CONF_AVAILABILITY_TOPIC, CONF_STATE_TOPIC,
    CONF_COMMAND_TOPIC, CONF_PAYLOAD_AVAILABLE, CONF_PAYLOAD_NOT_AVAILABLE,
    CONF_QOS, CONF_RETAIN, MqttAvailability, MqttDiscoveryUpdate)
from homeassistant.components.mqtt.discovery import MQTT_DISCOVERY_NEW
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.typing import HomeAssistantType, ConfigType

_LOGGER = logging.getLogger(__name__)

CONF_PAYLOAD_DISARM = 'payload_disarm'
CONF_PAYLOAD_ARM_HOME = 'payload_arm_home'
CONF_PAYLOAD_ARM_AWAY = 'payload_arm_away'
CONF_PAYLOAD_ARM_NIGHT = 'payload_arm_night'

DEFAULT_ARM_NIGHT = 'ARM_NIGHT'
DEFAULT_ARM_AWAY = 'ARM_AWAY'
DEFAULT_ARM_HOME = 'ARM_HOME'
DEFAULT_DISARM = 'DISARM'
DEFAULT_NAME = 'MQTT Alarm'
DEPENDENCIES = ['mqtt']

PLATFORM_SCHEMA = mqtt.MQTT_BASE_PLATFORM_SCHEMA.extend({
    vol.Required(CONF_COMMAND_TOPIC): mqtt.valid_publish_topic,
    vol.Required(CONF_STATE_TOPIC): mqtt.valid_subscribe_topic,
    vol.Optional(CONF_CODE): cv.string,
    vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
    vol.Optional(CONF_PAYLOAD_ARM_AWAY, default=DEFAULT_ARM_AWAY): cv.string,
    vol.Optional(CONF_PAYLOAD_ARM_HOME, default=DEFAULT_ARM_HOME): cv.string,
    vol.Optional(CONF_PAYLOAD_ARM_NIGHT, default=DEFAULT_ARM_NIGHT): cv.string,
    vol.Optional(CONF_PAYLOAD_DISARM, default=DEFAULT_DISARM): cv.string,
}).extend(mqtt.MQTT_AVAILABILITY_SCHEMA.schema)


async def async_setup_platform(hass: HomeAssistantType, config: ConfigType,
                               async_add_entities, discovery_info=None):
    """Set up MQTT alarm control panel through configuration.yaml."""
    await _async_setup_entity(hass, config, async_add_entities)


async def async_setup_entry(hass, config_entry, async_add_entities):
    """Set up MQTT alarm control panel dynamically through MQTT discovery."""
    async def async_discover(discovery_payload):
        """Discover and add an MQTT alarm control panel."""
        config = PLATFORM_SCHEMA(discovery_payload)
        await _async_setup_entity(hass, config, async_add_entities,
                                  discovery_payload[ATTR_DISCOVERY_HASH])

    async_dispatcher_connect(
        hass, MQTT_DISCOVERY_NEW.format(alarm.DOMAIN, 'mqtt'),
        async_discover)


async def _async_setup_entity(hass, config, async_add_entities,
                              discovery_hash=None):
    """Set up the MQTT Alarm Control Panel platform."""
    async_add_entities([MqttAlarm(
        config.get(CONF_NAME),
        config.get(CONF_STATE_TOPIC),
        config.get(CONF_COMMAND_TOPIC),
        config.get(CONF_QOS),
        config.get(CONF_RETAIN),
        config.get(CONF_PAYLOAD_DISARM),
        config.get(CONF_PAYLOAD_ARM_HOME),
        config.get(CONF_PAYLOAD_ARM_AWAY),
        config.get(CONF_PAYLOAD_ARM_NIGHT),
        config.get(CONF_CODE),
        config.get(CONF_AVAILABILITY_TOPIC),
        config.get(CONF_PAYLOAD_AVAILABLE),
        config.get(CONF_PAYLOAD_NOT_AVAILABLE),
        discovery_hash,)])


class MqttAlarm(MqttAvailability, MqttDiscoveryUpdate,
                alarm.AlarmControlPanel):
    """Representation of a MQTT alarm status."""

    def __init__(self, name, state_topic, command_topic, qos, retain,
                 payload_disarm, payload_arm_home, payload_arm_away,
                 payload_arm_night, code, availability_topic,
                 payload_available, payload_not_available, discovery_hash):
        """Init the MQTT Alarm Control Panel."""
        MqttAvailability.__init__(self, availability_topic, qos,
                                  payload_available, payload_not_available)
        MqttDiscoveryUpdate.__init__(self, discovery_hash)
        self._state = STATE_UNKNOWN
        self._name = name
        self._state_topic = state_topic
        self._command_topic = command_topic
        self._qos = qos
        self._retain = retain
        self._payload_disarm = payload_disarm
        self._payload_arm_home = payload_arm_home
        self._payload_arm_away = payload_arm_away
        self._payload_arm_night = payload_arm_night
        self._code = code
        self._discovery_hash = discovery_hash

    async def async_added_to_hass(self):
        """Subscribe mqtt events."""
        await MqttAvailability.async_added_to_hass(self)
        await MqttDiscoveryUpdate.async_added_to_hass(self)

        @callback
        def message_received(topic, payload, qos):
            """Run when new MQTT message has been received."""
            if payload not in (STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME,
                               STATE_ALARM_ARMED_AWAY,
                               STATE_ALARM_ARMED_NIGHT,
                               STATE_ALARM_PENDING, STATE_ALARM_TRIGGERED):
                _LOGGER.warning("Received unexpected payload: %s", payload)
                return
            self._state = payload
            self.async_schedule_update_ha_state()

        await mqtt.async_subscribe(
            self.hass, self._state_topic, message_received, self._qos)

    @property
    def should_poll(self):
        """No polling needed."""
        return False

    @property
    def name(self):
        """Return the name of the device."""
        return self._name

    @property
    def state(self):
        """Return the state of the device."""
        return self._state

    @property
    def code_format(self):
        """Return one or more digits/characters."""
        if self._code is None:
            return None
        if isinstance(self._code, str) and re.search('^\\d+$', self._code):
            return 'Number'
        return 'Any'

    async def async_alarm_disarm(self, code=None):
        """Send disarm command.
        This method is a coroutine.
        """
        if not self._validate_code(code, 'disarming'):
            return
        mqtt.async_publish(
            self.hass, self._command_topic, self._payload_disarm, self._qos,
            self._retain)

    async def async_alarm_arm_home(self, code=None):
        """Send arm home command.
        This method is a coroutine.
        """
        if not self._validate_code(code, 'arming home'):
            return
        mqtt.async_publish(
            self.hass, self._command_topic, self._payload_arm_home, self._qos,
            self._retain)

    async def async_alarm_arm_away(self, code=None):
        """Send arm away command.
        This method is a coroutine.
        """
        if not self._validate_code(code, 'arming away'):
            return
        mqtt.async_publish(
            self.hass, self._command_topic, self._payload_arm_away, self._qos,
            self._retain)

    async def async_alarm_arm_night(self, code=None):
        """Send arm night command.
        This method is a coroutine.
        """
        if not self._validate_code(code, 'arming night'):
            return
        mqtt.async_publish(
            self.hass, self._command_topic, self._payload_arm_night, self._qos,
            self._retain)

    def _validate_code(self, code, state):
        """Validate given code."""
        check = self._code is None or code == self._code
        if not check:
            _LOGGER.warning('Wrong code entered for %s', state)
        return check
 
So what is the minimum system requirement to use OmniLinkBridge (other than some flavor of linux)? 
 
Windows XP, Windows XPe, Windows 2003 Server, Windows 7, Windows 7e, Windows 8 and 8e, Windows 10 and recently tested it here on Windows 2016.
 
It is just an executible that you can run from a directory in Windows. 
 
HAI/Leviton OmniPro II?  Can OmniPro II be able to support legacy X10 devices controlled by my [currently unusable] Omni LT system?
 
It should run fine on an OmniLT system.  I am using it on an OmniPro 2 system and utilize it with X10, UPB, ZWave and Zigbee.
 
The old HAI Logger program connected fine to the Omni Pro panel and the Samsung Smartthings.  The new OmniLinkBridge program talks Mosquitto and you can utilize Software that talks Mosquitto for managing the OmniPro panel you have.
 
The most lite and cost reasonable hardware device you could utilize would be a Raspberry Pi running the application on it plus Mosquitto Broker and Node Red.
 
Note that Node Red is optional.
 
The author of the application is currently testing the application in CentOS Docker host. 
 
CentOS is just Linux.
 
What is CentOS Linux?

CentOS Linux is a community-supported distribution derived from sources freely provided to the public by Red Hat for Red Hat Enterprise Linux (RHEL). As such, CentOS Linux aims to be functionally compatible with RHEL. The CentOS Project mainly changes packages to remove upstream vendor branding and artwork. CentOS Linux is no-cost and free to redistribute. Each CentOS version is maintained for up to 10 years (by means of security updates -- the duration of the support interval by Red Hat has varied over time with respect to Sources released). A new CentOS version is released approximately every 2 years and each CentOS version is periodically updated (roughly every 6 months) to support newer hardware. This results in a secure, low-maintenance, reliable, predictable and reproducible Linux environment.
 
What is Docker?
 
Docker is a computer program that performs operating-system-level virtualization, also known as "containerization". It was first released in 2013 and is developed by Docker, Inc.

Docker is used to run software packages called "containers". Containers are isolated from each other and bundle their own tools, libraries and configuration files; they can communicate with each other through well-defined channels. All containers are run by a single operating system kernel and are thus more lightweight than virtual machines. Containers are created from "images" that specify their precise contents. Images are often created by combining and modifying standard images downloaded from public repositories.
 
The author has written a custom Python application that talks specfically to the OmniPro panel. 
 
All said above ....Read about Mosquitto, Node Red. 
 
There are open source public Home automation programs today (free) that talk Mosquitto like Home Assistant and OpenHAB.
 
and if you want to working only in Windows you can utilize HomeSeer which runs in Windows or Linux and has a specific OmniPro plugin for use with your OmniPro panel and a Mosquitto plugin which you can utilize.  I have tested and using both today.
 
Relating to my use of the new program here running it on Ubuntu 18.10 (as of yesterday) on an old Shuttle Nettop computer. (bare metal computer).
 
Earlier here I had installed it twice and had two configuration directories which caused me grief.  I installed the whole kitchen sink of Home Assistant which was too much and not really needed.  I was in a rush to install it.  It works fine.
 
BTW a quickie Mosquitto (MQTT) Synopsis from the Wiki...
 
 
MQTT (Message Queuing Telemetry Transport) is an ISO standard (ISO/IEC PRF 20922) publish-subscribe-based messaging protocol. It works on top of the TCP/IP protocol. It is designed for connections with remote locations where a "small code footprint" is required or the network bandwidth is limited. The publish-subscribe messaging pattern requires a message broker.

Andy Stanford-Clark of IBM and Arlen Nipper of Cirrus Link authored the first version of the protocol in 1999.

In 2013, IBM submitted MQTT v3.1 to the OASIS specification body with a charter that ensured only minor changes to the specification could be accepted. MQTT-SN is a variation of the main protocol aimed at embedded devices on non-TCP/IP networks, such as Zigbee.

Historically, the "MQ" in "MQTT" came from IBM's MQ Series message queuing product line. However, queuing itself is not required to be supported as a standard feature in all situations.

A quickie synopsis of Node Red

Node-RED is a flow-based development tool for visual programming developed originally by IBM for wiring together hardware devices, APIs and online services as part of the Internet of Things.

Node-RED provides a browser-based flow editor, which can be used to create JavaScript functions. Elements of applications can be saved or shared for re-use. The runtime is built on Node.js. The flows created in Node-RED are stored using JSON. Since version 0.14 MQTT nodes can make properly configured TLS connections.

In 2016, IBM contributed Node-RED as an open source JS Foundation project.
 
Thank you Ryan for the installation directions for using docker.
 
Here installed on Ubuntu 18.10 64 bit...
 
1 - Docker-CE
2 - Home Assistant
3 - Node Red
 
Node Red / Mosquitto Broker is running on an RPi
 
OmniLink Bridge is running on another Ubuntu 18.04 server.

Home Assistant and Homeseer Pro are picking up all of the devices running Mosquitto now. I have added 4 Tasmota / ESP Easy firmware Mosquitto devices and they are working well these days.

A bit overkill on the GDO stuff as I have wired it to the OP2 and concurrently have a Sonoff WiFi basic connected to separate reed sensors, button and added a temperature sensor.
 
Where I am going with this is to install Home Assitant / Homeseer Pro on a Rock64 / 4 Gb computer using an eMMC hard drive which will also be a firewall with an optional out of band management for the OmniPro 2 panel inside of the OmniPro can.  The Rock64 4Gb computer is the same size as an RPi. 
 
@Ryan,
 
Might be easier to keep tabs on your application if we created a sub topic under Marketplace....not sure what it can be called?
 
Maybe something like:
 
OmniLinkBridge for Leviton Omni Panels or OmniLinkBridge maybe?

You will need to ask moderator to create sub topic under vendors I think.
 
pete_c said:
HAI/Leviton OmniPro II?  Can OmniPro II be able to support legacy X10 devices controlled by my [currently unusable] Omni LT system?
 
It should run fine on an OmniLT system.  I am using it on an OmniPro 2 system and utilize it with X10, UPB, ZWave and Zigbee.
 
To the best of my knowledge OmniLT only supports serial (RS-232) link which requires support for COM port on Windows world or appropriate dev drivers on Linux.  Is there any support for serial port in OmniLinkBridge?
 
Can I use OmniLinkBridge to completely bypass the PC Access and use it to monitor security devices, Omnistat and a bunch of X10 devices currently connected to an OmniLT controller?
 
pete_c said:
The most lite and cost reasonable hardware device you could utilize would be a Raspberry Pi running the application on it plus Mosquitto Broker and Node Red.
 
I can get a Raspberry Pi board if it gives me freedom from OmniLT and PC Access.  Could you please give me some pointers for Raspberry Pi boards that I can use?  
 
 
pete_c said:
There are open source public Home automation programs today (free) that talk Mosquitto like Home Assistant and OpenHAB.
 
and if you want to working only in Windows you can utilize HomeSeer which runs in Windows or Linux and has a specific OmniPro plugin for use with your OmniPro panel and a Mosquitto plugin which you can utilize.  I have tested and using both today.
 
Thanks for the pointers for the open-source software.  No, I am not married to windows.  I spend most of my day working on either Linux or AIX machines...
 
Is there any support for serial port in OmniLinkBridge?
 
yes and no. 
 
The OmniLinkBridge connects to the firmware of the Omni panel.  The firmware talks serially to the serial ports via the use of Units.  X10 was the first protocal and only protocal used when the OmniPro was first sold and implemented.
 
Ryan wrote an interface called OmniLinkBridge which talks to the firmware of the Omni panel.
 
Way back Ryan wrote an interface called HAI Logger which also spoke to the Omni panel.  Initially it was just a logging interface that wrote to a MySQL database.
 
Later on Ryan made the HAI Logger program work with the Samsung Smartthings hub.
 
Just recently Ryan has changed the original interface (software) to speak Mosquitto.  (an add plus all original features).
 
The original HAILogger with Samsung Hub spoke in Windows and Linux Mono.
 
Can I use OmniLinkBridge to completely bypass the PC Access
 
No.  You cannot program the panel or configure it with the OmniLinkBridge software.  You will need PC Access for management of the panel.
 
 
 
use it to monitor security devices, Omnistat and a bunch of X10 devices currently connected to an OmniLT controller?
 
Yes and everything else connected to the Omni Panel. 
 
 
Here utilize Windows server 2016 standard via RDP to run PCA and I go to it via all of my linux / windows laptops / desktops.
 
Serially you can connect to:
 
serial.jpg
 
Via IP you can connect to:
 
extendedsetup.jpg
 
 
 
 
can get a Raspberry Pi board if it gives me freedom from OmniLT and PC Access.  Could you please give me some pointers for Raspberry Pi boards that I can use?
 
I still utilize Windows to run PC Access via RDP to a Windows 2016 64 bit server configuration.
 
I have historically used a Raspberry Pi for a bunch of stuff and it is still being used here.
 
IE:
 
One RPi2 is running a ZWave board (for ZWave), Node Red OWFS, Mosquitto Broker 1-wire network and using an SD Radio to download NOAA weather maps from satellite.
 
I have though moved to using the Pine64 2 Gb computer for Homeseer Lite here and waiting on an RTC with battery for use on the Rock64 4 Gb computer which is the same size as the RPi and a bit faster today with 4Gb RAM.
 

 
The Pine 64 2 Gb computer is about twice the size of an RPI but the same price as an RPi. 
 
pine64.jpgRock64.jpg
 
Thanks again pete_c.
 
pete_c said:
Is there any support for serial port in OmniLinkBridge?
 
yes and no. 
 
The OmniLinkBridge connects to the firmware of the Omni panel.  The firmware talks serially to the serial ports via the use of Units.  X10 was the first protocal and only protocal used when the OmniPro was first sold and implemented.
 
Is Omni panel and OmniLT controller the same thing?  If not, what is the purpose of Omni panel? (It is a pity that I have to ask this question in spite of owning an Omni LT system and a legal copy of PC Access software which of course cannot access the Omni LT system!! :( ).
 
Is there any documentation of the serial protocols used by Omni panel?
 
pete_c said:
Ryan wrote an interface called OmniLinkBridge which talks to the firmware of the Omni panel.
 
Thanks; I will be in touch with Ryan.
 
pete_c said:
Can I use OmniLinkBridge to completely bypass the PC Access
 
No.  You cannot program the panel or configure it with the OmniLinkBridge software.  You will need PC Access for management of the panel.
 
What makes the PC Access so unavoidable?  If OminLinkBridge can indeed talk to the firmware on Omni panel, why not provide the complete functionality of PC Access??
 
TristateUser said:
What makes the PC Access so unavoidable?  If OminLinkBridge can indeed talk to the firmware on Omni panel, why not provide the complete functionality of PC Access??
 
The OmniLinkBridge supports TCP/IP connection and not serial connection. Also you need PC Access to program the panel. The OmniLinkBridge is only querying status and changing runtime values. For example you can query a Unit (light) status and change it's state from on to off. You can't program a new Unit (light), set the name, type, etc.
 
TristateUser said:
Is there any documentation of the serial protocols used by Omni panel?
 
The OmniLink serial protocol specs can be downloaded from the link below. However I'm using the OmniLink II protocol over TCP/IP. The C# SDK I have from HAI, when I signed up to be a developer, technically supports the serial protocol as well. However it requires if serial then this else do this. I personally don't have the time to build this out. For connectivity reasons I would suggest buying an OmniLTe board for around $500.
 
http://kb.homeauto.com/redirfile.asp?id=342
 
Ryan, Thank you for the OmniLink serial protocol specs.
 
I didn't know that I could control the Russound system via OmniLT as well. I was using the Russound system directly via the wall-panels in the rooms.  I am assuming that the OmniLT and Russound systems in the house are connected because looking at the old invoices handed over to me by the previous owner both systems were installed by the same HAI dealer.
 
rsw686 said:
However I'm using the OmniLink II protocol over TCP/IP. The C# SDK I have from HAI, when I signed up to be a developer, technically supports the serial protocol as well. However it requires if serial then this else do this. I personally don't have the time to build this out. For connectivity reasons I would suggest buying an OmniLTe board for around $500.
 
I looks like I might be able to play with the system to a certain extend via the serial link using the protocol specs, but I would take your advice and upgrade from OmniLT to LTe.  I'm more concerned about physically swapping the LT controller with LTe board with all those wires than the cost of the board.  If you are aware of any DIY advice for installing OmniLTe board, please let me know.
 
I didn't get a chance to checkout your code on GitHub yet.  Have you provided the full C# SDK from HAI in there as well so that I can modify it to support serial link, perhaps as a branch? If I check out the source, will I be able to build the Windows (or Linux) binary myself? (I'm asking because Pete_c was referring to some x86 windows binaries).
 
One more question: Do you think it will help in anyway if I purchase a dealer version of PC Access to address the "connectivity issue" (I'm pretty sure it is not the serial communication parameters or COM port issue as I see ON-LINE at the bottom of PC Access screen)? 
 
Thanks again.
 
TristateUser said:
TristateUser, on 22 Oct 2018 - 18:28, said:
I didn't know that I could control the Russound system via OmniLT as well.
According to the documentation you need an OmniPro II, not the OmniLT to enable the Russound integration. I also just opened PC Access, started a new file for an OmniLTe system, and the Russound option is missing from the Serial dropdown.
TristateUser said:
TristateUser, on 22 Oct 2018 - 18:28, said:
One more question: Do you think it will help in anyway if I purchase a dealer version of PC Access to address the "connectivity issue" (I'm pretty sure it is not the serial communication parameters or COM port issue as I see ON-LINE at the bottom of PC Access screen)?
The non dealer version of PC Access won't let you edit the system configuration. I haven't used it personally but I'm assuming the Setup and Automation tabs will be hidden and only the Event Log and Status tabs visible.
 
Just a question relating to the MQTT Alarm Control Panel add for night mode.  
 
Followed procedure to install:  
 
1 - mkdir -p /opt/home-assistant/config/custom_components/alarm_control_panel
 
2 - cd /opt/home-assistant/config/custom_components/alarm_control_panel
 
3 - wget hxxps://raw.githubusercontent.com/home-assistant/home-assistant/49970331824cb233a8ff8874a3166c2ef66cbe00/homeassistant/components/alarm_control_panel/mqtt.py
 
4 - docker restart home-assistant  
 
See it loading in Home Assistant log:  
 
2018-10-23 07:53:04 WARNING (MainThread) [homeassistant.loader] You are using a custom component for alarm_control_panel.mqtt which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.  
 
Am I supposed to see armed_night over here ==>
 
armed night.jpg
 
Back
Top