Author Topic: HalCommands under Ultra Hal Assistant 5.0  (Read 49339 times)

Quixote

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
HalCommands under Ultra Hal Assistant 5.0
« Reply #45 on: December 15, 2004, 09:42:44 am »
Thanks again. Looks like I can use that with minimal modifications. I completed the blinds scripts last night, and I will work on this tonight.
I should be able to figure this out now.
Ultimately, I'd like to be able to extract other variables as well, which I will work on. I'm going to eventually set it up so that I can ask HAL "what is the weather forecast for tomorrow" and have it trigger an event and send "tomorrow" as the payload, then I can work in LUA which is the language that I would prefer to learn for my home automation. This way I will only need the basics for HAL and I don't need to learn 2 languages. I'll let you know how it goes.
By the way, the blinds work great. It's so neat telling HAL to "turn on the TV, Close the blinds all the way, or turn off the livingroom light" and so on, everytime I do  it makes me chuckle.
 

Quixote

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
HalCommands under Ultra Hal Assistant 5.0
« Reply #46 on: December 15, 2004, 06:53:17 pm »
Works great! I've got a question, though.
I added more terms to use and changed some, but it only recognizes some of them. For instance, it responds appropriately to "select channel 11", but it starts talking about television if I say "change to channel 11".
Here is the modified script (it's not changed much):

ChannelNumber = "" 'Initialize variables.
payload = ""
TestSentence = Trim(HalBrain.AlphaNumericalOnly(UserSentence)) 'Get rid of punctuation and end spaces.
If InStr(1, TestSentence, " TURN TO TELEVISION CHANNEL ", 1) > 0 Or InStr(1, TestSentence, " TURN TO CHANNEL ", 1) > 0 Or InStr(1, TestSentence, "SELECT TELEVISION CHANNEL ", 1) > 0 Or InStr(1, TestSentence, "SELECT CHANNEL ", 1) > 0 Then
TestSentenceArray = Split(TestSentence, " ", -1, vbBinaryCompare) 'Split TestSentence into an array of words.
If (IsArray(TestSentenceArray) = True And UBound(TestSentenceArray) > -1) Then
For X = 0 To UBound(TestSentenceArray)
If Trim(TestSentenceArray(X)) = "CHANNEL" And UBound(TestSentenceArray) >= (X + 1) Then
ChannelNumber = Trim(TestSentenceArray(X + 1)) 'Set ChannelNumber to the word or number following the word "CHANNEL".
X = 1000 'If channel number is found then break loop.

If ChannelNumber <> "" And IsNumeric(ChannelNumber) = True Then payload = ChannelNumber
End If
Next
End If

If payload <> "" Then
GetResponse = " Channel " & payload & ". "
GetResponseBlock = True
BlockSave = True
Set GirderEvent = CreateObject("Girder.GirderEvent")
GirderEvent.Device = 18
GirderEvent.EventString = "AICHANGECHANNEL"
GirderEvent.Payload(2) = payload
GirderEvent.Send()
End If

End If




I already removed the commands that don't work.
« Last Edit: December 15, 2004, 06:55:27 pm by Quixote »
 

Quixote

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
HalCommands under Ultra Hal Assistant 5.0
« Reply #47 on: December 15, 2004, 08:12:50 pm »
It just suddenly stopped working.


[V] [:(!]

Just when I thought everything was cool...
 

vonsmith

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
HalCommands under Ultra Hal Assistant 5.0
« Reply #48 on: December 15, 2004, 11:09:42 pm »
Quixote,
Your detection strings need a little tweaking.

Now is:

If InStr(1, TestSentence, " TURN TO TELEVISION CHANNEL ", 1) > 0 Or InStr(1, TestSentence, " TURN TO CHANNEL ", 1) > 0 Or InStr(1, TestSentence, "SELECT TELEVISION CHANNEL ", 1) > 0 Or InStr(1, TestSentence, "SELECT CHANNEL ", 1) > 0 Then

Should be:

InStr(1, TestSentence, "TURN TO TELEVISION CHANNEL ", 1) > 0 Or InStr(1, TestSentence, "TURN TO CHANNEL ", 1) > 0 Or InStr(1, TestSentence, "SELECT TELEVISION CHANNEL ", 1) > 0 Or InStr(1, TestSentence, "SELECT CHANNEL ", 1) > 0 Then

Notice that "TURN TO TELEVISION CHANNEL " and "TURN TO CHANNEL " strings should not have leading spaces. The prior line to detection is this:

TestSentence = Trim(HalBrain.AlphaNumericalOnly(UserSentence)) 'Get rid of punctuation and end spaces.

This is what is happening:

    UserSentence = " SELECT TELEVISION CHANNEL 123 " <-- before Trim()
    TestSentence = "SELECT TELEVISION CHANNEL 123"  <-- after Trim()
Incorrect:
Detection String = " SELECT TELEVISION CHANNEL "
Correct:
Detection String = "SELECT TELEVISION CHANNEL "

When it comes to string detection you have to certain what the strings look like after processing. Spaces are as important as characters.

I didn't find any other errors in the code. I can't speak for the girder code though.


=vonsmith=
 

Quixote

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
HalCommands under Ultra Hal Assistant 5.0
« Reply #49 on: December 16, 2004, 09:20:39 am »
Thanks. The Girder code is perfect. It was working flawlessly, but I think I somehow managed to mess up the HAL script while changing something. I will fix that tonight and get back to you.
Another goal accomplished (almost).
Next: dimming various lights to a certain percentage and by a certain percentage.
 

Medeksza

  • Administrator
  • Hero Member
  • *****
  • Posts: 1472
    • View Profile
    • http://www.zabaware.com
HalCommands under Ultra Hal Assistant 5.0
« Reply #50 on: December 19, 2004, 03:23:10 pm »
Quixote,

Your scripts interested me so I purchased Girder and a Tira2 to try something similar. I see that on the Promixis forum you had an unanswered question about long button presses a week ago. Have you figured it out yourself? I have a similar problem with some light dimmers and replied to your post on that forum.
Robert Medeksza

Quixote

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
HalCommands under Ultra Hal Assistant 5.0
« Reply #51 on: December 19, 2004, 10:09:21 pm »
I'll go check out your post. For now I will try to answer your questions here.
I have solved my problem with the blinds by creating a multigroup command and placing numerous copies of the same command that I wanted to use into the multigroup. This way when I fire that one command it sends the signal 30 times for instance. I have also ordered the USB-UIRT, which is similar to the Tira-2, but from what I understand it has a couple of added features. That remains to been seen, but I just thought I'd get one anyway.
The Tira section of the forum is run by another person that is not actually part of the Girder/Promixis team. For any questions about Girder, you can always try to ask me first, bt the real pros are in the Girder forum.
Now for the light dimmer question that you have (I have never heard of IR light switches. You may want to check out an X10 setup. try www.smarthome.com or www.x10.com - always check to make sure that there are plugins available in Girder for the device) The way I would solve the problem is the way I have for the blinds. First, create multigroups for different levels of Brightening or dimming. Then put a command in the multigroup and learn the IR code. Set the repeat to 10 in the TIRA settings and then duplicate the command a number of times within the multigroup. Each different multigroup should have a different number of copies of the dim or brighten command. You can also learn triggers for each level such as 1 for dimming 1 notch or 9 for dimming 9 notches and control-1 to brighten 1 notch and control-9 to brighten 9 notches. Don't forget to disable the group when you are not using it or the lights will start to go nuts while you are typing. You can assign a hot-key combination to that as well.

Please let me know if my instructions were clear enough and if this solved your problem.
 

Medeksza

  • Administrator
  • Hero Member
  • *****
  • Posts: 1472
    • View Profile
    • http://www.zabaware.com
HalCommands under Ultra Hal Assistant 5.0
« Reply #52 on: December 20, 2004, 03:45:00 pm »
Thanks, the multigroup did the trick. I created different multigroups for different levels of illumination and it works great.

I purchased 2 infrared dimmer light switches in Home Depot for $18 each a couple months ago. The dimmer has a switch to respond to 1 of 2 infrared commands, so each of the switches can be independently controlled by girder. I see now on their web page they list a different brand infrared switch for $62, but if you go to the store they still might have the $18 ones if you are interested.  



quote:
Originally posted by Quixote

I'll go check out your post. For now I will try to answer your questions here.
I have solved my problem with the blinds by creating a multigroup command and placing numerous copies of the same command that I wanted to use into the multigroup. This way when I fire that one command it sends the signal 30 times for instance. I have also ordered the USB-UIRT, which is similar to the Tira-2, but from what I understand it has a couple of added features. That remains to been seen, but I just thought I'd get one anyway.
The Tira section of the forum is run by another person that is not actually part of the Girder/Promixis team. For any questions about Girder, you can always try to ask me first, bt the real pros are in the Girder forum.
Now for the light dimmer question that you have (I have never heard of IR light switches. You may want to check out an X10 setup. try www.smarthome.com or www.x10.com - always check to make sure that there are plugins available in Girder for the device) The way I would solve the problem is the way I have for the blinds. First, create multigroups for different levels of Brightening or dimming. Then put a command in the multigroup and learn the IR code. Set the repeat to 10 in the TIRA settings and then duplicate the command a number of times within the multigroup. Each different multigroup should have a different number of copies of the dim or brighten command. You can also learn triggers for each level such as 1 for dimming 1 notch or 9 for dimming 9 notches and control-1 to brighten 1 notch and control-9 to brighten 9 notches. Don't forget to disable the group when you are not using it or the lights will start to go nuts while you are typing. You can assign a hot-key combination to that as well.

Please let me know if my instructions were clear enough and if this solved your problem.

Robert Medeksza

Quixote

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
HalCommands under Ultra Hal Assistant 5.0
« Reply #53 on: December 21, 2004, 12:15:40 am »
Glad to hear that that did the trick. I don't think I would use infra-red switches because they are too limited in that you need to point the device at the sensor to control them. This only really becomes a problem when you have many diferent devices to control. For example I have my TV, DVD player, Amplifier, an IR controled fan, and my vertical blinds. Additionally I am considering an IR controlled air-conditioner so that I can get some temperature sensors and have Girder turn them on or off depending on if it's too hot and if I am going to be home soon or am home already. (I use X10 motion sensors for that). The IR device needs to be repositioned when I want to turn on the fan because it is on the opposite wall that my wall unit is on. I solved this by attaching it to my swivel chair so that I can just spin the chair around while I'm sitting at the computer and want to turn on the fan. This is quicker that fumbling with 6 different remotes.

One thing that I would like to see implemented in HAL is the ability to follow a certain routine with questions and answers. I mentioned this to VonSmith before, and he told me that this is not possible at this time. I can send messages to HAL with Girder using LUACOM I think, so the trigger wouldn't be the problem, but let me explain what I am getting at and maybe you can give me some suggestions or consider the feature for the future:
I'm still working on this but it's coming along. I have set up a "gate" using motion sensors. when #1 is triggered (outside of my door) #2 is turned on (just inside my front door). when #2 is triggered it turns on #3. #3 (at the top of my stairs to my duplex) initiates the welcome home event, which right now just says welcome home and the time using Girder, and then turns off #3 and #2. I still have a few details to work out so it doesn't go off when I answer my door, but you get the picture. OK, now for where HAL comes in. I'd like to trigger a HAL command instead of the Girder "Welcome home" event and have this happen:

Hal: Welcome home! The time is [time]. Would you like to watch TV?
Me: Sure (or yes please, or OK, or any number of other affirmative responses)
TV TURNS ON
Hal: Any particular channel?
Me: 22, please.
Hal: Right away.
TV CHANGES TO CHANNEL 22

Do you see what I'm getting at?  Also, if I said "No, thanks (or nope, or not right now, etc) it would say something else such as "There's probably nothing good on anyway". Also, it would be good if it could see that there was no response within a certain time to the first question and say something else like "I guess you don't feel like talking." or "Oh, Hi JD." (That's my roommate and he is not into this whole automation thing). I've seen the scripts that people have worked on for responding after a certain amount of time of no responses, but I would find that totally annoying. Perhaps I could use some of the code, though.

Please let me know what you think. Thanks!

Quixote
« Last Edit: December 21, 2004, 12:18:12 am by Quixote »
 

Medeksza

  • Administrator
  • Hero Member
  • *****
  • Posts: 1472
    • View Profile
    • http://www.zabaware.com
HalCommands under Ultra Hal Assistant 5.0
« Reply #54 on: December 21, 2004, 02:59:38 am »
The tira-2 has a port in the back where you can connect additional ir blasters. I'm not sure why the tira company doesn't sell any ir blasters themselves, but i happened to have 6 unused ir blasters laying around from 2 replaytvs, and a couple remote control extenders. I soldered these ir blasters together in a parallel circuit and added some extention wire to some of them. This way I have a single tira controlling the devices in 2 rooms and it doesn't matter if someone or something is in the line of sight of the main transmitter since there are ir blasters setup around the room. I currently have my system setup to be controlled by a wifi pocketpc using girder and netremote. It controls 2 light dimmers, 2 audio receivers, a projector, a tv, a tivo, and an htpc. I'll probably have it control an air conditioner like you are planning sometime in June when I take it out again. I currently have it setup that when someone walks into my apartment, a motion detector turns a light on, a webcam takes your picture, and it uploads the picture to a remote internet server.

I'm still working on integrating girder and netremote in, but i definetely plan on adding hal into the mix in the near future. What you suggest is certainly possible with some scripting. I'll be sure to share any scripts I come up with.
Robert Medeksza

Quixote

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
HalCommands under Ultra Hal Assistant 5.0
« Reply #55 on: December 21, 2004, 12:03:41 pm »
Sounds like you're having a blast (no pun intended har har har)
I had no idea that you were so involved in this. Kudos!
I have some ir emitters as well, but they need to be taped to the IR sensor on the device, and to me this just doesn't cut it. I mean, what's the point of using IR if you're going to have wires taped to all of the devices. I may eventually buy some blasters like you have, though. Good idea.
Have fun!

P.S.- I like the webcam thing. I currently use wireless surveillance cameras, but the signal can be a little flakey.
 

Quixote

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
HalCommands under Ultra Hal Assistant 5.0
« Reply #56 on: December 27, 2004, 01:06:55 am »
VonSmith, would you mind proof-reading this script for me? I doesn't seem to want to work and I can't understand where i went wrong. It responds appropriately, saying "Adjusting the light to X percent." With X being a multiple of ten between 10 and 100, but the payload variable is not set. Here is the code:

LightLevel = ""
payload = ""
TestSentence = Trim(HalBrain.AlphaNumericalOnly(UserSentence))
If InStr(1, TestSentence, "DIM THE LIGHT TO ", 1) > 0 Or InStr(1, TestSentence, "BRIGHTEN THE LIGHT TO ", 1) > 0 Or InStr(1, TestSentence, "LIGHT LEVEL TO ", 1) > 0 Or InStr(1, TestSentence, "ADJUST THE LIGHT TO ", 1) > 0 Or InStr(1, TestSentence, "SET THE LIGHT TO ", 1) > 0 Then
TestSentenceArray = Split(TestSentence, " ", -1, vbBinaryCompare)
If (IsArray(TestSentenceArray) = True And UBound(TestSentenceArray) > -1) Then
For X = 0 To UBound(TestSentenceArray)
If Trim(TestSentenceArray(X)) = "TO" And UBound(TestSentenceArray) >= (X + 1) Then
LightLevel = Trim(TestSentenceArray(X + 1))
X = 1000

If LightLevel <> "" And IsNumeric(LightLevel) = True Then payload = LightLevel
End If
Next
End If

If payload <> "" Then
GetResponse = " Adjusting light to " & payload & " percent. "
GetResponseBlock = True
BlockSave = True
Set GirderEvent = CreateObject("Girder.GirderEvent")
GirderEvent.Device = 18
GirderEvent.EventString = "AI_Bright_Dim_TO"
GirderEvent.Payload(3) = payload
GirderEvent.Send()
End If

End If



Thanks again. And Happy holidays, by the way!
 

Quixote

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
HalCommands under Ultra Hal Assistant 5.0
« Reply #57 on: December 27, 2004, 01:14:33 am »
OOPS!!!!

My mistake. The script is fine. It was my girder script. I found the problem. I had been trying to execute functions with conditions based on the payload before I had defined the functions. [:I]
Oh well, thanks anyway! [:D]
 

Quixote

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
HalCommands under Ultra Hal Assistant 5.0
« Reply #58 on: December 28, 2004, 05:06:26 am »
I was just wondering how I can change the script so that as well as its current configuration:

If payload <> "" Then
GetResponse = " Increasing the volume by " & payload & " levels. "
GetResponseBlock = True
BlockSave = True

I can add:

if payload = "1" then
GetResponse = " Increasing the volume by " & payload & " level. "

So that it doesn't sound dumb when it says "Increasing the volume by one levels." (plural for 1 level)

Thanks!
 

Art

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3910
    • View Profile
HalCommands under Ultra Hal Assistant 5.0
« Reply #59 on: December 28, 2004, 04:17:00 pm »
Perhaps you could break the volume levels
into percents. That way your script would
still remain the same and the program would
say,"I am increasing the volume by 1 percent"
or by 20 percent or what ever.

Otherwise you would have to us the
if payload = "1" then GetResponse =
" Increasing the volume by " & payload & " level. "

else if payload > 1 then GetResponse =
" Increasing the volume by " & payload & " levels. "


Just a suggestion
« Last Edit: December 28, 2004, 04:18:29 pm by Art »
In the world of AI it's the thought that counts!

- Art -