Announcement

Collapse
No announcement yet.

VR and Paramters to Scripts (Like IR $# function)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • VR and Paramters to Scripts (Like IR $# function)

    I'm trying to reduce the need for scripts and events as much as I can.

    So I've create a single event with a voice trigger of "heat (20|21|22|23|24|25)"
    This allows me to use the phone to set a heatpoint on my thermostat (using the HAI plugin).

    Now, according to the doco, you can substitute a variable for a voice command in an IR command.
    (4.11 Sending an infrared command)

    So in the above example I can use $2 in the IR Command. So the IR command could look like this:
    tv,command,$2
    Which in my example if I said "heat 20" would be
    tv,command,20 (Ok. I'm not going to use an IR command to change a thermostat, but this is just and example to show what you can do).

    I'm trying to use this same IR variable substitution in the script line to set my thermostat so my script line looks like:
    &a=hs.plugin("HAI_System").HAI_Set_Temp($2,1,"heating")

    This isn't in a script, it's in the scripting input field where you can enter a script file name or a single script function.

    If I replace the $2 with a value, say 20, everything works fine so I know my function line is ok. Leaving the $2 I get Error: Invalid character
    It looks like I can't do the same VR variable substitution as you can with an IR command.

    Anyone know how to get around this? Seems like HS already breaks up the voice input into parameters so if I can't do what I want, sounds like a good feature to add! I might have to have 1 script that sets the thermostat, but I'd have to have separate events for each value I wanted calling the same script and just passing a parameter. Eg:
    heat 20
    heat 21
    heat 22 etc.

    I suppose I could use hs.lastvoicecommand then parse the text in a script to pull out the value but it would be great to be able to do it on the script line of the event.

    Thanks,

    Ross.
Working...
X