Thanks James, i will use rstrip() to remove the line for now.
I am a little tired, but i will post another question here, its about the same script.
My sensor sometimes send not only one feedback, but 2 o 3, in less then one second.
To avoid the action to run 2 or 3 times i created a dic
sensorControl = {
"GARAGESPEEK""" :"True",
"GARAGESPEEKFECHADO""" :"True",
"DOORSPEEK" : "True",
"DOORSPEEKFECHADO" : "True",
"WINDOWSIDESPEEK": "True",
"WINDOWCOUCHSPEEK": "True",
}
So, when the door of my room is opened i get the feedback and this will run a event :
See that i set the DOORSPEEK to false, then wait for 1 second to avoid the action to run again, since i am getting 2 or 3 feedback in 200 or 300ms.
In another action i am monitoring the air condition, everytime that i power on or power off the Air Condition using my ipad a event is sent for Vox and i set the state of the AC
<?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>
Now, when the door is opened the script run and if the AC is power on a TTS will inform that and ask to close the door. I will insert the rest of the code tomorrow, if the door dont close in 1 minute vox will power off the AC.
Now, my question, finally.
Every thing works fine with the action above, but let say that i want to do the same thing using only the script. I blocked the "IF condition" and tried this code :
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
But with this i get 2 or 3 TTS. I think that before run the script vox is running the action 2 or 3 times (from the feedback).
I dont know if i explain right, but what i wanna do its prevent the action to run again (sensorControl["DOORSPEEK"]= "False") and avoid this serial feedback from my sensors. I can use the first method above(works), but i believe that this code will be very big in a near future, i just start to make it and i will insert several conditions, so i will prefer to use the script to control everything, if its possible of course.
Thanks for your help.
Clayton