New to python - WHERE do my scripts go, and how do i call

Posted on
Mon Sep 18, 2017 8:00 am
sjbrownie offline
Posts: 2
Joined: Sep 15, 2017

New to python - WHERE do my scripts go, and how do i call

I'm new to python and Indigo. I have reasonable code experience (PHP mostly).

What I have:
I have a Raspberry Pi that serves as Garage door supervisor. I can query the state of any of my garage doors with a simple http request. On the scripting command line I have made the http query, and assigned it to a variable in indigo.

What I am missing:
I cant figure out how / where to save and re-use the commands I had success with.
I want to make a device called Garage Door, and then use the variable from the http query to know its status (open / closed).

Thanks for the help in advance. Its probably such a noob question to you all.

Posted on
Mon Sep 18, 2017 9:54 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: New to python - WHERE do my scripts go, and how do i cal

Sounds like you need to set-up a virtual device

One potential gotcha is that you have to enable the Virtual Devices interface from the main menu: Interfaces > Virtual Devices > Enable

You now need to set-up individual action groups for the virtual device. Go to the main window sidebar, select ACTION GROUPS and then click New...
You need to select Server Actions > Script and File Action > Execute Script to enter your script details.

That's a starter for 10 :)

Posted on
Mon Sep 18, 2017 10:39 am
sjbrownie offline
Posts: 2
Joined: Sep 15, 2017

Re: New to python - WHERE do my scripts go, and how do i cal

Thanks for Enable Virtual Devices tip.

Ive got my script entered as an action group as you indicate. Its working when i press run, it returns the correct property of the garage door (a 0 in this case). Sorry for my ignorace, but now how do I use that to update a virtual device?

Posted on
Mon Sep 18, 2017 11:24 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: New to python - WHERE do my scripts go, and how do i cal

I presume that you want to just check the status rather than be able to open/close the garage door from Indigo?

When you set up a Virtual Device: New... > Virtual Device > Type = Virtual devices, Model = Virtual On/Off Device, you are presented with a dialogue where you have to fill in Action Groups for On, Off, Toggle. You need to tick Supports Status and then provide a Status Variable and a Status (Action) Group to update the status.

In your case (assuming you don't want to open/close the garage door from Indigo) you don't require the on/off/toggle action groups but you have to set one up. You can set-up a dummy action group that does nothing for these three actions i.e. No Action. In the variable field specify your variable that you are altering by your script. In the status field specify the Action Group which has your script which returns the value 0 from your rPi - I assume it returns 1 if it is open? Indigo can handle 0 / 1, 'true' / 'false' in the variable used to determine the state. So now when you click the Virtual Device status button in the main Indigo Device List UI, Indigo will run your action group that will run your script that changes the variable depending on garage door state and Indigo will update the Virtual device state accordingly.

Depending how you want the status updated, you could set up a repeating schedule (say every 30 seconds) to do an action: Device Actions > Universal Controls > Request Full Status Update. This would check the state of the garage door every 30 seconds.

Hope that helps - post back if you need more detail. :)

Posted on
Tue Sep 19, 2017 10:16 pm
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: New to python - WHERE do my scripts go, and how do i cal

Great answer and detail there, Autolog. I'd forgotten you could do this with virtual devices.


Sent from my iPhone using Tapatalk Pro

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 5 guests