www.homeseer.com    
 

Go Back   HomeSeer Message Board > Developer Support > Scripts & Plug-Ins:Development and Libraries > HS3 Scripting

HS3 Scripting Discussions related to the scripting under HS3.

Reply
 
Thread Tools Display Modes
  #1  
Old April 22nd, 2018, 01:16 PM
yyz yyz is offline
Seer
 
Join Date: Aug 2016
Location: Las Vegas, Nevada
Posts: 16
Set virtual device value

Hi there,

So, if I create a virtual device who's value is either Off or On, this value must be retrieved by sending a curl message to an http server and parsing out the json response. I'm not sure of the different ways to do this status update. What I mean is, when I open Web Control\Devices or open HS3Touch, can I make the virtual device check it's status at that time or do I have to do everything by events (i.e. polling the http server)? I'm just a beginner here so any advice would be greatly appreciated.

Thanks, Chris
Reply With Quote
  #2  
Old April 22nd, 2018, 03:08 PM
mrhappy mrhappy is offline
OverSeer
 
Join Date: Nov 2007
Location: W.Mids, UK
Posts: 7,344
I'm sorry I don't quite catch exactly what you are trying - do you want to notify your external application of changes in a devices status? Or do you want to know if there is a different way of getting the status of a device?
Reply With Quote
  #3  
Old April 22nd, 2018, 03:38 PM
yyz yyz is offline
Seer
 
Join Date: Aug 2016
Location: Las Vegas, Nevada
Posts: 16
Hi there,

Sorry I wasn't more clear. I would like to do both. I am basically controlling a light switch using a URL. I think I understand how to script the On\Off functions using events. I think my question is, if I were to turn off the lights directly from the outside source, how does the virtual device know this happened. Do I just poll it every once in a while? Is there a rule of thumb for the frequency of polling? Can I hurt the performance of the system by polling too often?
Reply With Quote
  #4  
Old April 22nd, 2018, 04:04 PM
mrhappy mrhappy is offline
OverSeer
 
Join Date: Nov 2007
Location: W.Mids, UK
Posts: 7,344
Quote:
Originally Posted by yyz View Post
Hi there,

Sorry I wasn't more clear. I would like to do both. I am basically controlling a light switch using a URL. I think I understand how to script the On\Off functions using events. I think my question is, if I were to turn off the lights directly from the outside source, how does the virtual device know this happened. Do I just poll it every once in a while? Is there a rule of thumb for the frequency of polling? Can I hurt the performance of the system by polling too often?
not the easiest topic to explain don't worry And just to be clear is that light switch controlled by HomeSeer and you are controlling it from something else like a web page via HomeSeer? So say you want HomeSeer to tell your external web page when it has changed?

For the most then yes your easiest method would be to periodically poll HomeSeer to check if the device has changed, whether or not there is any performance implication is a difficult one to answer because it would be dependent on your HS hardware, the stability of your HS system and all sorts of other factors. Personally I would not hammer the webserver with requests any less than once every couple of seconds, you could probably do it every second but personally I wouldn't want to. Best thing to do is just to experiment and see what happens, the HS web server is a custom design and no one really knows what is going on underneath, if you wanted to know the status of 100 lights then I wouldn't think this would be viable or sensible even if it was possible.

You could look at firing off an event when the light switch changed state to re-broadcast back to your page the new status, I imagine it would be forgiving enough not to do anything unusual if you sent back the same status as it was currently set to. The other option would be to look at the ASCII interface, this is a TCP port that you can open and new changes in devices all across the HS system can be read from this port - there are details of the commands and syntax in the help file/SDK. It's of course reliant on you being able to open the port and parse the results in your web page or whatever you are using.
Reply With Quote
  #5  
Old April 22nd, 2018, 05:10 PM
Uncle Michael's Avatar
Uncle Michael Uncle Michael is offline
OverSeer
 
Join Date: Feb 2006
Location: Rochester, NY
Posts: 5,997
Quote:
Originally Posted by yyz View Post
Hi there,

Sorry I wasn't more clear. I would like to do both. I am basically controlling a light switch using a URL. I think I understand how to script the On\Off functions using events. I think my question is, if I were to turn off the lights directly from the outside source, how does the virtual device know this happened. Do I just poll it every once in a while? Is there a rule of thumb for the frequency of polling? Can I hurt the performance of the system by polling too often?
If you provide a concrete example of what you want to do, it might be easier to answer your question. Is the light switch controlled directly by an IP command, or is the command going to HS, which sends instructions to the switch? If the former, how does the switch communicate with HS? How does HS communicate with the external source?
__________________
Mike____________________________________________________________ __________________
HS3 Pro Edition 3.0.0.435

HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF, Rain8Net+ | RFXCOM | QSE100D | Vantage Pro | Green-Eye | X10:
Compose, XTB-232, -IIR | Edgeport/8 | Way2Call | Ecobee3

Reply With Quote
  #6  
Old April 22nd, 2018, 09:10 PM
yyz yyz is offline
Seer
 
