Announcement

Collapse
No announcement yet.

Event to cycle colors

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

    Event to cycle colors


    #2
    gjelsvik,

    The random function indeed is a bit tricky when you call the randomize function several times in the same time period. That is an issue with all randomizers I know of as they use the time as a base value. If you wait a bit longer the randomize should work better.

    You can use scripting indeed for setting lights to your own needs. In the documentation you'll find more about the scripting details for the plugin. (you can find it here too: http://www.vuyk.info/hs/jowihue/scripting)

    Be aware that the IKEA bulbs work a lot better when you use presets that use xy (Cie Colorspace) values instead of Hue values. If you would convert the Hue values to xy the bulbs would be better in color.

    Wim
    -- Wim

    Plugins: JowiHue, RFXCOM, Sonos4, Jon00's Perfmon and Network monitor, EasyTrigger, Pushover 3P, rnbWeather, BLBackup, AK SmartDevice, Pushover, PHLocation, Zwave, GCalseer, SDJ-Health, Device History, BLGData

    1210 devices/features ---- 392 events ----- 40 scripts

    Comment


      #3
      So with the use of the script function SetLightRGB (xy/cie) will give best result?

      Is there a table somewhere of which rgb values are which colors? Or is it just a matter of try and fail untill I have a result?


      The random function seems to give mostly the same results everytime.. Only red and purple colours.

      Comment


        #4
        gjelsvik,

        If you check the deviceutility page there should be a colorpicker next to the hue device of a Ikea bulb, here you can select the color in rgb to set to the bulb. This should be a reasonable match once ececuted, althoug the Ikea bulbs differ more then the Philips Hue bulbs.

        also, you can pick rgb colors here for example: https://www.w3schools.com/colors/colors_picker.asp

        Wim
        -- Wim

        Plugins: JowiHue, RFXCOM, Sonos4, Jon00's Perfmon and Network monitor, EasyTrigger, Pushover 3P, rnbWeather, BLBackup, AK SmartDevice, Pushover, PHLocation, Zwave, GCalseer, SDJ-Health, Device History, BLGData

        1210 devices/features ---- 392 events ----- 40 scripts

        Comment


          #5
          Sorry for the long delay here, been busy with other things this summer. But now as it gets darker here, this was brought up again.
          So im trying the SetLightsRGB() function.

          First, is there some way to pass the DeviceRef rather than the Devicename? If I choose to change the name (move the bulbs etc) I need to update the script. The deviceref will not be changed unless i replace the bulb/reinstall my system.

          Second, that command, copied right from the documentation:
          Code:
          hs.PluginFunction("JowiHue", "", "SetLightsRGB", {True, "All Lights", Nothing, “255,255,0”, 20})
          Gives this error.
          Running script(2) &hs.PluginFunction("JowiHue", "", "SetLightsRGB", {True, "TV Strip", Nothing, “255,255,0”, 20}), init error: Ugyldig tegn
          ("Ugyldig tegn" translates to "invalid character")

          Comment


            #6
            Are you running this as a script or direct command? If you run this through a script (vb) file, the ampersand (&) has to go.

            Wim
            -- Wim

            Plugins: JowiHue, RFXCOM, Sonos4, Jon00's Perfmon and Network monitor, EasyTrigger, Pushover 3P, rnbWeather, BLBackup, AK SmartDevice, Pushover, PHLocation, Zwave, GCalseer, SDJ-Health, Device History, BLGData

            1210 devices/features ---- 392 events ----- 40 scripts

            Comment


              #7
              Originally posted by w.vuyk View Post
              Are you running this as a script or direct command? If you run this through a script (vb) file, the ampersand (&) has to go.

              Wim
              I`ve tried both. The result in my last post was as a intermediate command.
              Tried to run it as a script now:
              Code:
              Public Sub Main(ByVal param As String)
              hs.PluginFunction("JowiHue", "", "SetLightsRGB", {True, "TV strip", Nothing, "255,255,0", 20})
              End Sub
              Aug-15 23:54:36 JowiHue Warning: Please check parameters with documentation?
              Aug-15 23:54:36 JowiHue Error: (PluginFunction):: calling SetLightsRGB: Målet forårsaket et unntak under aktivering.
              Aug-15 23:54:35 Event Running script in background: C:/Program Files (x86)/HomeSeer HS3/scripts/rndcolor.vb
              Aug-15 23:54:35 Event Event Trigger "Scripts fargetest"
              The error translates to "The target caused an exception during activation"

              Comment


                #8
                omg.. My mistake..
                I had the first parameter to "True", (as in group) but the name is for a specific light, not a group. Changed that to "False" and it didnt throw an error anymore. And the light changed color as it should. So now its just to write up the code to make it cycle the color for each time the script runs.

                So, a bit embarrassed, and so sorry for taking your time.

                Oh, any clever way to pass the device ref instead of name? Or is it just better to do a hs.getDeviceNameByRef() during runtime maybe..

                Comment


                  #9
                  Ok so I have the script and event up and running.
                  Works fine, Im triggering it with the previous/next buttons from an Ikea trådfri remote.

                  "If [name of remote] becomes "next" then run script." (Passing the name of group as parameter)
                  And I use the "previous" button to revert back to normal white light.

                  Code:
                  Public Sub Main(ByVal param As String)
                  dim r,g,b,max,min as Integer
                  max=255
                  min=0
                  randomize
                  
                  r = Int((max-min+1)*Rnd+min)
                  g = Int((max-min+1)*Rnd+min)
                  b = Int((max-min+1)*Rnd+min)
                  dim rgbstring as string = r & "," & g & "," & b
                  hs.writelog("rndcolor", "Lights in: [" &param &"]: color set to: " & rgbstring)
                  hs.PluginFunction("JowiHue", "", "SetLightsRGB", {True, param, Nothing, rgbstring,5})
                  End Sub
                  The problem is that the status of the remote isnt reset, it stays the last status untill next time it changes.
                  This makes it impossible to cycle the to next colour without pressing another button in between each time.

                  The device for the remote is not possible to control through an event, even though it is not set as an "status only" device.
                  My first thought was to "reset" the remote status in the end of my script.

                  Is there any way to achieve this?

                  I have a workaround idea, but its a bit comprehensive, and requires a new VD for every remote, and a extra event for each button.

                  I guess I could use a virtual device, add an event to set it to "1" whenever the remote becomes "next"
                  Then add an event to run my script when the virtual device is set to "1". And in the end of the script I can set the VD back to "0"

                  edit:
                  Didnt work, I just moved the problem. I cant control the VD, since the remote still doesnt change its value after its been set.
                  Last edited by gjelsvik; August 19, 2018, 03:29 PM.

                  Comment


                    #10
                    Originally posted by gjelsvik View Post
                    Ok so I have the script and event up and running.
                    Works fine, Im triggering it with the previous/next buttons from an Ikea trådfri remote.

                    "If [name of remote] becomes "next" then run script." (Passing the name of group as parameter)
                    And I use the "previous" button to revert back to normal white light.

                    Code:
                    Public Sub Main(ByVal param As String)
                    dim r,g,b,max,min as Integer
                    max=255
                    min=0
                    randomize
                    
                    r = Int((max-min+1)*Rnd+min)
                    g = Int((max-min+1)*Rnd+min)
                    b = Int((max-min+1)*Rnd+min)
                    dim rgbstring as string = r & "," & g & "," & b
                    hs.writelog("rndcolor", "Lights in: [" &param &"]: color set to: " & rgbstring)
                    hs.PluginFunction("JowiHue", "", "SetLightsRGB", {True, param, Nothing, rgbstring,5})
                    End Sub
                    The problem is that the status of the remote isnt reset, it stays the last status untill next time it changes.
                    This makes it impossible to cycle the to next colour without pressing another button in between each time.
                    If you are running the script through an Enent Trigger “IF [name of remote] becomes “next””, it will only trigger the first time, because after that its status doesn’t change until a different button is pressed. Try “IF [name of remote] had its value set to “next””. This trigger will work because the value does not need to change. A device set to “next” can be set to “next” again. HS will recognize that the device has been set.
                    HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

                    Comment

                    Working...
                    X