Architecture

MQTT

Home Assistant does not have a builtin MQTT Broker, so I have a docker for it: Adding Mosquitto (MQTT) to my Home Automation

Java Application as Bridge

Github Source: https://github.com/jobu279/zensehome

Compile the source code or fetch the runtime. Edit config.properties to suit your network and mqtt.

Samples below are referenced from /home/bnp/production/zensehome/zensemqtt

You need to create a "/home/bnp/production/zensehome/zensemqtt/logs" directory; - then execute the application

root@robin:~/production/zensehome/zensemqtt# java -Dfile.encoding=UTF-8 -classpath /home/bnp/production/zensehome:/home/bnp/production/zensehome/zensemqtt/mqtt-client-0.4.0.jar zensemqtt.ZenseMQTT
Jan 09, 2019 8:14:01 PM zensemqtt.Log logging
INFO: Starting ZenseHome MQTT listener

Setup a light source

My configuration.yaml has these parts:

mqtt:
  broker: 10.0.0.150

light: !include light.yaml

My lights.yaml looks like this:

- platform: mqtt
    name: "Kitchen Light"
    state_topic: "zense/execute/18324"
    command_topic: "zense/execute/18324"
    payload_on: "ON"
    payload_off: "OFF"

  - platform: mqtt
    name: "Office Light"
    state_topic: "zense/execute/10604"
    command_topic: "zense/execute/10604"
    payload_on: "ON"
    payload_off: "OFF"

  - platform: mqtt
    name: "Bedroom Light"
    state_topic: "zense/execute/58739"
    command_topic: "zense/execute/58739"
    payload_on: "ON"
    payload_off: "OFF"

....
....

With the Topics according to https://github.com/jobu279/zensehome. The Id can be found in the Zensehome Windows Application:


After restarting Home Assistent, the lights will be entries:


Installing as a service

Follow: https://computingforgeeks.com/how-to-run-java-jar-application-with-systemd-on-linux/

Logging

Watch the Log in /home/bnp/production/zensehome/zensemqtt/logs

root@robin:~/production/zensehome/zensemqtt/logs# cat 2019-1_ZenseLog.log
Jan 09, 2019 7:44:53 PM zensemqtt.Log logging
INFO: Starting ZenseHome MQTT listener
Jan 09, 2019 7:46:35 PM zensemqtt.Log logging
INFO: New message with topic: zense/execute/10604, Message: ON
Jan 09, 2019 7:46:37 PM zensemqtt.Log logging
INFO: New message with topic: zense/execute/10604, Message: OFF
Jan 09, 2019 7:46:43 PM zensemqtt.Log logging
INFO: New message with topic: zense/execute/10604, Message: ON
Jan 09, 2019 7:46:44 PM zensemqtt.Log logging
SEVERE: Error in socket creation: java.net.SocketException
Jan 09, 2019 7:46:54 PM zensemqtt.Log logging
INFO: New message with topic: zense/execute/10604, Message: OFF
Jan 09, 2019 7:46:55 PM zensemqtt.Log logging
SEVERE: Error in socket creation: java.net.SocketException
Jan 09, 2019 7:47:00 PM zensemqtt.Log logging
INFO: New message with topic: zense/execute/10604, Message: ON

Notice the "SEVERE: Error in socket creation: java.net.SocketException" - this means the ZenseHome box is non-responding

Use the MQTT Explorer for examining the topics