Announcement

Collapse
No announcement yet.

Set Hue Brightness via Link?

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

  • Set Hue Brightness via Link?

    Hi Spud,

    I am using the JowiHue plugin to control some Hue bulbs. I have a group of them on a UPB controlled switch. Currently the switch is set to activate and deactivate a link. And I use events to control the bulbs. This basically limits them to on/off though with no dimming. What I would like to do is to set the toggle to a super toggle to control the link, and have snap on, dim, and snap off transmitted from the UPB link to the Hue brightness for the group.

    I was going to ask this question in the JowiHue forum, but it seems that this would be more of a UPB feature.

    Do you have any ideas on how to do this?
    _______________________________________________

    HS3 : HSpro (3.0.0.460) on Win2012 (vm on ESXi)
    Plugins: HSTouch, UPBSpud, Kinect, Nest, IFTTT, DirecTV, EasyTrigger, Imperihome, Zwave, RFXcom, UltraMon3, UltraWeatherBug3, UltraGCIR3, UltraLog3, UltraPioneer, PHLocation, Pushover, Pushalot, MCSSPrinklers S, JowiHue
    Jon00 Plugins: Bluetooth Proximity, Performance Monitor, DB Chart, Links

  • #2
    you can use the UPB link device status to trigger a Hue action.

    IF "UPB link device" changes and become "snap on"
    THEN do something with your Hue lights

    am I missing something?

    Comment


    • #3
      "Snap on" is easy dimming is hard.
      _______________________________________________

      HS3 : HSpro (3.0.0.460) on Win2012 (vm on ESXi)
      Plugins: HSTouch, UPBSpud, Kinect, Nest, IFTTT, DirecTV, EasyTrigger, Imperihome, Zwave, RFXcom, UltraMon3, UltraWeatherBug3, UltraGCIR3, UltraLog3, UltraPioneer, PHLocation, Pushover, Pushalot, MCSSPrinklers S, JowiHue
      Jon00 Plugins: Bluetooth Proximity, Performance Monitor, DB Chart, Links

      Comment


      • #4
        well, for dimming you just need a simple script that retrieves the UPB link device value, and set your Hue light accordingly.

        Comment


        • #5
          That makes sense. I'd been thinking along the same lines. The problem is how to use the "snap on/off" from double taps, and the hold to set dim level together in one script? Are you suggesting multiple events to handle snap and dim separately? If you have an example script for dim for at least the UPB side it would be really helpful for me.
          _______________________________________________

          HS3 : HSpro (3.0.0.460) on Win2012 (vm on ESXi)
          Plugins: HSTouch, UPBSpud, Kinect, Nest, IFTTT, DirecTV, EasyTrigger, Imperihome, Zwave, RFXcom, UltraMon3, UltraWeatherBug3, UltraGCIR3, UltraLog3, UltraPioneer, PHLocation, Pushover, Pushalot, MCSSPrinklers S, JowiHue
          Jon00 Plugins: Bluetooth Proximity, Performance Monitor, DB Chart, Links

          Comment


          • #6
            this C# script works

            Code:
            public object Main(object[] parms)
            {
                int upbLinkRef =  3593;
                int value = (int)hs.DeviceValueEx(upbLinkRef);
                
                if(value ==  -4)
                {
                    hs.Speak("Snap On");
                }
                else if(value ==  -3)
                {
                    hs.Speak("Snap Off");
                }
                else if(value>=1 && value<=99)
                {
                    hs.Speak(String.Format("Dim {0} percent", value));
                }
            
                return 0;
            }
            copy this code in a .cs file in your script directory, replace 3593 with the ref of your link device
            then create an event like

            IF <your link device> has a value that just changed.
            THEN run the C# script

            then if it works like you want replace the speak function by an action on your Hue lights.

            Comment


            • #7
              Thanks for the example. I'm not sure how to set a group of hue lights on or off via scripting, as it is not covered in the JowiHue documentation. I will ask over there. The documentation does have a method for setting the brightness of a group of hue lights. The brightness is a value from 1-255. Does my modification of your script look correct for setting the brightness based on dim value? In case it is not obvious I am not that handy with code. I really appreciate your help!

              Code:
              public object Main(object[] parms)
              {
                  int upbLinkRef =  3593;
                  int value = (int)hs.DeviceValueEx(upbLinkRef);
                  int huebright = value*2.6-1.6
                  if(value ==  -4)
                  {
                      hs.Speak("Snap On");
                  }
                  else if(value ==  -3)
                  {
                      hs.Speak("Snap Off");
                  }
                  else if(value>=1 && value<=99)
                  {
                      hs.PluginFunction("JowiHue", "", "SetLightsHueSat", {True, "Master Bath", huebright, Nothing, Nothing, Nothing});
                  }
              
                  return 0;
              }
              _______________________________________________

              HS3 : HSpro (3.0.0.460) on Win2012 (vm on ESXi)
              Plugins: HSTouch, UPBSpud, Kinect, Nest, IFTTT, DirecTV, EasyTrigger, Imperihome, Zwave, RFXcom, UltraMon3, UltraWeatherBug3, UltraGCIR3, UltraLog3, UltraPioneer, PHLocation, Pushover, Pushalot, MCSSPrinklers S, JowiHue
              Jon00 Plugins: Bluetooth Proximity, Performance Monitor, DB Chart, Links

              Comment


              • #8
                you have to cast to int, and you forgot a semi colon at the end of the instruction
                Code:
                int huebright = (int)(value*2.6-1.6);
                otherwise it looks ok

                Comment


                • #9
                  OK This is my revised script:

                  Code:
                  public object Main(object[] parms)
                  {
                      int upbLinkRef =  1391;
                      int value = (int)hs.DeviceValueEx(upbLinkRef);
                      int huebright = (int)(value*2.6-1.6);
                      if(value ==  -4)
                      {
                          hs.PluginFunction("JowiHue", "", "SetLightsHueSat", {True, "Master Bath", 255, Nothing, Nothing, Nothing});
                      }
                      else if(value ==  -3)
                      {
                          hs.PluginFunction("JowiHue", "", "SetLightsOff", {True, "Master Bath"});
                      }
                      else if(value>=1 && value<=99)
                      {
                          hs.PluginFunction("JowiHue", "", "SetLightsHueSat", {True, "Master Bath", huebright, Nothing, Nothing, Nothing});
                      }
                  
                      return 0;
                  }
                  When I attempt to run it I see this in the log:

                  Code:
                  Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\UPBtoHUE_MB.cs: {interactive}(25,60): error CS1525: Unexpected symbol `{' {interactive}(25,65): error CS1525: Unexpected symbol `,' {interactive}(25,68): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement {interactive}(25,80): error CS1525: Unexpected symbol `,' {interactive}(25,83): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement {interactive}(25,85): error CS1525: Unexpected symbol `,' {interactive}(25,94): error CS1525: Unexpected symbol `,' {interactive}(25,103): error CS1525: Unexpected symbol `,' {interactive}(25,112): error CS1525: Unexpected symbol `}' {interactive}(25,113): error CS1525: Unexpected symbol `)' {interactive}(33,57): error CS1525: Unexpected symbol `{' {interactive}(33,62): error CS1525: Unexpected symbol `,' {interactive}(33,65): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement {interactive}(33,77): error CS1525: Unexpected symbol `}' {interactive}(33,78): error CS1525: Unexpected symbol `)' {interactive}(41,60): error CS1525: Unexpected symbol `{' {interactive}(41,65): error CS1525: Unexpected symbol `,' {interactive}(41,68): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement {interactive}(41,80): error CS1525: Unexpected symbol `,' {interactive}(41,91): error CS1525: Unexpected symbol `,' {interactive}(41,100): error CS1525: Unexpected symbol `,' {interactive}(41,109): error CS1525: Unexpected symbol `,' {interactive}(41,118): error CS1525: Unexpected symbol `}' {interactive}(41,119): error CS1525: Unexpected symbol `)' {interactive}(2,1): warning CS0105: The using directive for `System' appeared previously in this namespace {interactive}(3,1): warning CS0105: The using directive for `System.Linq' appeared previously in this namespace {interactive}(4,1): warning CS0105: The using directive for `Scheduler' appeared previously in this namespace {interactive}(5,1): warning CS0105: The using directive for `HomeSeerAPI' appeared previously in this namespace
                  Is this a result of mixing vbscript example from JowiHue with your c# example? When I run your example at the top it runs fine after I change the ref ID to mine.
                  Last edited by jlrichar; October 4th, 2015, 01:14 PM.
                  _______________________________________________

                  HS3 : HSpro (3.0.0.460) on Win2012 (vm on ESXi)
                  Plugins: HSTouch, UPBSpud, Kinect, Nest, IFTTT, DirecTV, EasyTrigger, Imperihome, Zwave, RFXcom, UltraMon3, UltraWeatherBug3, UltraGCIR3, UltraLog3, UltraPioneer, PHLocation, Pushover, Pushalot, MCSSPrinklers S, JowiHue
                  Jon00 Plugins: Bluetooth Proximity, Performance Monitor, DB Chart, Links

                  Comment


                  • #10
                    Originally posted by jlrichar View Post
                    Is this a result of mixing vbscript example from JowiHue with your c# example? .
                    probably, try this:

                    Code:
                    public object Main(object[] parms)
                    {
                        int upbLinkRef =  1391;
                        int value = (int)hs.DeviceValueEx(upbLinkRef);
                        int huebright = (int)(value*2.6-1.6);
                        if(value ==  -4)
                        {
                            hs.PluginFunction("JowiHue", "", "SetLightsHueSat", new object[] {true, "Master Bath", 255, null, null, null});
                        }
                        else if(value ==  -3)
                        {
                            hs.PluginFunction("JowiHue", "", "SetLightsOff", new object[] {true, "Master Bath"});
                        }
                        else if(value>=1 && value<=99)
                        {
                            hs.PluginFunction("JowiHue", "", "SetLightsHueSat", new object[] {true, "Master Bath", huebright, null, null, null});
                        }
                    
                        return 0;
                    }

                    Comment


                    • #11
                      A little bit of success. When I snap on the lights turn on. Though when I snap off, or hold to set level I see no change in the light and a bunch of "running script in background" entries in the log for this event. Under the event action I selected "only allow one instance at a time" I did not select "immediate script command" though--should I?


                      Edit: It looks like both snap on and off works well. The jowiHue lights off command is not working. The dim is not working anywhere, even in the test script at the top of this thread. I am using the standard rocker in UPB upstart.
                      Last edited by jlrichar; October 4th, 2015, 02:06 PM.
                      _______________________________________________

                      HS3 : HSpro (3.0.0.460) on Win2012 (vm on ESXi)
                      Plugins: HSTouch, UPBSpud, Kinect, Nest, IFTTT, DirecTV, EasyTrigger, Imperihome, Zwave, RFXcom, UltraMon3, UltraWeatherBug3, UltraGCIR3, UltraLog3, UltraPioneer, PHLocation, Pushover, Pushalot, MCSSPrinklers S, JowiHue
                      Jon00 Plugins: Bluetooth Proximity, Performance Monitor, DB Chart, Links

                      Comment


                      • #12
                        well, if my first script with the Speak actions works, then the problem is probably on the Hue side.

                        for debugging you can add some debug statements like the following to see the value that is sent to the Hue function

                        hs.WriteLog("UPBtoHUE Script", "huebright = " + huebright);

                        Comment


                        • #13
                          Originally posted by spud View Post
                          well, if my first script with the Speak actions works, then the problem is probably on the Hue side.

                          for debugging you can add some debug statements like the following to see the value that is sent to the Hue function

                          hs.WriteLog("UPBtoHUE Script", "huebright = " + huebright);
                          When I retested your first script it did not work for the third speak command, only for snap on and snap off. Sorry, I got excited when it worked for snap on and off and proclaimed it working. That test did not have the huebright variable, so even if that is also broken there seems to be something else broken. I will run a few more tests.
                          _______________________________________________

                          HS3 : HSpro (3.0.0.460) on Win2012 (vm on ESXi)
                          Plugins: HSTouch, UPBSpud, Kinect, Nest, IFTTT, DirecTV, EasyTrigger, Imperihome, Zwave, RFXcom, UltraMon3, UltraWeatherBug3, UltraGCIR3, UltraLog3, UltraPioneer, PHLocation, Pushover, Pushalot, MCSSPrinklers S, JowiHue
                          Jon00 Plugins: Bluetooth Proximity, Performance Monitor, DB Chart, Links

                          Comment


                          • #14
                            when you try to dim from your switch, does your link device status is correctly set to "Dim X%"

                            Comment


                            • #15
                              Originally posted by spud View Post
                              when you try to dim from your switch, does your link device status is correctly set to "Dim X%"
                              No! When I use the slider to dim the link it dims. The switch does not dim the link. In upstart I have dimming enabled, though in the HS link device it is set as a non-dimmable device. What did I do wrong here? I have other links that do dim.
                              _______________________________________________

                              HS3 : HSpro (3.0.0.460) on Win2012 (vm on ESXi)
                              Plugins: HSTouch, UPBSpud, Kinect, Nest, IFTTT, DirecTV, EasyTrigger, Imperihome, Zwave, RFXcom, UltraMon3, UltraWeatherBug3, UltraGCIR3, UltraLog3, UltraPioneer, PHLocation, Pushover, Pushalot, MCSSPrinklers S, JowiHue
                              Jon00 Plugins: Bluetooth Proximity, Performance Monitor, DB Chart, Links

                              Comment

                              Working...
                              X