Would it be feasible to write a plugin reliant on a Python 3.x module?

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
Septik
Posts: 37
Joined: Sun Feb 15, 2015 1:29 pm

Would it be feasible to write a plugin reliant on a Python 3.x module?

Post by Septik » Wed Oct 18, 2017 11:30 am

After getting my first taste of the writing of plugins, I've been wanting to learn more. As a user of Home Assistant, I thought a plugin for that could be my next project. (Don't worry, @kgschlosser, I'm still up for writing the wx part of the Spotify plugin.) After playing around with it and creating a simple plugin with a functional action, I started looking into the API and found a module called Python Remote API, a sub-package/sub-module(?) of the homeassistant package. I was excited at first, but soon realized that Home Assistant runs on Python 3, while EventGhost currently runs on Python 2.7.6.

Would it still be possible to use the homeassistant.remote package in an EventGhost plugin, or would they simply be incompatible? If the latter: Is a Python 3 version of EventGhost in the works? 'Cause if so, I guess I'll post-pone the writing of this plugin.

Thanks for reading.

Edit: I am probably mixing up the terms "module" and "package". I'm new to Python, but I hope and think you get the idea anyway.

Edit 2: I realized that most of what I wanted to achieve with a plugin can be done using MQTT. I am however having some trouble with krambriw's latest MQTT plugin.
  • I am unable to subscribe to several topics from the same domain (Home Assistant). I will get an error saying not to use duplicate subsciptions (although the names and topics differ). The most recent subscription will simply replace the old one.
  • I am able to subscribe to specific topics, for example "homeassistant/sensor/temp_outside/state" - but because of the above I can only subscribe to one particular topic this way, which is pointless.
  • I am able to subscribe to everything by subscribing to "#", but that gives me tons of events I don't need.
  • I am also able to subscribe to certain categories, for example "homeassistant/sensor/#", but that too gives tons of events I don't need.
Am I doing something wrong here?

By the way, I realize that this is probably not the place to ask for help with existing plugins. I'll probably post elsewhere soon.

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

Re: Would it be feasible to write a plugin reliant on a Python 3.x module?

Post by kgschlosser » Thu Oct 19, 2017 11:02 pm

I have been trying to figure out what the remote API is for in the home assistant library. It kind of half makes sense but then it doesn't

I seems as tho it is used to perform various things to a remote instance of home assistant. but it requires you to have home assistant installed on the machine that you are using to issue the commands. Which is the part that does not make any sense.


But I am trying to understand exactly what you are trying to accomplish. Are you trying to control home assistant from EG? or are you trying to control EG from home assistant? are you trying to run home assistant from inside of EG?

But any of them can be done by making a script that would create a named pipe (if trying to control home assistant from EG on the same computer) or creating a socket (if remote) and that script would run in the python 3 interpreter on the machine that is supposed to receive the commands. then you would open a socket or name pipe connection from inside of EG that would connect to the script running in the python 3 interpreter. and you could pass the command directly if you wanted through along with any parameters or you could create specific commands so that the script running in python 3 could issue and return any information it needed to. I have actually thought about doing something like this for a while for using python openzwave which I have only been able to successfully compile on windows running python 3.5 I have been trying to think of a way to be able to transfer and build a whole class structure through a socket or a named pipe that could be built on the other end.
If you like the work I have been doing then feel free to Image

Post Reply