Premise MQTT for Premise.

Motorola Premise
Funny,  I actually got more answers on the OH forum than the HA forum for a couple of general questions.  But I am having a really hard time trying to figure out the best way to get my multizone audio setup working in HA.  So I really just wanted to see if I could wrap my head around OH an better than HA.  Although in general, I am getting HA working fairly well with lighting and using scripts for scenes.  And Yaml doesn't seem to bother me outside of it's sensitivity to spacing.  One extra space and it doesn't work :(
HA has a Russound RIO integration that looks good.  It automatically discovers enabled zones and sources.  So I may consider selling my old one and buying a used Russound.  In fact, I just found a used MCA-C5 8X8 nearby for $150.  Might be worth it.
samgreco said:
123, can you point me in a direction to get my Premise stuff into OpenHab?  
Go to Devices > CustomDevices > Syseventbroker, scroll to the very bottom of the Properties pane, and there you'll find a section called ExportOpenHAB. Click Reset first and then check the contents of the section above called ExportParameters. This is where it identifies the host name of your Premise Server, the export path (on the host machine), and the output file name. Make sure these three properties are correct before clicking Export. The resulting .items file can then be used with openHAB and will contain all of your (non-hidden) Premise Home objects (converted into openHAB Items).
With regards to the Home Assistant community forum, it's been my experience that if you bring up the subject of older home automation technologies, there are fewer responses (if any). My impression is that most members are working with gear that's no older than 5 years. If it doesn't have the word 'smart' in front of it, they don't know about it (I'm being facetious of course … but it's not very far from the truth). It's odd to hear them championing devices that support "local control" (i.e. non-cloud-based). Anyone tinkering with home automation for over 5 years knows that "local control" was the de facto standard for many years. So-called 'smart' devices leveraged the cloud and made it appear cloud-access was integral to being 'smart'. Anyway, that's my long-winded way of saying they're not going to be very familiar with older tech (as you've seen, even UPB).
I know what you mean by 'royalty' and have experienced it. I ultimately asked the individual to refrain from responding to any of my questions; he was no longer being helpful, just argumentative. There are also members who can be summarized as being insecure; they are quick to play the 'hurt feelings' card. I recall commenting that there was a certain practice that 'made me feel stupid'. A user replied that they followed that practice and objected to being called stupid. No one called *you* stupid; you went out of your way to fall under the 'hurt feelings' bus. That's not an isolated incident; I've seen others willingly express 'hurt feelings' about comments that weren't directed at them. Very odd behavior. FWIW, I've never experienced the 'royalty' treatment or the 'hurt feelings' angle here on Cocoontech or in the Home Assistant forum. 
I think I'm going to either 1) Buy a PI to use HA- okay, not adverse to it. I think the containers and VMs and all of the other stuff is too IT-ish for me. Maybe straight Linux would work without so much hassle 123, does it have enough power? 2) Live with the royalty of OpenHab 3) Dive into RTI. 4) Learn how to build drivers using Visual Studio or last but not least, get my lazy butt of the chair and see who's at the door  :eek:
Finally, success!! Once I got the ports and the naming correct, boom!
Very nice job, 123!! (I'm grinning ear to ear watching state changes!!)
I thought I read you had done a basic UI? I'm assuming to see if it worked/s?
I'm trying to figure out how to get rid of the polling in my homebrew UI, Although I'm migrating to something, I'd like to finish it for my own piece of mind...
If you had a couple of examples on how I would pub and sub it would sure help me out...
chucklyons said:
I thought I read you had done a basic UI? I'm assuming to see if it worked/s?
I'm using Home Assistant to generate a UI.
For example, I have the following light in Premise:
In Home Assistant, I define an MQTT Light:
  - platform: mqtt
    name: "Foyer"    
    state_topic: "premise/home/house/first/foyer/foyerlight/powerstate"
    command_topic: "premise/command/home/house/first/foyer/foyerlight/powerstate"
    payload_on: "1"
    payload_off: "0"
    brightness_scale: 100
    brightness_state_topic: "premise/home/house/first/foyer/foyerlight/brightness"
    brightness_command_topic: "premise/command/home/house/first/foyer/foyerlight/brightness"
    on_command_type: 'brightness'

This creates an entity called light.foyer and Home Assistant will automatically display it in its UI (just like Premise's Automation Browser and MiniBrowser). The card's appearance is simply a toggle button but if you click the card a 'More-Info' popup appears allowing you to control the brightness as well (it also shows a timeline of recent on/off events). That's the default card for displaying a light but there are other ones available.
This 'automatic display' is not in any organized fashion so the next step most people take is to specify how to render the entities. There are two ways:
1. Easy way is to do it directly in the UI.
2. More flexible way is to create ui-lovelace.yaml file containing instructions for what, where, how, and when to show a given entity. This is the option I've chosen.
Here's an excerpt from my ui-lovelace file. It defines a View (a tab) called Lights with a card containing all Downstairs (first floor) lights.
- title: Lights
    icon: mdi:lightbulb-on
      - type: entities
        title: Downstairs
        show_header_toggle: true
          - light.foyer

Thanks, 123.
Well, this is now my 4th attempt to post an example of the scripts I am using. I'll have to email the code, as this won't post my crapware, apparently.
In Premise MB, I poll. I use javascript (SetInterval) to poll a function that gets updated based on the state of the object. The function(via javascript) also changes the icon to graphically reflect the state of the object.
How, in Premise MB (not HA), would I subscribe to a topic?
(BTW, this EventBroker code is so well done!)
chucklyons said:
How, in Premise MB (not HA), would I subscribe to a topic?
Sorry but I don't know. 
You want to write code for MiniBroker that subscribes to an MQTT topic. Effectively, you want to use an MQTT Client service but Premise doesn't have one.
Even SyseventBroker isn't an MQTT Client. It farms out that function to Node-Red. The two communicate via a TCP port using a simple protocol I devised. Creating a native MQTT Client service for Premise is beyond my C++ skills.
123, thanks for giving me another stretch assignment!!
Node-Red has a rudimentary approach for building a UI - currently I have realtime status in a browser page for most devices that you have included in syseventbroker. I've added some that I needed; I'm looking at other things like audio devices. However, Node-Red also has a more advanced UI Builder that integrates with the Node-Red admin UI. So far, so good. As it integrated with other frontends, or not, but also works with jQuery, VUE.js, REACT, a lot of the code I have created for the MiniBrowser SHOULD work.  As you can include other frameworks, some of the time consuming efforts like dials and knobs will be a lot easier.
Node-R also supports things like weather, Amazon Echos, Google, ZWave, Zigbee, etc. Although I have just started, the pace at which I have been able to get realtime (no polling - okay, I was wrong! I love the instant status!!) updates on this rugged UI has been very exciting!
But now I see the errors of my way. SYSEventBroker ONLY SENDS status. It doesn't receive any published I would need to create the corresponding code and flow. I don't suppose you could help a guy out who's down on his luck?
I found that I can brute force commands from the Node-Red UI to objects in Premise. SysEventBroker then publishes the changed state, which then gets reflected in the Node-Red UI.
Of course, the current approach requires the object ID, so its a bit tedious as they have to be keywhacked in. But it works...
chucklyons said:
...SYSEventBroker ONLY SENDS status. It doesn't receive any published messages...
It publishes (sends) and subscribes (receives).
If KitchenLight's PowerState changes from true to false, a payload of 0 is published to:
It is also subscribed to:
So if I publish a payload containing 1 to that topic, Syseventbroker will turn on KitchenLight.
hmm...I think I may have found a bug...SysEventBroker does what I tell it to do; not what I want it to do... :blush:
I have to say, I am loving Node-Red...and SysEventBroker! I put together status for lights, security and a weather feed in maybe a week+, using the NR Dashboard. I haven't started on UIBuilder yet.... As we travel between homes a lot, status is more critical than control. It scales very for phone or tablet. It's not bad on the TV.
Next is on to sending from Node-Red to Premise....

For what I need, Premise and NR should serve me well for a while...
I modified 123's SysEventBroker to include Audio Video devices (see downloads) to send status changes to MQTT and on to the HA Platform of your choice. Best of all?. It  still works!
It includes all of the native Premise AV objects. So if you're still using that CD_Changer, you're in luck! And there are a few custom classes, as well. ETC's Marantz, Tivo, and my Russound MCA Multisource, Multizone driver. (coming soon)
If anyone is even watching this forum, the obvious question is...why build anything in Premise?
So far, Premise seems to be the easiest way for me to develop drivers. And I use Premise for behind the scenes controlling of devices, scheduling, and interacting between devices. e.g. Zone 2 turns on, lights turn off, etc.
Usual caveat - backup, then install.
Funny, I just shut down my Windows/Premise server last weekend.  Everything has been moved to a Linux box running Home Assistant, Logitech Media Server and Channels DVR.  So not only did I shut down Premise, but also SageTV.
This is all because there is finally a reliable UPB driver for HA now.  Interestingly, there is also a new UPB driver for OpenHab.  But I just can't seem to get my brain around OpenHab.
All this to say, you may be the last....
LOL. I may very well be. Between Premise, Node-Red and Alexa, I have virtually everything covered...
Take care, Sam!