Running python script with variables

Posted on
Sun Nov 13, 2016 7:26 pm
plaurent offline
Posts: 12
Joined: Jan 10, 2016

Running python script with variables

Decided to just dive directly into the fire... not using anything easy or sensible like Zwave, but rather a Plumlife lightswitch on a totally new v7 installation, having never before used HA before.

I can control and retrieve the status of the switch at the shell with several Python commands ("plum-probe.py --logical_load_id xxx-yyy-zzz --status" to get the status, while replacing --status with other arguments such as "--dim 80" or "--off" or "--on" for control. Easy enough at the shell level.

How do I pass those parameters on within Indigo. Found that I can't seem to create a device with this newfangled switch, so I found that I could do something with Action Groups, within Server Actions, but I'm sure I've got it all wrong.

Further adventures will include creating input variables for "--logical_load_id" and "--dim" so I can do something with more than just one switch and setting, and then creating variables from the resulting JSON string returned to actually get some feedback.

Anyone want to nudge or push me in the right direction? I've done quite a bit of searching and reading, and I'm not a stranger to programming, but I'm a bit turned around at the moment.

Posted on
Sun Nov 13, 2016 8:16 pm
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Running python script with variables

At the shell level are you sending commands like this?
Code: Select all
....$ python plum-probe.py --logical_load_id xxx-yyy-zzz --status

You could send the commands individually by writing scripts that call your python script using 'subprocess' for each function you want to send, but given the large number of possible iterations, you might want to think about writing a plugin.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Nov 14, 2016 7:43 am
plaurent offline
Posts: 12
Joined: Jan 10, 2016

Re: Running python script with variables

Many thanks for the reply!

Kinda figured it would head in the plugin direction. Hoping to not have to code from scratch, but rather adapt loosely off of another plugin and then submit it for others to use, is there a plugin with which you are familiar that might resemble my needs?

Posted on
Mon Nov 14, 2016 7:48 am
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Running python script with variables

You should really take a look at Rogue Proliator's Plugin Developer Documenter and the Indigo SDK.

The first demos the various calls and how they interact and the latter gives examples of various "types" of plugins. The forums are also a great place to find help.


Sent from my iPhone using Tapatalk

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest