MQTT with Eventghost - half way there

I’m completely new to HASS, or doing anything with raspberryPI.

So far I’ve installed Rasbian on a Pi3 and enabled the Mosquitto service. I’ve also installed a MQTT plugin in Eventghost on my Windows10 pc. I can publish a topic from Mosquitto on the Pi and have eventghost successfully subscribe/receive the message, but when I try to have eventghost publish to said topic I cant seem to have HASS receive it. (it’s probably my automation that’s wrong) I would really appreciate some help with getting the two talking to each other.

Hopefully someone else is using evenghost for the same thing. Here’s a snippet of the config.yaml

mqtt:
    broker: 192.168.1.245
    port: 1883
    client_id: home-assistant-1
    keepalive: 60
    #username: USERNAME
    #password: PASSWORD
    birth_message:
        topic: 'hass/status'
        payload: 'online'
        qos: 1

Automation
  - alias: mqtt test
    trigger:
        platform: mqtt
        topic: "chromecast/playpause"
    action:
    platform: mqtt
        topic: "hass/status"
        payload: "online"
        qos: 1

Hi

I am not familiar with eventghost - but it seems to be another home automation system.

What are you trying to do with HASS?

MQTT is just a messaging service that you can post and collect messages from. Very handy when communication between machines.

Do you want HASS to send a message to MQTT that eventghost will collect so that it performs an action, or is the intention for HASS to listen for a message on MQTT and then it act?

In either case, you will need to compose your message for MQTT - which entails a topic and a payload

Maybe if you can clarify your use case for HASS we can help some more

Welcome to home assistant!!

Phil

I actually figured it out. I didnt understand how the formating for messages worked.
This is a good explanation for anybody else struggling with MQTT.
http://www.hivemq.com/blog/how-to-get-started-with-mqtt

I have a HTPC that is always on. It receives all the IR codes from my harmony hub and then reacts based on different things. In this case, eventghost sees when I change to the chromecast input, and re purposes the media control buttons as events to send MQTT topics. I can control my chromcast with my harmony remote now! This automation in itself has made investing in HASS worth it. Its always bugged me that I couldn’t have a physical remote for chromecast.

Thanks guys

Glad you got it working - I used the Hive overview to get my head around MQTT also, great suggestion.

Couldn’t agree more about the chromecast control!

I am hoping the guys get finished on the harmony hub component soon, then I can augment it with some HASS magic to react to remote presses on the chromecast.

Perhaps if you post your solution, you could also mark as solved. Then others could use it to resolve similar issues

Please share your setup, i find it extremely interesting

Well, first off you need to install Eventghost on a windows pc and have an IR receiver. I would absolutely recommend the usb-uirt it’s both a receiver and transmitter. It works really well, and has good Eventghost support. All IR codes received show up as events and can be reacted to as you wish. Eventghost also tracks what system processes are running so it can activate/deactivate things based on what program/event has occured.

I have the Harmony hub set up with my TV, AR and and a dummy device that is only there for the “blank” IR codes. (IR Codes that none of my other devices will react to.) The dummy device IR codes are used differently by Eventghost depending on different events it tracks.

In the case of the Chromecast, receiving the ir code for the input that my Cromecast is on, is used as an event to enable a folder that reacts to media buttons on the Harmony Smart Control by sending MQTT messages to HASS.

I hope that’s clear enough to let you know if you want to attempt a try. If you assistance as you set it up I’m willing to help with what I can. I’m still getting the hang of it all.

1 Like

Please, could you share your EventGhost configuration for sending MQTT messages to HASS? :slight_smile:

Sorry, I didn’t notice this till now.

Assuming you have Eventghost installed, head to the link below and download the “MQTT Client using Paho/” plugin for Eventghost. Open the file with Eventghost so it installs. After that you can add the MQTT plugin to your Eventghost Configuration Tree, allowing you to Subscribe and Publish to MQTT Topics on the Home-Assistant MQTT server.

I’m assuming all that makes sense. If it doesn’t I’m willing to go into as much detail as needed as long as your patient.

MQTT Plugin:
http://krambriw.net/Release/

2 Likes

Thanks for sharing I’m going to give this a go. Previously I was integrating my Amazon echo via ifttt via pushbullet to send commands to eventghost.

I like how this is all local and bidirectional.

@Orthodoxmonster you seem pretty knowledgeable in EventGhost given you’ve created a MQTT plugin to send commands from EG > HASS.

I’d like to do the same, but I’m trying to be simpler by using HASS’s RESTful API (HTTP Post JSON messages). I have the JSON messages I wish to send and am trying to use Python to send the requests i need from EG > HASS. Only problem is it doesn’t seem to work.

NOOB question. Do I need to install Python on my windows 8.1 machine running EG, so that I can execute Python commands in EG? Nowhere have I read that Python needs to be installed so I assume it’s not necessary.

Oh no, I didn’t write the plugin I found it reading through the Eventghost forum. Did you try using the python script action in Eventghost?

@Orthodoxmonster I managed to figure it out. Find below the Python Script I used to do similar to what you’re doing with MQTT, but instead I’m just using a HTTP call to HASS Rest API. You can easily adapt my code below to run any action on HASS.

What the Python Code below is doing is calling HASS to tell my LG TV to set the volume to 50%. Within EventGhost I have this Python script triggered whenever I turn on my HTPC (given that i’ll control volume via Windows OS volume, rather than the TV directly)

import requests
import json

url = 'http://192.168.86.127:8123/api/services/media_player/volume_set'
header = {'x-ha-access': 'PASSWORD', 'content-type': 'application/json'}
payload = json.dumps({'volume_level': '0.5', 'entity_id': 'media_player.lg_webos_smart_tv'})

r = requests.post(url, headers=header, data=payload)
1 Like

For future readers: the krambriw website seems to be (permanently?) down, but I found the author’s account on the EventGhost forums and he has a link to his Google Drive in his signature, so you can still download the plugin from there.

3 Likes

It took me a while to figure out, but I managed to get this setup working with Let’s Encrypt’s TLS/SSL encryption. If anyone else would like to do the same, I wrote some step-by-step instructions and put them in a gist here: How to set up EventGhost’s MQTT plugin to communicate with Home Assistant using TLS/SSL + Let’s Encrypt certificate

I’ve now got an EventGhost MQTT subscriber listening on a topic to hibernate my PC with a macro when a message is published there. I’ve integrated it with the Wake-on-LAN switch’s turn_off script on my Home Assistant and it’s working quite nicely so far :smile:

Relevant Home Assistant config:

switch:
  - platform: wake_on_lan
    name: PC WOL
    mac_address: !secret pc_mac_address
    host: !secret pc_ip
    turn_off:
      service: mqtt.publish
      data:
        topic: pc_hibernation_topic_name_here
        qos: 1

how to use hassio for control windows 10 without certificate ? in my local network
will it work without tls\ssl and certificates ?

I have tried to install the MQTT plugin in eventghost but when trying to add the plugin eventghost stalls completely. I have tried both on a win 8.1 and a win 7 machine with same result.
Anyone got an idea what can be done?

solved :slight_smile: I just used the plugin version 1.2.2 instead of 1.1.0

Did you find any instructions how to configure or use the EQ MQTT plugin?
When I configure the plugin I get a dialog with “Currently active threads” but only column headers and no entries.
Any idea what I’m missing?

Never mind. Adding a command to start a new MQTT subscription to autostart got me going.

how to find mqtt event?
i configured plugin, but event never show up in log after i publish topic

can someone tell me im missing something?