News:

HOT TIP! Commands and groups can be copied and pasted directly from your command editor to the forum, and vice versa. This makes sharing command XML on the forum much easier!

Main Menu
Menu

Show posts

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

Messages - Marcowhite

#1
Python Scripting / Re: Import payloads in Python script
January 15, 2015, 06:24:53 PM
Now it's Working!!!!!


Thanks a lot for your support!


Marco!
#2
Python Scripting / Re: Import payloads in Python script
January 15, 2015, 06:08:10 PM
I'm passing an integer number, a value of temperature of a zona at my home.

If i run the script in idle (without variable) it runs perfectly.

When i try to run in into VC (with or without the variable) it seems that can't open the socket.

Marco
#3
Python Scripting / Re: Import payloads in Python script
January 15, 2015, 05:46:07 PM
Sorry but i'm thinking i'm stupid...

import socket
import sys

def doSimpleThing(var):
   
    temp = str(var)
   
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    except socket.error:
        print 'Failed to create socket'
        sys.exit()

    host = '192.168.1.40';
    port = 20000;
    zona = '6'

    try:
     remote_ip = socket.gethostbyname( host )

    except socket.gaierror:
        print 'Hostname could not be resolved. Exiting'
        sys.exit()


    s.connect((remote_ip , port))

    message1 = "*99*0##"
    message2 = "*#4*" + zona + "*#14*" + "0" + temp + "0" + "*1##"

    try :
        s.sendall(message1)
    except socket.error:
        print 'Send failed'
        sys.exit()

    try :
        s.sendall(message2)
    except socket.error:
        print 'Send failed'
        sys.exit()



Do you think it is correct?
#4
Python Scripting / Re: Import payloads in Python script
January 15, 2015, 05:15:13 PM
I'm sorry for the error when posting!

Now i'll try to code it!

I appreciate your help, Marco.
#5
Python Scripting / Re: Import payloads in Python script
January 15, 2015, 05:04:34 PM
And a code like this will not work?

import socket
import sys

from System.Collections.Generic import *
vc.triggerEvent("t.zonagiorno", List[str](["payload1"]))

print str

try:
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except socket.error:
    print 'Failed to create socket'
    sys.exit()

host = '192.168.1.12';
port = 35869;
zona = '6'

try:
    remote_ip = socket.gethostbyname( host )

except socket.gaierror:
    print 'Hostname could not be resolved. Exiting'
    sys.exit()


s.connect((remote_ip , port))

message1 = "*569*85*8"
message2 = "*#4*" + zona + "*#14*" + "0" + str + "0" + "*1##"

try :
    s.sendall(message1)
except socket.error:
    print 'Send failed'
    sys.exit()

try :
    s.sendall(message2)
except socket.error:
    print 'Send failed'
    sys.exit()
#6
Python Scripting / Re: Import payloads in Python script
January 15, 2015, 04:42:01 PM
Ah ok! The other script that i call from VC are written with IDLE and are perfectly working.

I'll try to rewrite the code in the plugin editor and i'll let you know if i receive errors.

Thanks, Marco.
#7
Python Scripting / Re: Import payloads in Python script
January 15, 2015, 04:29:39 PM
This is te code of the command.

<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.2.9-->
<command id="281" name="Imposta T zona giorno" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>PY.ExecFile</cmdType>
    <params>
      <param>C:\Voce\PY\sonda6set.py</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTSMS.SpeakSync</cmdType>
    <params>
      <param>Temperatura impostata.</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Temperatura zona giorno</phrase>
  <payloadRange>10,30</payloadRange>
  <event>t.zonagiorno</event>
</command>

Then i'll write a python script with IDLE, that import the variable and send it to a gateway via Socket.

I tried to watch this part of code but i don't understan it.

Thanks, Marco


#8
Python Scripting / Import payloads in Python script
January 15, 2015, 03:28:41 PM
Hi to all! I'm new to VoxCommando, but i realized that there are many things I can do with.

I'm trying to import a payload value from voxcommando to python but i don"t understand howto! I read the demo codes in the wiki but i get an error that are missing some modules!

Thank to all for helping me.

P.S. Sorry for my bad english.

Marco