Unfortunately I can not get the external script to work.
I used the command: Python /Library/Application\ Support/Perceptive\ Automation/Python2-includes/Bioscoop_SK.py "Kijk TV" in a shell for test and there it returns an error: ImportError: No module named indigo. When I run it from within Indigo action group shell script nothing happens and no messages displayed.
I want to run the python file from an action group with the argument "Kijk TV" which is used in the module BioscoopSK(mode). See code below (hack of collected bits and pieces from the forum and internet)
Is it possible to get this script to run external?
- Code: Select all
#!/usr/bin/env python
# This Python file uses the following encoding: utf-8
import random, time, calendar
import indigo
import applescript
import os
# From a file
script_file_path = "/Library/Application Support/Perceptive Automation/Scripts_External/Indigo2iRed_Ext.scpt"
iRed = applescript.AppleScript(path=script_file_path)
def BioscoopSK(mode):
versterker = 0
tv = 0
mediaplayer = 0
bioscooplicht = 0
SK_Bioscoop_var = indigo.variables[1389824491].getValue(str) # read variable "SK_Bioscoop"
SK_Bioscooplicht_var = indigo.variables[1923317447].getValue(str) # read variable "SK_Bioscooplicht"
SK_Kijk_Film_var = indigo.variables[367201486].getValue(str) # read variable "SK_Kijk_Film"
SK_Kijk_TV_var = indigo.variables[1991888223].getValue(str) # read variable "SK_Kijk_TV"
SK_Luister_Muziek_var = indigo.variables[1625817234].getValue(str) # read variable "SK_Luister_Muziek"
SK_MediaPlayer_var = indigo.variables[704464969].getValue(str) # read variable "SK_MediaPlayer”
SK_TV_var = indigo.variables[1033771403].getValue(str) # read variable "SK_TV”
SK_Versterker_var = indigo.variables[769372050].getValue(str) # read variable "SK_Versterker”
isDaylight_var = indigo.variables[517482721].getValue(str) # read variable "isDaylight"
Zon_Onder_Lux_var = indigo.variables[1778341929].getValue(str) # read variable "Zon_Onder_Lux"
# -- set variabeles depending on theatre mode
if mode == "SK Bioscoop UIT":
iRed.call("RemoteControl", "DENON AVR3312", "DENON/Receiver", "Mute", "IRTrans LAN")
time.sleep(1)
if SK_Bioscoop_var == "OFF":
indigo.server.speak("Slaapkamer, Bioscoop is al uitgezet")
else:
indigo.server.speak("Slaapkamer, bioscoop wordt uitgezet")
indigo.variable.updateValue(1389824491, value="OFF") # set variable "SK_Bioscoop" to "OFF"
indigo.variable.updateValue(367201486, value="OFF") # set variable "SK_Kijk_Film" to "OFF"
indigo.variable.updateValue(1991888223, value="OFF") # set variable "SK_Kijk_TV" to "OFF"
indigo.variable.updateValue(1625817234, value="OFF") # set variable "SK_Luister_Muziek" to "OFF"
if mode == "SK TV":
if SK_Kijk_TV_var == "ON":
indigo.server.speak("Slaapkamer, TV Kijken is al actief")
else:
indigo.server.speak("Slaapkamer, Kijk TV")
indigo.variable.updateValue(1389824491, value="ON") # set variable "SK_Bioscoop" to "ON"
tv = 1
bioscooplicht = 1
elif mode == "SK MediaPlayer":
indigo.server.speak("Slaapkamer, Kijk film met X, treamer")
indigo.variable.updateValue(1389824491, value="ON") # set variable "SK_Bioscoop" to "ON"
mediaplayer = 1
tv = 1
bioscooplicht = 1
# =====================================================================================================
# -- Check if theater lights have to be on (Only after sunset)
indigo.server.log("-- LUX -> variable isDaylight = " + isDaylight_var)
indigo.server.log("-- LUX -> variable Zon_Onder_Lux = " + Zon_Onder_Lux_var)
indigo.server.log("")
if isDaylight_var == "false" or Zon_Onder_Lux_var == "true":
indigo.server.log("-- LUX -> currently it's night time")
if SK_Bioscooplicht_var == "OFF" and bioscooplicht == 1:
indigo.server.log("-- LIGHTS -> switching theater lights on")
indigo.actionGroup.execute(74020290) # Execute Action Group: SK_Bioscoop_Licht_AAN
time.sleep(1)
indigo.server.speak("Bioscoop licht is aangezet")
indigo.variable.updateValue(1923317447, value = "ON") # set variable "SK_BioscoopLicht" to "ON"
else:
indigo.server.log("-- LUX -> Currently it's day time")
# =====================================================================================================
# -- Check Variables and ON/OFF state of devices
if SK_MediaPlayer_var == "OFF" and mediaplayer == 1: # switch mediaplayer on
indigo.variable.updateValue(704464969, value = "ON") # set variable "SK_MediaPlayer" to "ON"
indigo.device.turnOn(61763166) # Turn Device ON "SK - iXtreamer")
if SK_TV_var == "ON" and tv == 0: # zet tv uit
indigo.variable.updateValue(1033771403, value = "OFF") # set variable "SK_TV" to "OFF"
iRed.call("RemoteControl", "LG TV", "LG Discrete/TV", "OFF", "IRTrans LAN")
time.sleep(0.5)
iRed.call("RemoteControl", "LG TV", "LG Discrete/TV", "OFF", "IRTrans LAN")
elif SK_TV_var == "OFF" and tv == 1: # zet tv aan
indigo.variable.updateValue(1033771403, value = "ON") # set variable "SK_TV" to "ON"
iRed.call("RemoteControl", "LG TV", "LG Discrete/TV", "ON", "IRTrans LAN")
time.sleep(0.5)
iRed.call("RemoteControl", "LG TV", "LG Discrete/TV", "ON", "IRTrans LAN")
if SK_Versterker_var == "ON" and versterker == 0: # switch amplifier off
indigo.variable.updateValue(769372050, value = "OFF") # set variable "SK_Versterker" to "OFF"
iRed.call("RemoteControl", "DENON AVR3312", "DENON/Receiver", "Standby", "IRTrans LAN")
elif SK_Versterker_var == "OFF" and versterker == 1: # switch amplifier on
indigo.variable.updateValue(769372050, value = "ON") # set variable "SK_Versterker" to "ON"
iRed.call("RemoteControl", "DENON AVR3312", "DENON/Receiver", "ON", "IRTrans LAN")
# =====================================================================================================
# -- Set Amplifier inputs depending of theatre mode
if mode == "SK TV":
if SK_Bioscoop_var == "ON":
if SK_Kijk_Film_var == "ON":
time.sleep(1)
iRed.call("RemoteControl", "LG TV", "LG Discrete/TV", "TV", "IRTrans LAN")
indigo.variable.updateValue(367201486, value = "OFF") # set variable "SK_Kijk_Film" to "OFF"
indigo.variable.updateValue(1991888223, value = "ON") # set variable "SK_Kijk_TV" to "ON"
indigo.variable.updateValue(1625817234, value = "OFF") # set variable "SK_Luister_Muziek" to "OFF"
elif mode == "SK MediaPlayer":
if SK_Bioscoop_var == "ON":
if SK_Kijk_TV_var == "ON":
time.sleep(3)
iRed.call("RemoteControl", "iXtreamer Player", "iXtreamer/MediaPlayer", "Standby", "IRTrans LAN")
iRed.call("RemoteControl", "iXtreamer Player", "iXtreamer/MediaPlayer", "Standby", "IRTrans LAN")
time.sleep(34)
iRed.call("RemoteControl", "LG TV", "LG Discrete/TV", "HDMI2", "IRTrans LAN")
time.sleep(5)
iRed.call("RemoteControl", "iXtreamer Player", "iXtreamer/MediaPlayer", "ENTER", "IRTrans LAN")
time.sleep(4)
iRed.call("RemoteControl", "iXtreamer Player", "iXtreamer/MediaPlayer", "DOWN", "IRTrans LAN")
time.sleep(1)
iRed.call("RemoteControl", "iXtreamer Player", "iXtreamer/MediaPlayer", "DOWN", "IRTrans LAN")
time.sleep(1)
iRed.call("RemoteControl", "iXtreamer Player", "iXtreamer/MediaPlayer", "DOWN", "IRTrans LAN")
time.sleep(1)
iRed.call("RemoteControl", "iXtreamer Player", "iXtreamer/MediaPlayer", "ENTER", "IRTrans LAN")
time.sleep(1)
else:
time.sleep(1)
else:
time.sleep(3)
iRed.call("RemoteControl", "iXtreamer Player", "iXtreamer/MediaPlayer", "Standby", "IRTrans LAN")
iRed.call("RemoteControl", "iXtreamer Player", "iXtreamer/MediaPlayer", "Standby", "IRTrans LAN")
time.sleep(34)
iRed.call("RemoteControl", "LG TV", "LG Discrete/TV", "HDMI2", "IRTrans LAN")
time.sleep(5)
iRed.call("RemoteControl", "iXtreamer Player", "iXtreamer/MediaPlayer", "ENTER", "IRTrans LAN")
time.sleep(4)
iRed.call("RemoteControl", "iXtreamer Player", "iXtreamer/MediaPlayer", "DOWN", "IRTrans LAN")
time.sleep(1)
iRed.call("RemoteControl", "iXtreamer Player", "iXtreamer/MediaPlayer", "DOWN", "IRTrans LAN")
time.sleep(1)
iRed.call("RemoteControl", "iXtreamer Player", "iXtreamer/MediaPlayer", "DOWN", "IRTrans LAN")
time.sleep(1)
iRed.call("RemoteControl", "iXtreamer Player", "iXtreamer/MediaPlayer", "ENTER", "IRTrans LAN")
time.sleep(1)
indigo.variable.updateValue(367201486, value = "ON") # set variable "SK_Kijk_Film" to "ON"
indigo.variable.updateValue(1991888223, value = "OFF") # set variable "SK_Kijk_TV" to "OFF"
indigo.variable.updateValue(1625817234, value = "OFF") # set variable "SK_Luister_Muziek" to "OFF"
if mode == "WK Bioscoop UIT":
iRed.call("RemoteControl", "DENON AVR3312", "DENON/Receiver", "Mute", "IRTrans LAN")
indigo.variable.updateValue(1389824491, value="OFF") # set variable "SK_Bioscoop" to "OFF"
indigo.variable.updateValue(367201486, value = "OFF") # set variable "SK_Kijk_Film" to "OFF"
indigo.variable.updateValue(1991888223, value = "OFF") # set variable "SK_Kijk_TV" to "OFF"
indigo.variable.updateValue(1625817234, value = "OFF") # set variable "SK_Luister_Muziek" to "OFF"
else:
indigo.variable.updateValue(1389824491, value="ON") # set variable "SK_Bioscoop" to "ON"
# =====================================================================================================
# -- Check if theater lights have to be switched off.
if isDaylight_var == "false" or Zon_Onder_Lux_var == "true":
if SK_Bioscooplicht_var == "ON" and bioscooplicht == 0:
indigo.actionGroup.execute(394630618) # Action Group: SK_Alle_Lichten_uit
time.sleep(0.5)
indigo.server.speak("Slaapkamer, Bioscoop licht is uit gezet")
indigo.variable.updateValue(1923317447, value = "OFF") # set variable "SK_BioscoopLicht" to "OFF"
# -- Check if Mediaplayer must be switched off
if SK_MediaPlayer_var == "ON" and mediaplayer == 0: # switch mediaplayer off
indigo.variable.updateValue(704464969, value = "OFF") # set variable "SK_MediaPlayer" to "OFF"
time.sleep(23)
indigo.device.turnOff(61763166) # Turn Device OFF "SK - iXtreamer")
# =====================================================================================================
indigo.server.speak("Klaar")
return