MQTT Client

Questions and comments specific to a particular plugin should go here.
Snowbird
Experienced User
Posts: 363
Joined: Fri Jul 03, 2009 10:04 am

Re: MQTT Client

Post by Snowbird » Sat Jul 14, 2018 9:54 pm

yes i'm using a laptop, I mentioned it a few posts earlier :)

so if I understand well, for this specific matter (using a laptop) WMI works better than ctypes ? Because with WMI not only I can get the current brightness level, I can also set it to whatever I like. Well anyway, we can continue this conversation on the other topic, we are off topic ! :) (sorry MQTT ) :)

Terr
Posts: 14
Joined: Wed Jul 11, 2018 8:42 am

Re: MQTT Client

Post by Terr » Sat Jul 14, 2018 11:49 pm

same

Code: Select all

Python Script
   Traceback (most recent call last):
     Python script "16", line 104, in <module>
       raise ctypes.WinError()
   WindowsError: [Error 31] \u041f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u043e\u0435 \u043a \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.
i use pc with tv as monitor
and i use program volume2 which can control brightness with hotkeys

User avatar
kgschlosser
Site Admin
Posts: 4763
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: MQTT Client

Post by kgschlosser » Sun Jul 15, 2018 12:36 am

It depends on how the brightness is being set.

WMI could very well be altering the output stream from the video card. and not setting the actual brightness level of the screen. there is a very large difference.

The only way you would be able to know is if you had EG draw a completely black box that filled the entire screen and then changed the brightness. if the "glow" doesn't diminish then WMI is not setting the brightness but it is altering the video stream.

I do not know that innerworkings of windows to know who does what and why. or even if that function that i found works. The fact that it states that it uses an i2c data lane make me wonder if it in fact will work on a screen.

The way I am going about it is not using WMI and nor is it using that function. I am using a specific function for sending raw codes to a screen. There is so much that is broken in Windows who knows what does and does not work properly.

give me a few moments to put together a quick and dirty to test the mechanism I am going to use,
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 4763
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: MQTT Client

Post by kgschlosser » Sun Jul 15, 2018 12:40 am

@Terr

i forgot to go and buy a box of lucky charms. to get the free decoder ring prize so i can decode that error message. LOL

You either have to give me the language you have your computer set to so I can decode that bugger. or if you want to change the language you have windows set to then rerun it so we get an error output in english.

I find it odd that it is output that way because the error messages are gotten from Windows it's self. which would be translated into the current locale windows is set to. do you have EG set differently then Windows as far as the language goes?
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 4763
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: MQTT Client

Post by kgschlosser » Sun Jul 15, 2018 12:41 am

I am going to move over into the other thread where this conversation is better suited.
If you like the work I have been doing then feel free to Image

kalinkamaen
Experienced User
Posts: 138
Joined: Wed Dec 26, 2012 9:23 am

Re: MQTT Client

Post by kalinkamaen » Wed Aug 01, 2018 3:56 pm

Hello guys.

Mqtt with Domoticz. When I am pushing a scene in domoticz, the mqtt stops logging in EG.

Code: Select all

Exception in thread domoticz/out:
Traceback (most recent call last):
  File "threading.pyc", line 532, in __bootstrap_inner
  File "C:\EventGhost\plugins\MQTT Client\__init__.py", line 439, in run
    lrsp = mqttc.loop(10.0, 1)
  File "C:\EventGhost\plugins\MQTT Client\paho\mqtt\client.py", line 824, in loop
    rc = self.loop_read(max_packets)
  File "C:\EventGhost\plugins\MQTT Client\paho\mqtt\client.py", line 1086, in loop_read
    rc = self._packet_read()
  File "C:\EventGhost\plugins\MQTT Client\paho\mqtt\client.py", line 1488, in _packet_read
    rc = self._packet_handle()
  File "C:\EventGhost\plugins\MQTT Client\paho\mqtt\client.py", line 1956, in _packet_handle
    return self._handle_publish()
  File "C:\EventGhost\plugins\MQTT Client\paho\mqtt\client.py", line 2131, in _handle_publish
    self._handle_on_message(message)
  File "C:\EventGhost\plugins\MQTT Client\paho\mqtt\client.py", line 2287, in _handle_on_message
    self.on_message(self, self._userdata, message)
  File "C:\EventGhost\plugins\MQTT Client\__init__.py", line 323, in on_message
    res_key = msg.topic + ', ' + str(result[4])
