Announcement

Collapse
No announcement yet.

Can you run a Powershell script from within an HS4 Event?

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

    Can you run a Powershell script from within an HS4 Event?

    Hi all,

    In HS4, I'm trying to figure out how to do some real simple things such as get a device's value/status and then set a device, all using a Powershell script that is launched via an HS4 event. I've tried to search the forum, but there is nothing specific I am finding on basic HS4 scripting with Powershell. Is Powershell even possible with HS4, or do we have to use VBscript?

    Can anyone point me to information on how to do this? Also, is there a function/script reference guide/document on all the commands which can be used from within a script (i.e. HS4 api or script commands, etc)?

    Really appreciate any help!

    Thanks!
    Brian

    #2
    There are some links on this page to scripting documentation

    http://tenholder.net/tenWare2/tenScr...S4Changes.aspx
    tenholde

    Comment


      #3
      You also have Node Red scripting capabilities. It was recently announced and a subforum was created. If you are experienced with PoweShell, however, I understand the desire to stay there.
      Karl S
      HS4Pro on Windows 10
      1070 Devices
      56 Z-Wave Nodes
      104 Events
      HSTouch Clients: 3 Android, 1 iOS
      Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

      Comment


        #4
        You can execute external programs from an event using the action ":Run Another Program or Process". I am on linux so I do not use powershell.. However, I suspect that the Applicaiton Path is the path + power shell executable and the Parameters are your powershell script with additional parameters.

        I assume powershell can consume web API's and parse json responses. HS4 has a JSON interface where you can get and set device information. You will need to enable this interface capability under Setup -> Remote Control Settings -> Enable Control with JSON

        https://docs.homeseer.com/display/HSPI/JSON+API
        Len


        HomeSeer Version: HS3 Pro Edition 3.0.0.435
        Linux version: Linux homeseer Ubuntu 16.04 x86_64
        Number of Devices: 633
        Number of Events: 773

        Enabled Plug-Ins
        2.0.54.0: BLBackup
        2.0.40.0: BLLAN
        3.0.0.48: EasyTrigger
        30.0.0.36: RFXCOM
        3.0.6.2: SDJ-Health
        3.0.0.87: weatherXML
        3.0.1.190: Z-Wave

        Comment


          #5
          You can easily run external programs, but due to security issues, MS makes it extremely hard to run Powershell scripts from outside of the Powershell cmd line. Google it for work arounds.
          tenholde

          Comment


            #6
            Thanks everyone for your input... greatly appreciated! I did a simple test using JSON within a Powershell script (see the image posted) and it worked to control the color of a Homeseer sensor (HSM-200).

            My next challenge will be to write a script to do the following:
            1. When motion is detected in the kitchen (at nighttime) .... (it's a HSM-200 sensor)
            2. Wait 3 seconds (and make sure the LED is off) [reason I do this is because I may turn on a light within the 3 secs]
            3. Poll or retrieve the light level at that instant (after the 3 seconds)
            4. If it is 0.0, then turn on a light automatically.

            (The above seems hard to do with regular HS4 events and actions, so hence a script)

            If anyone has a solution, please share!

            Thanks again!
            Brian

            Comment


              #7
              Is there more than one light source which may be turned on in the room? If not, why not trigger an event with motion to turn your light on after 3 second? If that light is already on and you send a last level command it change the light.
              Karl S
              HS4Pro on Windows 10
              1070 Devices
              56 Z-Wave Nodes
              104 Events
              HSTouch Clients: 3 Android, 1 iOS
              Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

              Comment


                #8
                Yes Karl thanks, there are many lights in the room which can be turned on independent of this light. The light I want to control is an under-cabinet light which works well in the middle of the night, since it's low light :-).

                Comment


                  #9
                  This could be done with a simple Node Red flow which I could give you with an explanation of the various settings if you are interested. It would require you to install and configure Node Red to run with HomeSeer. If you are interested, let me know. It would use settings from HomeSeer devices and can set the cabinet lights to a hard coded dim level or turn them on at their last value, if the device is capable of such. As I said before, if you are more comfortable stocking with powershell, then that is fine as well.
                  Karl S
                  HS4Pro on Windows 10
                  1070 Devices
                  56 Z-Wave Nodes
                  104 Events
                  HSTouch Clients: 3 Android, 1 iOS
                  Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

                  Comment


                    #10
                    Originally posted by KBF100 View Post

                    My next challenge will be to write a script to do the following:
                    1. When motion is detected in the kitchen (at nighttime) .... (it's a HSM-200 sensor)
                    2. Wait 3 seconds (and make sure the LED is off) [reason I do this is because I may turn on a light within the 3 secs]
                    3. Poll or retrieve the light level at that instant (after the 3 seconds)
                    4. If it is 0.0, then turn on a light automatically.
                    This can be done with 2 events. First, create a "turn kitchen light on" event:
                    If this event is manually triggered
                    and if "kitchen light" has a value equal to Off
                    then set "kitchen light" to on

                    Now, create the motion sensor controlled event:
                    if motion is detected
                    then wait 3 seconds
                    then Poll "kitchen light" for status (if this is zwave, there is a "zwave actions" option near the bottom of the list)
                    then if the event conditions are true, run event "turn kitchen light on"

                    You must enable the "Check conditions on target event" on the last step
                    Len


                    HomeSeer Version: HS3 Pro Edition 3.0.0.435
                    Linux version: Linux homeseer Ubuntu 16.04 x86_64
                    Number of Devices: 633
                    Number of Events: 773

                    Enabled Plug-Ins
                    2.0.54.0: BLBackup
                    2.0.40.0: BLLAN
                    3.0.0.48: EasyTrigger
                    30.0.0.36: RFXCOM
                    3.0.6.2: SDJ-Health
                    3.0.0.87: weatherXML
                    3.0.1.190: Z-Wave

                    Comment


                      #11
                      Originally posted by lveatch View Post

                      This can be done with 2 events. First, create a "turn kitchen light on" event:
                      If this event is manually triggered
                      and if "kitchen light" has a value equal to Off
                      then set "kitchen light" to on

                      Now, create the motion sensor controlled event:
                      if motion is detected
                      then wait 3 seconds
                      then Poll "kitchen light" for status (if this is zwave, there is a "zwave actions" option near the bottom of the list)
                      then if the event conditions are true, run event "turn kitchen light on"

                      You must enable the "Check conditions on target event" on the last step
                      Yes thanks, technically that solution would work and I had something similar prior to HS4, but there are several lights to check and these lights are all UPB, and for some reason, after the HS4 upgrade, checking or polling to determine if a UPB light is ON or OFF, did not work anymore. I'm not sure if it is related to the UPB plug-in, the UPB link commands, or something else. So until I can determine why that is not working, I'll need another solution.

                      Comment


                        #12
                        KBF100 Does the light sensor update a HomeSeer device when the light level changes? If not, what are you using to get the light level?
                        Karl S
                        HS4Pro on Windows 10
                        1070 Devices
                        56 Z-Wave Nodes
                        104 Events
                        HSTouch Clients: 3 Android, 1 iOS
                        Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

                        Comment


                          #13
                          Originally posted by ksum View Post
                          KBF100 Does the light sensor update a HomeSeer device when the light level changes? If not, what are you using to get the light level?
                          OK - so here's what I discovered.... (the issue was the UPB link)

                          I was planning to use the HSM-200 luminance level to detect if a light in the room was on vs. polling the (entry) (UPB) lights (LIGHTS #1 and #2) for ON/OFF status (because the polling was inaccurate and not working... I would turn on LIGHT #1 at the switch, but Homeseer didn't recognize it... it only recognizes it when HS4 controls the light) BUT.... I discovered that you absolutely must have a UPB link (scene) created for each UPB light to detect the proper ON/OFF status in Homeseer. Once I created a link for each light and updated the homeseer.upe export file, it worked without using the Luminance device. Without that UPB link created for the light, homeseer will not properly 'read' the status of the UPB device IF you control the switch MANUALLY. Once I fixed that, polling the ON/OFF status of the lights now works (for LIGHTS #1 and #2) ... if they are ON, then I do not turn on LIGHT #3.

                          I may experiment with the Luminance further, but I was not real sure about the Luminance values on this device, it seems really low with only a value of 11.0 in the daytime! When I shined a flashlight in it, it went to 7000! So, I suppose you have to experiment with the device to determine appropriate light levels.

                          Sorry for all the confusion, but I've never played around with Luminance and was trying to get that to work, but I obviously have more reading and experimentation to do with the Luminance feature.

                          You have all be very helpful. Thank you.

                          -Brian

                          Comment


                            #14
                            Originally posted by KBF100 View Post
                            Sorry for all the confusion, but I've never played around with Luminance and was trying to get that to work, but I obviously have more reading and experimentation to do with the Luminance feature.
                            Just in case you didn't know - you must have hysteresis (gap) in you Luminance on/off values - i.e. switch on the lights at 100 Lm but back off at 150. Otherwise you get unpleasant flashing around threshold.

                            Comment

                            Working...
                            X