Announcement

Collapse
No announcement yet.

HS3 Script - Web Power Switch

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

  • HS3 Script - Web Power Switch

    I have created a script to control the Web Power Switch from Digital Loggers:
    http://www.digital-loggers.com/lpc.html

    Please be careful with this script! The Web Power Switch allows you to turn outlets on and off remotely and oftentimes PCs/Servers are plugged into it. It would be very easy to accidentally turn on or off outlets and any equipment attached. I assume no responsibility for your use of this script and any subsequent equipment damage that may occur.

    I have confirmed that the script will work with the Web Power Switch II. The current version of the Web Power Switch is 7.

    The script uses a tool called UU.W32.EXE found on the Digital Loggers site here:
    http://www.digital-loggers.com/cex.html

    The notes for this tool say it works with the following devices:
    Web Power Switch III
    Ethernet Power Controller II
    Ethernet Power Controller III
    48Volt Power Switch
    DIN Relay
    Vertical PDU

    So I am going to assume my script will work with any of these devices (and presumably more, but no guarantees).

    The first time the script is executed, it will create 8 devices in Homeseer - one device representing each outlet. Each device will have three options - On, Off, Cycle. On and Off are pretty self explanatory. Cycle means that if the outlet is On, it will turn it off and then back on. And if it is Off, it will turn it on and then back off.

    Future executions of the script will check for the existence of the first outlet as a Homeseer device and if found, will not create any devices.

    To use the script, you must download the aforementioned UU.W32.exe tool and put it in your Homeseer Scripts directory. You must also go into the script and configure your Web Power Switch Web URL, Username, and Password. You can also turn debugging on or off, set the name of the devices, Floor, and Room (called Category in the script).

    I am not a programmer at all so I am sure there are many things in the script that aren't done efficiently and could be improved, but it works for me. Feel free to steal this script of any of the associated code for your own use.

    The script works well, but there are several things to be aware of:

    1. You cannot hit the On, Off, Cycle buttons too quickly in succession. I have posted a question here regarding this issue. I suggest waiting at least 3 seconds between button presses.

    2. The script does not "detect" changes to the Web Power Switch made outside of Homeseer. In other words, if you use the Web Power Switch's internal web server to turn an outlet on or off, the script will not be aware of this. You could set the script up to poll the outlet status, but I did not choose to do this.

    3. I can't figure out how to get rid of the Light Bulbs in the Homeseer UI without replacing them with other images. This isn't a big deal for me, but is slightly annoying. I think this issue is addressed here, but I did not see a solution.

    Scott
    Attached Files

  • #2
    Scott,

    I just noticed your script. It's been something I've wanted for a while since I have two Web Power Switches in my home. I was very exited to see you had shared this script. Unfortunately, I've run into a problem. Data Loggers has updated the "UU.W2.exe" tool including a name change. I tried just changing the name in the script, but it still didn't work. I get the attached two errors. Could you update your script or perhaps provide the "UU.W2.exe" files

    Forrest
    Attached Files

    Comment


    • #3
      I'm having an issue with this script as well. It creates my outlet devices fine and even populates them with the correct status, but the On, Off, and Cycle buttons don't do anything other than toggle the status in HS. I'm not sure why the button press is not calling the WPSOutletControl function as it should.

      Comment


      • #4
        The Digital Logger's Inc. Web Power Switch is an IP enabled "power strip" with 8 controlled outlets. Info can be found at http://www.digital-loggers.com.

        I've updated the Web Power Switch script that scott12v developed to work with the current version of Digital Logger's command line tool "UU.exe". Like msieczkowski, I struggled with getting Version 1.0 to work when a device status changed. Finally, I changed the script a bit to operate in a way that made sense to me. I'm sure there are much cleaner ways to do it, but this is what I managed with my very limited VB knowledge combined with scott12v initial code and a bunch of snippets I found in other posts and on VB "help" websites.

        To use the script, you put the script and the UU.exe files in your Homeseer Scripts directory. The script must also be edited to provide values for the following constants:

        - Debug: Constant to Control Debug Setting (True / False)
        - ScriptFileName: Provide the Name of this script that is in the HS3 Scripts Directory
        - WPSURL: URL and Port to WebPower Switch in format "###.###.###.###:####
        - Username: Username for WebPower Switch
        - Password: Provide Password for WebPower Switch
        - NumberOfOutlets: Number of Controlled Outlets on WebPower Switch
        - Room: Value for Location2
        - Category: Value for Location1
        - WPSDeviceName: Base Name for each outlet. Will be appended with outlet number. The inititial device names will be updated to match the WPS outlet names
        - WPSDeviceAddress: Base Device Address Name for each outlet. Will be appended with outlet number
        - DeviceType: DeviceType Name
        - WPSDeviceFunction: DeviceFunction Name

        Version 2.0 of the script has the following functionality:
        - The first time the script is run (manual event) it creates devices for each controlled outlet, sets the device name to match the outlet name stored in the Web Power Switch and finally sets the initial status of each device to match the status of each outlet in the Web Power Switch.

        Click image for larger version

Name:	1 Initialize Event.jpg
Views:	1
Size:	129.5 KB
ID:	1188005

        - When the script is run from an event that triggers when any of the device values changes, it sets the Web Power Switch outlet to match the current device value of ON, OFF, or CYCLE. Additionally the device name is compared to WPS Outlet Name and if it is different the device name is updated to match the WPS Outlet.

        Click image for larger version

Name:	2 Device Value Change Event.JPG
Views:	1
Size:	163.5 KB
ID:	1188006
        Click image for larger version

Name:	3 DeviceList.jpg
Views:	1
Size:	114.4 KB
ID:	1188007

        I am not a programmer either so I agree with scott12v that there are many things in version 2 of the script that aren't done efficiently and could be improved. Feel free to steal this script of any of the associated code for your own use.

        scott12v caveats still stand. The script works well, but there are several things to be aware of:

        1. You cannot hit the On, Off, Cycle buttons too quickly in succession. Wait at least 3 seconds between button presses.

        2. The script does not "detect" changes to the Web Power Switch made outside of Homeseer. In other words, if you use the Web Power Switch's internal web server to turn an outlet on or off, the script will not be aware of this. You could set the script up to poll the outlet status, but I did not choose to do this. I've attached a zip file with the script and UU.exe file.

        Forrest
        Last edited by kesterf; December 4th, 2016, 12:31 PM.

        Comment


        • #5
          I appreciate the effort on the web power switch. I have been a long time HS2 user recently upgraded to HS3. I don't really need buttons in HS3 for the Web Power Switch, but I did want to convert my HS2 scripts for use in HS3.

          A typical HS2 script to control the Web Power Switch is:
          &hs.launch("C:\UU.W32.exe", "ipaddressort userassword 8pulse")
          which would cycle plug 8 after launching UU.W32.exe with the noted parameters. The word pulse can also be replaced by on or off.

          For HS3, I just used the Run Another Program or Process event with the command parameters:
          ipaddressort userassword 8pulse
          and it worked!

          colon followed by p seems to be replaced by in the text above. Sorry for the poor display.

          Comment

          Working...
          X