Would you like to say "Thanks!" for extra support or new features that we provided? Donations are gratefully accepted.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu


Quote from: jitterjames on May 28, 2013, 10:22:56 AMI am a bad programmer.Really ?.....
#Global Variables
variable1 = "test1"
variable2 = "test2"
def changeVariables():
variable1 = "change1"
variable2 = "change2"
#Local Variable
variable3 = variable1+variable2
return variable3
def changeVariablesGlobal():
global variable1
global variable2
variable1 = "change1"
variable2 = "change2"

#Global Variables
variable1 = "test1"
variable2 = "test2"
def changeVariables():
variable1 = "change1"
variable2 = "change2"
#Local Variable
variable3 = variable1+variable2
def changeVariablesGlobal():
global variable1
global variable2
variable1 = "change1"
variable2 = "change2" <?xml version="1.0" encoding="utf-16"?>
<command id="1791" name="variables" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
<action>
<cmdType>PY.ExecFile</cmdType>
<cmdString>PY\TestVariables.py</cmdString>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>PY.ExecString</cmdType>
<cmdString>changeVariables()</cmdString>
<cmdRepeat>0</cmdRepeat>
</action>
<action>
<cmdType>PY.ExecString</cmdType>
<cmdString>changeVariablesGlobal()</cmdString>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>PY.ExecString</cmdType>
<cmdString>result = variable1 + " " + variable2</cmdString>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>OSD.ShowText</cmdType>
<cmdString>{LastResult}&&3000</cmdString>
<cmdRepeat>1</cmdRepeat>
</action>
</command>
variable1 = "test1"
variable2 = "test2"

def changeVariables():
variable1 = "change1"
variable2 = "change2"
#Local Variable
variable3 = "test3"

def changeVariablesGlobal():
global variable1
global variable2
variable1 = "change1"
variable2 = "change2" 

File.WriteQuote from: jitterjames on May 27, 2013, 09:18:54 PMOk, you can test this by yourself, but this is working
I don't know what you are asking me any more... it is a bit hard to follow after all your posts.
What error are you getting? Maybe if you can upload all the xml and all the python that you are using, I can try to make some sense of it.
Impossible. vc.callAction will never return a value.
The first question I would ask is, why is the sensor sending the event more than once? What kind of sensor is it?
One way to avoid the problem with the sensor triggering multiple times is this.
1 - When your code is initialized, store the current time in a variable called "lastTriggerTime".
2 - Every time the sensor triggers your code, you compare the current time to the last time that was stored in lastTriggerTime. If it has been less than 5 seconds (or whatever period of time works best) then exit.
3 - Update the variable lastTriggerTime to the current time.
another option would be to use a timer, but that is more difficult.
powerArCondition =vc.callAction("File.Read","{Path.VC}\Devices\ArGree.txt",None)<?xml version="1.0" encoding="utf-16"?>
<command id="1645" name="porta home speek" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
<action>
<cmdType>PY.ExecString</cmdType>
<cmdString>sensorControl["DOORSPEEK"] = "True"</cmdString>
<cmdRepeat>1</cmdRepeat>
</action>
<event>speekDoor</event>
</command>
sensorControl = {
"GARAGESPEEK""" :"True",
"GARAGESPEEKFECHADO""" :"True",
"DOORSPEEK" : "True",
"DOORSPEEKFECHADO" : "True",
"WINDOWSIDESPEEK": "True",
"WINDOWCOUCHSPEEK": "True",
}
<?xml version="1.0" encoding="utf-16"?>
<command id="409" name="CFPower ArGree" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
<action>
<cmdType>File.WriteLine</cmdType>
<cmdString>{Path.VC}\Devices\ArGree.txt&&Ligado</cmdString>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>File.WriteLine</cmdType>
<cmdString>{Path.VC}\Devices\ArGreeTemp.txt&&{2}</cmdString>
<cmdRepeat>1</cmdRepeat>
</action>
<event>ArGree</event>
</command>powerArCondition = vc.getObject("lastresult", None)
powerArCondition = powerArCondition.rstrip()
doorSpeek = sensorControl["DOORSPEEK"]
doorSpeekFechado = sensorControl["DOORSPEEKFECHADO"]
def _doorOpen():
vc.callAction("OSD.ShowText",powerArCondition+doorSpeek, None)
if powerArCondition == "Ligado" and doorSpeek == "True":
sensorControl["DOORSPEEK"]= "False"
vc.callAction("TTS.Speak","Porta aberta", None)
vc.callAction("VC.SetEventTimer","1&&speekDoor",None)
variable = "True"
else:
variable = "False"
return variable