Announcement

Collapse
No announcement yet.

Run script on device change?

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

    Run script on device change?

    Is there any way besides making an event for each device?

    I've found "eDeviceAPI.Script" but not had much luck making it work.


    As for what I'm trying to do in case there is another, better way....

    I've purchased some of the sonesse st30-RS485 roller shade motors. I've got a RasPI with a USB-RS485 adapter that's working really well to control them and provide feedback on their status.

    Still trying to figure out the best way to incorporate into HS, current thought is to have 3 devices per shade -- Target position, actual position, and status -- Might do a 4th for error, but that's currently in status.
    I'll a couple more "target position" devices that will point to groups instead of individual shades.

    I'm trying to deal with the target position devices. Currently I have an event that triggers on "changes... any value" than runs a script, and I have to pass the shade address in the parameters.

    But instead of having multiple events, I'd love to have the device trigger the script, and read the shade address from the device that triggered it.

    #2
    Originally posted by wes View Post
    But instead of having multiple events, I'd love to have the device trigger the script, and read the shade address from the device that triggered it.
    I am not aware of a way for a device to "trigger" a script directly. A device change can be used to trigger an event, which then runs a script. The way to make the script aware of which device triggered the event is to have the event pass that information to the script.

    It can be a very simple event, though, which you copy and modify for each trigger.
    Mike____________________________________________________________ __________________
    HS3 Pro Edition 3.0.0.548, NUC i3

    HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

    Comment


      #3
      I found this while digging through the help files....
      http://homeseer.com/support/homeseer...edeviceapi.htm

      "Device launches a script when the value and/or string changes."

      And it will let you specify the script and the sub to run. (ScriptName, ScriptFunc in the help files)
      And when it runs it passes an array of parameters that would let me get the correct address to send to my shade controller and the levels.
      All without having to have several different events, that I have to "hard code" the address in the parameters passed to the script.


      But since it's not working, I'm thinking it must only work if the device is from a plug-in or an API.
      I've been using homeseer almost since their beginning. And have a decent amount of scripting experience, but since they went to HS3, some of the new more advanced functions are a little beyond my scope, (and desire to invest the time to figure them out)

      I'm familiar with doing an event trigger, and how to get all that working,
      I was just hoping to make it a little cleaner on the event side.

      Comment


        #4
        It should work and did work, that is until a recent change to HS event handling broke it and it has not been fixed since. It will work from scripts just fine and that was it's original purpose.

        One option could be to register a script for value change callback (in the documentation), then whenever ANY device in HS changes value the script will be called. Make an early check in that script that the device that has changed is the one you are interested in and you can perform actions as appropriate.

        Comment


          #5
          That worked perfectly, thank you

          I can just do a check on device type string, and call my control script if necessary

          And it will help with a couple other times where I've wanted a range of devices to trigger an event like "all kitchen lights"

          Comment


            #6
            Found this thread while digging around for info on running a script when a device changes value. Does anyone know if "Device launches a script when the value and/or string changes." has been fixed?

            Would like to be able to run a script when a single device changes and not necessarily when any device changes.

            Comment


              #7
              Originally posted by mwolter View Post
              Found this thread while digging around for info on running a script when a device changes value. Does anyone know if "Device launches a script when the value and/or string changes." has been fixed?

              Would like to be able to run a script when a single device changes and not necessarily when any device changes.
              I've not tested it in a while but I've not seen mention of it being fixed so I'd guess not.

              Comment


                #8
                Originally posted by mwolter View Post
                Would like to be able to run a script when a single device changes and not necessarily when any device changes.
                Perhaps I do not understand what you want to do, but there is an option to trigger an event if a specific device changes. If the event has the action to run a script, does that serve your purpose? (The EasyTrigger plug-in expands the trigger options even further.)
                Mike____________________________________________________________ __________________
                HS3 Pro Edition 3.0.0.548, NUC i3

                HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

                Comment


                  #9
                  Programmatically I would like to be able to assign a script to run when a single device changes value. So this would mean not using events or RegisterStatusChangeCB. Oh and not have to create a plugin

                  Comment


                    #10
                    Originally posted by mwolter View Post
                    So this would mean not using events or RegisterStatusChangeCB.
                    Is this a matter of personal preference? What is the motivation?
                    Mike____________________________________________________________ __________________
                    HS3 Pro Edition 3.0.0.548, NUC i3

                    HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

                    Comment


                      #11
                      Originally posted by mwolter View Post
                      Programmatically I would like to be able to assign a script to run when a single device changes value. So this would mean not using events or RegisterStatusChangeCB. Oh and not have to create a plugin
                      Use the ASCII interface programmatically. You may need to enable it under Setup -> Network.

                      HS documentation is located at https://homeseer.com/support/homesee...nk/default.htm
                      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


                        #12
                        Originally posted by Uncle Michael View Post
                        Is this a matter of personal preference? What is the motivation?
                        Both Trying to find a way to run a script by changing the value on a device (clicking the on button) and have that device to script association created by a script. I found the method mentioned in this thread and another even older method (here https://forums.homeseer.com/showthread.php?t=166257 DeviceScriptButton_AddButton) but neither appear to work.

                        My goal is to have devices created based on a received data string from a 3rd party gateway. Then have those same devices send a string to the same gateway when their value changes. Seems pretty simple but I can't find a way to do this short of events or creating my own plugin.

                        Using Druel's IP / Serial program I can get close. With it, devices can be created via a stript and it can also transmit data via a stript but an event would need to be used to link the outbound data to a device value change. Not too fond of adding additional events.

                        I also have it working by using Node Red to translate the data to MQTT but much more software needs to be involved raising the potential for failure.

                        Might look into the ASCII interface but the gateway would need to know the device's ID somehow. Not sure this is any cleaner or less complicated but it should work.

                        Comment


                          #13
                          Originally posted by mwolter View Post
                          Might look into the ASCII interface but the gateway would need to know the device's ID somehow. Not sure this is any cleaner or less complicated but it should work.
                          The gs command will retrieve the device ID (ref) and it's location1 and 2, and device name.

                          Returns a comma list of devices. If the ref parameter is omitted, all devices are returned seperated with a "|", else just information for the requested ref number. Format of return is:

                          ref,parent_ref,status,name,location2,location1
                          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

                          Working...
                          X