Announcement

Collapse
No announcement yet.

Device Script Buttons

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

    Device Script Buttons

    I know you can create a virtual device and add a Device Script Button that will trigger a script.
    But is it also possible when you add a slider to the device (in the Status Graphics of the device), to let the slider trigger a script?

    I have multiple Chromoflex units I can set with a script.
    I want to control them with devices.
    So when I set a slider of a device to 205, it will trigger a script with the device reference id and slider value.
    The script will then set the right Chromoflex to the right value.
    I know there is a Chromoflex plugin to do the job. But the plugin works with only 1 com port.
    I use 3 com ports at the moment, to trigger 20 Chromoflex units.
    Peter

    http://ohh.pcgsm.nl

    #2
    Hi Peter

    As you know I am the author of the Chromoflex PI. Just had a thought: If you wanted I could compile the plug-in twice more, both with different names (e.g. Chromoflex2 and Chromoflex3). You would then save those two PIs in the HS3 folder and effectively you should have three "different" PIs that can each control a different port.

    Let me know if you are interested?
    Nicolai L

    Comment


      #3
      Originally posted by NicolaiL View Post
      Hi Peter

      As you know I am the author of the Chromoflex PI. Just had a thought: If you wanted I could compile the plug-in twice more, both with different names (e.g. Chromoflex2 and Chromoflex3). You would then save those two PIs in the HS3 folder and effectively you should have three "different" PIs that can each control a different port.

      Let me know if you are interested?
      Yes! That will be a good solution.
      Thanks!

      Verstuurd vanaf mijn SM-G900F met Tapatalk
      Peter

      http://ohh.pcgsm.nl

      Comment


        #4
        OK. Here you go. I have not tested this so proceed with caution and at your own risk!!

        I changed all references in my source code and also changed the GUID.

        Let me know how you get on.
        Attached Files
        Nicolai L

        Comment


          #5
          Originally posted by NicolaiL View Post
          OK. Here you go. I have not tested this so proceed with caution and at your own risk!!

          I changed all references in my source code and also changed the GUID.

          Let me know how you get on.
          Works perfect!
          Thanks!
          Peter

          http://ohh.pcgsm.nl

          Comment


            #6
            Glad I could help!
            Nicolai L

            Comment


              #7
              Hi Nicolai,

              I am configuring my events to use your plugin.
              I know you can also set the transition time to go from one level to an other level. I used to use 2 settings, fast (1) to switch a light on immediately and slow (255) to switch lights off or to go to a different color for the RGB leds.

              How can I set these transition times in an event?

              Also when I quit HS, the lights will go out.
              When I start HS the levels for the lights are still in the devices, but the lights are still out.
              With my script I saved the levels in an ini file when I changed them and ran the levels in the ini file every 15 minutes.
              That way the levels always went back to the level I had set with HS. Also when I changed the levels with CF_edit for demo, within 15 minutes all was back to the HS levels.
              Is it possible to add something like this (an alternative status request) to your plugin?
              Last edited by peterpc; October 19, 2015, 04:45 PM.
              Peter

              http://ohh.pcgsm.nl

              Comment


                #8
                Hi Peter

                Although I never documented it I actually built in some public functions you can call which might do what you want.

                In your events you can do an action to "Run Another Script", then chose Immediate Script Command. Then you can call the functions below using thnis format:

                &hs.plugin("izChromoflex").PROCNAME(PARAMETERS)

                The calls you have are:

                apiTakeControl(ByRef GroupID As Integer)

                apiReleaseControl(ByRef GroupID As Integer)

                SetColourBurst(ByRef GroupID As Integer, R As Integer, G As Integer, B As Integer)

                SetColourIncrement(ByRef GroupID As Integer, R As Integer, G As Integer, B As Integer)

                SetTransitionSpeed(ByRef GroupID As Integer, R As Integer, G As Integer, B As Integer)

                I don't use these myself and can't remember if I tested them, so have a play and see if they work for you.

                There is no way to do a "status request" because the Chromoflexes themselves do not send *any* communication back in response, so there is no way to ask for current settings.

                Hope this helps.
                Nicolai L

                Comment


                  #9
                  Should &hs.plugin(..... not be &hs.pluginfunction(...... ?

                  I tried this:
                  &hs.pluginFunction("izChromoflex", "", "SetTransitionSpeed", " 0, 1, 1, 1")
                  But that gives this error:
                  Running script(2) &hs.pluginFunction("izChromoflex", "", "SetTransitionSpeed", " 0, 1, 1, 1"), init error: Invalid procedure call or argument: 'hs.pluginFunction'

                  Can you give me an example?
                  Peter

                  http://ohh.pcgsm.nl

                  Comment


                    #10
                    Hi Peter

                    I think I've fixed the issue with the plug-in calls. Download the latest version from the updater.

                    The correct formatter for invoking from an event is:

                    &nhs.PluginFunction("izChromoflex", "", "SetColourIncrement", {"1, 152, 153, 154"})

                    Let me know if that works for you. I can then apply the same fix to the two "special" plug-ins for the extra COM port support.
                    Nicolai L

                    Comment


                      #11
                      Installed the update 3.0.2.0.
                      Run this script:
                      &hs.PluginFunction("izChromoflex", "", "SetTransitionSpeed", {"0, 1, 1, 1"})

                      gives me this error:
                      Running script(2) &hs.PluginFunction("izChromoflex", "", "SetTransitionSpeed", {"0, 1, 1, 1"}), init error: Invalid character

                      I think that for Transitionspeed you only need 2 parameters (address 0...8 and speed) , but also then I get the same error.
                      Peter

                      http://ohh.pcgsm.nl

                      Comment


                        #12
                        Originally posted by peterpc View Post
                        Installed the update 3.0.2.0.
                        Run this script:
                        &hs.PluginFunction("izChromoflex", "", "SetTransitionSpeed", {"0, 1, 1, 1"})

                        gives me this error:
                        Running script(2) &hs.PluginFunction("izChromoflex", "", "SetTransitionSpeed", {"0, 1, 1, 1"}), init error: Invalid character

                        I think that for Transitionspeed you only need 2 parameters (address 0...8 and speed) , but also then I get the same error.
                        You have the wrong syntax. Although it looks like a typo the correct call is &nhs not &hs. This forces HS3 to use .NET

                        Try this and let me know.
                        Nicolai L

                        Comment


                          #13
                          If I send this:
                          &nhs.PluginFunction("izChromoflex", "", "SetColourIncrement", {"3, 10, 10, 10"})
                          I get this error 12 times:

                          Oct-22 21:15:57 izChromoflex ERROR Failed to send data to COM port
                          Oct-22 21:15:57 izChromoflex ERROR COM port error: sendString: The port is closed.

                          If I send this:
                          &nhs.PluginFunction("izChromoflex", "", "SetTransitionSpeed", {"3,1"})
                          I get no error, but no data is send to the com port.
                          Peter

                          http://ohh.pcgsm.nl

                          Comment


                            #14
                            Believe it or not that required a larger rewrite than I had expected. I have attached a beta here, which will hopefully work.

                            Note that the transition speed call requires four parameters (see previous note above).
                            Attached Files
                            Nicolai L

                            Comment


                              #15
                              No errors in the log, but time to get ON/ OFF is the same for both events and around 2 seconds:
                              Attached Files
                              Peter

                              http://ohh.pcgsm.nl

                              Comment

                              Working...
                              X