IndexError: list index out of range

Schmurtz
Posts: 3
Joined: Wed Jan 30, 2019 2:11 pm

Re: MQTT Client

Post by Schmurtz » Wed Jan 30, 2019 3:31 pm

kgschlosser wrote:
Wed Jul 11, 2018 10:06 pm
....
Because of the complex nature of MQTT the author decided to put the message information into a payload. We can greatly improve upon this if you wanted. What can be done is you would create a Macro that has a python script action in it.

In that python script paste the following code

Code: Select all

payload = eg.event.payload

if payload and isinstance(payload, (str, unicode)) and 'suffix' in payload:
	payload = payload.split('suffix=')
	suffix = payload[1].strip()
	if 'prefix' in payload[0]:
	    payload = payload[0].split('prefix=')
	    prefix = payload[1].strip()
	elif 'prefix' in suffix:
	    suffix = suffix.split('prefix=')
	    prefix = suffix[1].strip()
	    suffix = suffix[0].strip()
	else:
	    prefix = eg.event.string
	if 'payload'  in payload[0]:
	    payload = payload[0].split('payload=')
	    payload = payload[1].strip()
	elif 'payload' in prefix:
	    prefix = prefix.split('payload=')
	    payload = prefix[1].strip()
	    prefix = prefix[0].strip()
	elif 'payload' in suffix:
	    suffix = suffix.split('payload=')
	    payload = suffix[1].strip()
	    suffix = suffix[0].strip()
	else:
	    payload = None
	eg.TriggerEvent(prefix=prefix, suffix=suffix, payload=payload)

then drag and drop one of your events. double click on the event in your tree and change it to the following.

Code: Select all

MQTT.*
so what we have done is we created a universal MQTT payload parser. you ill need to change the message being sent. now you can create custom events using MQTT here is an example of a message
Thanks a lot for that :) This example is simple and show the power of eventghost.

I was looking for events formatted like this :

Code: Select all

MyMQTT.MyComputer/run/kodi.start
so I simplified your script to the maximum for my use :

Code: Select all

payload = eg.event.payload
prefix = "My" + eg.event.string

if payload and isinstance(payload, (str, unicode)):
    eg.TriggerEvent(prefix=prefix, suffix=payload, payload=None)
It was a little difficult to have this MQTT client perfectly working at the beginning (installation with the copy of the content from "C:\ProgramData\EventGhost\plugins\MQTT Client\paho" to "C:\Program Files (x86)\EventGhost\lib26\site-packages" is a little subtle :lol: ).

If you listen the root of MQTT with a lot of mqtt messages the plugin seems to crash quickly :

Code: Select all

Exception in thread myMQTT:
Traceback (most recent call last):
  File "threading.pyc", line 532, in __bootstrap_inner
  File "C:\ProgramData\EventGhost\plugins\MQTT Client\__init__.py", line 521, in run
    lrsp = mqttc.loop(10.0, 1)
  File "C:\ProgramData\EventGhost\plugins\MQTT Client\paho\mqtt\client.py", line 1004, in loop
    rc = self.loop_read(max_packets)
  File "C:\ProgramData\EventGhost\plugins\MQTT Client\paho\mqtt\client.py", line 1282, in loop_read
    rc = self._packet_read()
  File "C:\ProgramData\EventGhost\plugins\MQTT Client\paho\mqtt\client.py", line 1847, in _packet_read
    rc = self._packet_handle()
  File "C:\ProgramData\EventGhost\plugins\MQTT Client\paho\mqtt\client.py", line 2294, in _packet_handle
    return self._handle_publish()
  File "C:\ProgramData\EventGhost\plugins\MQTT Client\paho\mqtt\client.py", line 2465, in _handle_publish
    self._handle_on_message(message)
  File "C:\ProgramData\EventGhost\plugins\MQTT Client\paho\mqtt\client.py", line 2612, in _handle_on_message
    self.on_message(self, self._userdata, message)
  File "C:\ProgramData\EventGhost\plugins\MQTT Client\__init__.py", line 389, in on_message
    ProcessEvent(msg, True, 1.0, res_key, event)
  File "C:\ProgramData\EventGhost\plugins\MQTT Client\__init__.py", line 272, in ProcessEvent
    TriggerEvent(msg)
  File "C:\ProgramData\EventGhost\plugins\MQTT Client\__init__.py", line 252, in TriggerEvent
    smsg = msg.topic.decode('utf-8')
  File "encodings\utf_8.pyc", line 16, in decode