Join Date: Aug 2016
Location: Las Vegas, Nevada
Posts: 16
Quote:
Originally Posted by Uncle Michael View Post
If you provide a concrete example of what you want to do, it might be easier to answer your question. Is the light switch controlled directly by an IP command, or is the command going to HS, which sends instructions to the switch? If the former, how does the switch communicate with HS? How does HS communicate with the external source?
The light switch is controlled directly by an HTTP command (ie http://192.168.1.50:3000/circuit/3/off) or from a panel. The status of the light is also done by HTTP command (ie http://192.168.1.50:3000/circuit/3 returns a JSON payload). I think there's a socket that I can subscribe to but that's something I'll do down the road. The light switch can also be controlled from the panel itself.
Reply With Quote
  #7  
Old April 24th, 2018, 08:37 PM
yyz yyz is offline
Seer
 
Join Date: Aug 2016
Location: Las Vegas, Nevada
Posts: 16
Thanks for everyone's advice...
Reply With Quote
  #8  
Old May 15th, 2018, 08:57 PM
fcol's Avatar
fcol fcol is offline
Seer
 
Join Date: Dec 2016
Location: CA
Posts: 35
Have you looked into Jon00's DataScraper plugin:
https://forums.homeseer.com/showthread.php?t=175423
"Allows you to scrape data from Web pages and/or files on your network. Multiple virtual devices can be created from the data obtained with a mix of your own text/images & scraped data."*

I just installed DataScaper and am using it to poll the status of the handy OpenGarage device (garage door state, ultrasonic sensor distance, and vehicle presence). Then I just run a recurring event to periodically update the status of those virtual devices. In my case, I don't care if the state isn't synced up in real-time since the OpenGarage sensors are secondary to my primary garage door sensor.

*The above Datascraper description came from this list of all of Jon00's excellent utilities:
https://forums.homeseer.com/showthread.php?t=123313]
Reply With Quote
  #9  
Old May 15th, 2018, 10:38 PM
yyz yyz is offline
Seer
 
Join Date: Aug 2016
Location: Las Vegas, Nevada
Posts: 16
Thanks much for the response. I'll take a look at the plugin.
Reply With Quote
  #10  
Old May 15th, 2018, 10:41 PM
yyz yyz is offline
Seer
 
Join Date: Aug 2016
Location: Las Vegas, Nevada
Posts: 16
Bummer, it looks like the plugin is for Windows only...
Reply With Quote
  #11  
Old May 16th, 2018, 12:12 AM
fcol's Avatar
fcol fcol is offline
Seer
 
Join Date: Dec 2016
Location: CA
Posts: 35
Sorry - I can't script (other than copying other examples from this forum). I think I was trying to do something similar to you and spent a couple hours messing around until I found that Datascraper plugin.

To trigger your light via an http command, you could use hs.getURL in a .vb script (and trigger via an event). e.g.,
https://forums.homeseer.com/showthre...75#post1061175

I think that getting the device status and passing it onto a virtual device is trickier (for non-scripting beginners). I found this to set a device string:
https://forums.homeseer.com/showthre...28#post1153428

To scrape data from a webpage, I found some useful stuff here:
https://forums.homeseer.com/showthread.php?t=165045
https://forums.homeseer.com/showthre...7525&styleid=1

Then I (unsuccessfully) tried to learn how to use vbscript and InStr function to parse the desired values from the webpage. That's when I stumbled upon Datascraper and gave up trying to write my own script...
Reply With Quote
  #12  
Old May 16th, 2018, 01:27 AM
yyz yyz is offline
Seer
 
Join Date: Aug 2016
Location: Las Vegas, Nevada
Posts: 16
Awesome, thanks for the links. I am pretty good at VB and C#. It's just a matter of finding the right examples to get me started. I appreciate you helping me out...
Reply With Quote
  #13  
Old May 16th, 2018, 01:53 AM
jon00's Avatar
jon00 jon00 is offline
OverSeer
 
Join Date: Jan 2002
Location: London UK
Posts: 11,561
Quote:
Originally Posted by yyz View Post
Bummer, it looks like the plugin is for Windows only...
Not sure you read that but Datascraper works fine on both Windows & Linux versions of HS3.
__________________
Jon

Reply With Quote
  #14  
Old May 16th, 2018, 02:01 AM
yyz yyz is offline
Seer
 
Join Date: Aug 2016
Location: Las Vegas, Nevada
Posts: 16
Quote:
Originally Posted by jon00 View Post
Not sure you read that but Datascraper works fine on both Windows & Linux versions of HS3.
Sorry, my bad. I was looking at the wrong plugin. Thanks...
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Store and retrieve device status (in virtual device?) Patholoraptor BLDenon (3P) 1 August 9th, 2016 09:25 PM
Can a virtual Harmony Hub device control a real device or activity in HS? rayvino Harmony Hub 15 April 13th, 2016 07:53 AM
Virtual device to mimic a real device? U5tabil HomeSeer Software 5 July 20th, 2015 02:09 PM
HS3 Script Syntax to copy one virtual device status string to another virtual device pjohnson HS3 Scripting 8 December 31st, 2014 02:48 PM
Parse device string and update as the value of a virtual device ccat HomeSeer General Discussion Area 5 December 14th, 2010 04:32 PM


All times are GMT -4. The time now is 11:38 PM.


Copyright HomeSeer Technologies, LLC