Announcement

Collapse
No announcement yet.

Dim with the Cube.

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

    Dim with the Cube.

    Hello

    Just godt the rotation to work with my Xiaomi cube.
    When rotation the cube, i can get values from -360 -> 360.

    I would like to take these values and use them in a dim function.
    So the more i rotate the Cube, the more it dims a light.

    Can someone help with some script that can do that?

    #2
    IdPlusse was that a software update as mine hasn't changed recently?

    Steve

    Originally posted by ldplusse View Post
    Hello

    Just godt the rotation to work with my Xiaomi cube.
    When rotation the cube, i can get values from -360 -> 360.

    I would like to take these values and use them in a dim function.
    So the more i rotate the Cube, the more it dims a light.

    Can someone help with some script that can do that?

    Comment


      #3
      Steve,

      If you check https://www.dresden-elektronik.de/deconz/win/ you will find 2.05.00 there as latest version. This solve the rotation cube not changing values and probably several other issues people with the ConBee are seeing. This is an important update all ConBee users should install.

      Lars,

      Here is a quick and (real) dirty script I am using here to control the dim value of devices, depending on the side up from the cube.
      • Dimmax should be set according on the dim choise made in the configuration page. If you use percentage, 100 is correct, otherwise 255
      • Side is the device reference id for a virtual device that I created to know which side of the cube is up (event controlled)
      • Lights is an array reference id's of bulbs (or groups if you like) in sequence of the cube's side you want to control. First value shoud stay 0.
      • Rotation is the device value of the rotation device (adjust the reference id!)


      Again, it is a rough script, but it might push you in the right direction.

      Code:
      Sub Main(parms As Object)
          Try
              Dim DimMax As Integer = 100
              Dim Side As Integer = hs.devicevalue(4526)
              Dim Lights() As Integer = {0, 2888, 2900, 4450, 4454, 2508, 2524}
              Dim CurrentDimValue As Integer = hs.devicevalue(Lights(Side))
              Dim Rotation As Integer = hs.devicevalue(4524) 
              Dim DimNew As Integer = CurrentDimValue
              Dim cc As HomeSeerAPI.CAPIControl = hs.CAPIGetSingleControlbyuse(Lights(Side), 3) ' True, "Dim", False, True)
              DimNew = CurrentDimValue + ((Rotation / 360) * DimMax)
              If DimNew >= DimMax Then DimNew = DimMax
              If DimNew < 1 Then DimNew = 1
              '  hs.setdevicevaluebyref(Lights(Side), DimNew, True)
              cc.ControlValue = DimNew
              Dim cr As HomeSeerAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)
          Catch ex As exception
              hs.writelog("Kubus", ex.message)
          End Try
      
      End Sub
      -- 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


        #4
        I tried to use a modified version of your script without the side thing but it seems like the light sometimes shortly dims into the wrong direction. Any suggestions?

        Comment


          #5
          Thanks for the script.
          Got it working.

          Is there a way to parse some info to the script from the '"Sub or Function:" and "Parameters:"
          This is my first script on HS.
          Last edited by ldplusse; February 3, 2018, 06:09 PM.

          Comment


            #6
            Originally posted by ldplusse View Post
            Thanks for the script.
            Got it working.

            Is there a way to parse some info to the script from the '"Sub or Function:" and "Parameters:"
            This is my first script on HS.
            Lars,

            What would you like to do? Passing parameters to this specific script is not needed as it is getting the info from the rotation device? Or is there something else you want to add to it?

            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 superwerder View Post
              I tried to use a modified version of your script without the side thing but it seems like the light sometimes shortly dims into the wrong direction. Any suggestions?
              The cube is quite sensitive with sending the rotation values. So if you touch the cube and even twist it a bit to the wrong direction it will trigger the script already. so it might trigger twice if you fllow up with twitsting into the direction you want? I saw this in the beginning too, but did not notice it anymore lately. Maybe I got used to it, or are now taking the cube with the right movement?

              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

              Working...
              X