Homeseer Script Syntax Help

upstatemike

Senior Member
I'm using a simple Homeseer script to copy data from my weather station into variables in my Stargate. For example, for humidity I use:

sub main()

hs.setDeviceValueByName("JDS vwshumid"),hs.DeviceValueByName("VWS Outsidehumidity")/100

end sub

The JDS and VWS represent the "room" that these Homeseer devices are in. The VWS plugin I am using has changed the default room for weather station devices to "Wx Station" and that space in the name seems to be messing up the syntax of the script. I could manually change the room name back to VWS but that is not optimal because every time I need to re-create the devices for some reason they are going to revert back to the default room name and I will have to go through a major manual process of resetting them again. It would be better to change the script to work with the default room name but I can't seem to find the right combination of quotes and/or parenthesis to make it work. Anybody have a suggestion for the correct syntax to replace "VWS" with "Wx Station" in this example?
 
how about just setting a variable which sets the room name to whatever you want it to be, then use the variable in the hs.SetDeviceValueByName command. Should do the trick.
 
how about just setting a variable which sets the room name to whatever you want it to be, then use the variable in the hs.SetDeviceValueByName command. Should do the trick.

Might be over my head... The room name is an attribute of the device so I guess I would need to know the hs.xxx command for modifying that attribute. I can't seem to find any list of Homeseer commands in the knowledge base or help files to use as a reference.
 
You are showing the room name in quotes, I assume you entered/hardcoded that value yourself? Basically it would look like this:
Code:
Public sHumidity

sub main()

sHumidity = "Wx Station Outsidehumidity"

hs.setDeviceValueByName("JDS vwshumid"),hs.DeviceValueByName(sHumidity)/100

end sub

It has been so long since I did VBscript (see my last script here for some examples), but I don't remember VBscript having issues with spaces when using quotes, so I think I am not understanding you correctly.
 
You are showing the room name in quotes, I assume you entered/hardcoded that value yourself? Basically it would look like this:
Code:
Public sHumidity

sub main()

sHumidity = "Wx Station Outsidehumidity"

hs.setDeviceValueByName("JDS vwshumid"),hs.DeviceValueByName(sHumidity)/100

end sub

It has been so long since I did VBscript (see my last script here for some examples), but I don't remember VBscript having issues with spaces when using quotes, so I think I am not understanding you correctly.

I think you are understanding fine, it is just that I am no programmer and so am not explaining it well.......

Homseer assigns device codes dynamically for each device (A1, W23, ]6, etc.)

Each device has some attributes including devicename (driveway, porchlight, etc.) and room (upstairs, JDS, VWS, etc.)

Because the device code can change under certain circumstances, like re-installing using a new version of a plugin, it is best to write any scripts by using the name instead of the device code. This keeps you from doing massive script edits if the device codes change.

hs.xxx functions (that I have used anyway) allow you to use the combination of room and devicename in the format "room devicename" in place of a code like W23 as a function parameter. Noting that the delimter is a space, any room or devicename that contains a space is going to mess up the syntax.

For my Stargate devices I have no problem because the plugin defaults to a room name of JDS and I was carefule not to use any spaces in the device names on my Stargate. The VWS plugin auto generates both the room and devicename and the room is is Wx Station with a space. I could manually edit it in the Homeseer GUI interface but it would return to the default if I ever had to re-install the plugin, causing a bunch of manual configuration again (original problem). I was hoping there was a way to put parenthesis (or quotes) around Wx Station to let the function work the way it did when the room name was VWS. Seems like this would be a common situation in the world of Homeseer scripting and I was kind of expecting a simple syntax tip from some Homeseer guru who has dealt with similar situations.

Tried asking on the HS forum but no response there.
 
Actually I decided just to edit the VWS devices I need and be done with it (and it work fine now). Thanks for the response though!!
 
Ok, I definitely understand now. I am surprised to see that Homeseer decided to use a space as a delimiter here, a bad and strange decision. Anyways, I'll show you how to do it, eventho you seemed to have taken care of the issue already. It's really simple:
Code:
sub main()

' initialize the variable we are going to be using to store the location
Dim sLocation

' set sLocation to Wx station
sLocation = "Wx Station"

hs.setDeviceValueByName("JDS vwshumid"),hs.DeviceValueByName(sLocation & " " & "Outsidehumidity")/100
hs.setDeviceValueByName("JDS vwstemp"),hs.DeviceValueByName(sLocation & " " & "OutsideTemperature")/100
...

end sub

I am pretty sure this should work (been a while since I played with HS). I added a fictional line for temperature, to show you that you only have to set that sLocation variable once.
 
Ok, I definitely understand now. I am surprised to see that Homeseer decided to use a space as a delimiter here, a bad and strange decision. Anyways, I'll show you how to do it, eventho you seemed to have taken care of the issue already. It's really simple:
Code:
sub main()

' initialize the variable we are going to be using to store the location
Dim sLocation

' set sLocation to Wx station
sLocation = "Wx Station"

hs.setDeviceValueByName("JDS vwshumid"),hs.DeviceValueByName(sLocation & " " & "Outsidehumidity")/100
hs.setDeviceValueByName("JDS vwstemp"),hs.DeviceValueByName(sLocation & " " & "OutsideTemperature")/100
...

end sub

I am pretty sure this should work (been a while since I played with HS). I added a fictional line for temperature, to show you that you only have to set that sLocation variable once.

Yes, I think that would work. I'll keep it in mind in case I hit a similiar situation. Thanks!
 
I'm using a simple Homeseer script to copy data from my weather station into variables in my Stargate. For example, for humidity I use:

sub main()

hs.setDeviceValueByName("JDS vwshumid"),hs.DeviceValueByName("VWS Outsidehumidity")/100

end sub

The JDS and VWS represent the "room" that these Homeseer devices are in. The VWS plugin I am using has changed the default room for weather station devices to "Wx Station" and that space in the name seems to be messing up the syntax of the script. I could manually change the room name back to VWS but that is not optimal because every time I need to re-create the devices for some reason they are going to revert back to the default room name and I will have to go through a major manual process of resetting them again. It would be better to change the script to work with the default room name but I can't seem to find the right combination of quotes and/or parenthesis to make it work. Anybody have a suggestion for the correct syntax to replace "VWS" with "Wx Station" in this example?

Hi Mike,

Kind of jumping into this thread late but it think this would work:

vbscript code:

Code:
sub main()

hs.setDeviceValueByName "JDS vwshumid", hs.DeviceValueByName "Wx Station " & "Outsidehumidity" / 100

end sub

Vb.Net code:

Code:
sub Main(byVal parms As Object)

hs.setDeviceValueByName("JDS vwshumid", hs.DeviceValueByName("Wx Station " & "Outsidehumidity") / 100)

end sub

Let me know if that doesn't work and I'll setup a couple variables and get the syntax working for you.

Ken
 
Back
Top