Announcement

Collapse
No announcement yet.

Set virtual device value

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

  • 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

  • #2
    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?
    My Plugins:

    Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
    Yeelight 3P | Nanoleaf 3P

    Comment


    • #3
      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?

      Comment


      • #4
        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.
        My Plugins:

        Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
        Yeelight 3P | Nanoleaf 3P

        Comment


        • #5
          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.500

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

          Comment


          • #6
            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.

            Comment


            • #7
              Thanks for everyone's advice...

              Comment


              • #8
                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]

                Comment


                • #9
                  Thanks much for the response. I'll take a look at the plugin.

                  Comment


                  • #10
                    Bummer, it looks like the plugin is for Windows only...

                    Comment


                    • #11
                      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...

                      Comment


                      • #12
                        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...

                        Comment


                        • #13
                          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

                          Comment


                          • #14
                            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...

                            Comment

                            Working...
                            X