Announcement

Collapse
No announcement yet.

How would you do it

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

  • How would you do it

    Hi,
    I would like to change the status of my HStouch button to red if one of the lights upstrairs are on and if the house is not occupied (I have a device on/off for this). I would like to write a scirpt but I'm not familiar with it. The script would setup a virtual device on/off if one of the lights are off or on. Any help would be greatly appreciated.

  • #2
    do you need to script it? I'd say you could do it with a conditional event evaluating every light and your occupied device in OR groups with the action to control this virtual device. The downside being that conditional events are only evaluated every minute. You would need an opposite event to turn the device off when the house became occupied.

    You could script it if you want but other than being able to run it more frequently I don't see there is a real advantage (??).
    My Plugins:

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

    Comment


    • #3
      I just happen to have a script that does something similar. I've modified it below, but the modified script hasn't been tested, so treat accordingly.

      The script has a list of device codes in an array. Those need to be changed to the codes for your lights. (I'm guessing you don't have 18, so include only the devices you have.)

      The loop index needs to change to reflect the number of devices to check. It's base 0, so 18 devices has a limit of 17.

      The script sets a monitor virtual device (U41 in my example - change it to the address of your device) to Off, then checks to see if any light is on. If in finds one, it sets the monitor device to On and exits the script. If it doesn't find any lights on, then the monitor device will be set to off.

      Code:
      Sub Main(ByVal Params As Object)
      
              '  List of the Device Codes for all monitored lights        
              Dim strSensor_addr() As String = {"A4", "A6", "A12", "A14", "B10", "B12", "B14", "B16", "C4", "C6", "C16", "D12", "F10", "H16", "K10", "K12", "K14", "O16"}
      
              Dim I As Integer
              Dim strAddr As String
              Dim strMonAddr As String = "U41"    ' This is the address of the virtual device that tracks the lights
      
              hs.SetDeviceStatus(strMonAddr, 3)       ' Turn the Monitor Flag off
      
              ' Check each light
              For I = 0 To 17
                  strAddr = strSensor_addr(I)
      
                  ' If the light is on set the monitor device to On and exit
                  If hs.DeviceStatus(strAddr) = 2 Then
                      hs.SetDeviceStatus(strMonAddr, 2)           ' Turn flag on
                      Exit Sub
                  End If
      
              Next 'I
      
          End Sub
      Mike____________________________________________________________ __________________
      HS3 Pro Edition 3.0.0.548

      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


      • #4
        UM,

        I think there is a length property for .vb scripts (vs. the vbs/txt scripts)?

        I found an example in my iconifier script:
        "for i = 0 to ubound(validHCArray)"

        Where that array is processed:
        validHC = hs.getIniSection("ValidHC", "iconIfier.ini")
        validHCArray = split(validHC,chr(0))

        And the ValidHC from the iconifier ini is:

        [ValidHC]
        hc1=^
        hc2=[
        hc3=J
        hc4=Q
        hc5=N
        hc6=F
        hc7=]
        hc7=A


        So, I'm not sure it's a cut and paste, as my "array" is split on chr(0), then on "="...

        Maybe with some effort could make that automatically adjust as items are added/removed?? --course the selfish me is going to need something like that at a later date so it would be nice if someone figured that out

        --Dan
        Tasker, to a person who does Homeautomation...is like walking up to a Crack Treatment facility with a truck full of 3lb bags of crack. Then for each person that walks in and out smack them in the face with an open bag.

        Comment


        • #5
          Thanks to all; the script below would be just perfect.

          Aldo

          Comment


          • #6
            Originally posted by drozwood90 View Post
            Maybe with some effort could make that automatically adjust as items are added/removed??
            Dan,
            I have no experience with that level of script sophistication. I suspect you are correct, but I'm definitely not the person to ask.
            Mike____________________________________________________________ __________________
            HS3 Pro Edition 3.0.0.548

            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

            Working...
            X