UnicodeDecodeError: 'utf8' codec can't decode byte 0xc0 in position 12: unexpected end of data
But if you dedicate a more quiet topic to the computer it seems OK.
Now I'm happy with it, I control my computer from Home Assistant, thanks to the creator and the community ;)

User avatar
kgschlosser
Site Admin
Posts: 4763
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: MQTT Client

Post by kgschlosser » Thu Jan 31, 2019 6:58 pm

@Schmurtz

I had updated this plugin a while back to fix that decoding issue. you can download it HERE
If you like the work I have been doing then feel free to Image

marschner
Posts: 8
Joined: Mon Mar 12, 2012 10:59 am

Re: MQTT Client

Post by marschner » Sat Mar 23, 2019 4:54 pm

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?

User avatar
topix
Experienced User
Posts: 441
Joined: Sat May 05, 2007 3:43 pm
Location: Germany
Contact:

Re: MQTT Client

Post by topix » Sat Mar 23, 2019 5:11 pm

Which version of EG and the plugin? How do you install (double click .egplugin file, copy to directory)?

You could also run EG from command line with the -debug parameter and see it prints any error message.

marschner
Posts: 8
Joined: Mon Mar 12, 2012 10:59 am

Re: MQTT Client

Post by marschner » Sat Mar 23, 2019 5:27 pm

EG version 0.4.1.r1722 and client version 1.1.0.
I just doubleclick the file with EG open. It shows the client fine between the plugins.

marschner
Posts: 8
Joined: Mon Mar 12, 2012 10:59 am

Re: MQTT Client

Post by marschner » Sat Mar 23, 2019 8:15 pm

solved :-) I just used plugin version 1.2.2 instead!

Schmurtz
Posts: 3
Joined: Wed Jan 30, 2019 2:11 pm

Re: MQTT Client

Post by Schmurtz » Tue Mar 26, 2019 10:01 pm

kgschlosser wrote:
Thu Jan 31, 2019 6:58 pm
@Schmurtz

I had updated this plugin a while back to fix that decoding issue. you can download it HERE
Thanks for that !
Seems really more stable now. :D
I don't know who manage this download page but it should be uploaded here too :
http://www.eventghost.rocks/forum/db/pl ... tt_client/

User avatar
kgschlosser
Site Admin
Posts: 4763
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: MQTT Client

Post by kgschlosser » Wed Mar 27, 2019 8:28 pm

the original author no longer uses EventGhost and I do not believe he is maintaining this plugin any longer. I do not ue MQTT and do not have enough knowledge about it to be able to maintain it properly. I can make small fixes and post those. but that is not enough to open up a new forum thread for it.
If you like the work I have been doing then feel free to Image

Schmurtz
Posts: 3
Joined: Wed Jan 30, 2019 2:11 pm

Re: MQTT Client

Post by Schmurtz » Tue Jun 04, 2019 2:02 pm

kgschlosser wrote:
Thu Jan 31, 2019 6:58 pm
@Schmurtz

I had updated this plugin a while back to fix that decoding issue. you can download it HERE
The file is not available anymore. I think that it is really a shame for the community to not have this stable version :)

Post Reply