Announcement

Collapse
No announcement yet.

Issue with Reported State Change for Up/Down Fan Lights

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

    Issue with Reported State Change for Up/Down Fan Lights

    Multiple (some erroneous) state messages appear in log when HS changes the state of lights with a fan with an Up and Down light (see log below). When I turn on a "DownLight" on, AK Bond can report that the down light went OFF when it is already OFF, then went ON and the UpLight went ON when it is actually OFF, then went OFF when it was OFF all along.

    To duplicate this

    1. start with both lights ON,
    2. then turn the down light OFF,
    3. then turn the UP light OFF. This should leave Bond in the state shown at the bottom of this post: "light":1,"up_light":0,"down_light":1
    4. Then turn the down light ON.

    The HS device ICONs are correct at every step, but some of the the logged changes are incorrect. I assume this is because of the way you are dealing with the three lights (UpLight, DownLight, and Light) when there are really only two physical lights (UpLight and DownLight) and Light is a odd combination of UpLight and DownLIght.

    AK Bond ANDs the state of Light with UpLight and DownLight to reflect the state of the physical lights so it can set the HS ICONs properly (which it does correctly). I'm guessing that you are registering a state change before you do the AND and that is what is causing the problem. And that is further confused by reporting the state of the UpLight and DownLight whenever Light changes state.

    I suppose you could consider this a "who cares" scenario as it does not effect the functioning of the device and in the end the state reporting is correct. However, it is confusing when trying to use the log to determine if events are working properly (the main reason for having the log in my opinion).
    Code:
     [TABLE]
    [TR]
    [TD="align: left"]Mar-03 11:14:13 AM[/TD]
     			[TD="align: left"] [/TD]
     			[TD="colspan: 3, align: left"]AK Bond[/TD]
     			[TD="colspan: 8, align: left"][648]: Device: Sue's Fan Down Light Set to -18 (TurnDownLightOn)[/TD]
     		[/TR]
    [/TABLE]
    [TABLE]
    [TR]
    [TD="align: left"]Mar-03 11:14:13 AM[/TD]
     			[TD="align: left"] [/TD]
     			[TD="colspan: 3, align: left"]AK Bond[/TD]
     			[TD="colspan: 8, align: left"][640]: ValueChanged 'down_light': 1 (old 0)[/TD]
     		[/TR]
    [/TABLE]
    [TABLE]
    [TR]
    [TD="align: left"]Mar-03 11:14:13 AM[/TD]
     			[TD="align: left"] [/TD]
     			[TD="colspan: 3, align: left"]AK Bond[/TD]
     			[TD="colspan: 8, align: left"][646]: Device: Sue's Fan Up Light Set to -15 (TurnUpLightOff)[/TD]
     		[/TR]
    [/TABLE]
    [TABLE]
    [TR]
    [TD="align: left"]Mar-03 11:14:13 AM[/TD]
     			[TD="align: left"] [/TD]
     			[TD="colspan: 3, align: left"]AK Bond[/TD]
     			[TD="colspan: 8, align: left"][640]: ValueChanged 'up_light': 0 (old 1)[/TD]
     		[/TR]
    [/TABLE]
    [TABLE]
    [TR]
    [TD="align: left"]Mar-03 11:14:13 AM[/TD]
     			[TD="align: left"] [/TD]
     			[TD="colspan: 3, align: left"]AK Bond[/TD]
     			[TD="colspan: 8, align: left"][648]: Device: Sue's Fan Down Light Set to -19 (TurnDownLightOff)[/TD]
     		[/TR]
    [/TABLE]
    [TABLE]
    [TR]
    [TD="align: left"]Mar-03 11:14:13 AM[/TD]
     			[TD="align: left"] [/TD]
     			[TD="colspan: 3, align: left"]AK Bond[/TD]
     			[TD="colspan: 8, align: left"][646]: Device: Sue's Fan Up Light Set to -14 (TurnUpLightOn)[/TD]
     		[/TR]
    [/TABLE]
    [TABLE]
    [TR]
    [TD="align: left"]Mar-03 11:14:13 AM[/TD]
     			[TD="align: left"] [/TD]
     			[TD="colspan: 3, align: left"]AK Bond[/TD]
     			[TD="colspan: 8, align: left"][640]: ValueChanged 'light': 1 (old 0)[/TD]
     		[/TR]
    [/TABLE]
    [TABLE]
    [TR]
    [TD="align: left"]Mar-03 11:14:13 AM[/TD]
     			[TD="align: left"] [/TD]
     			[TD="colspan: 3, align: left"]AK Bond[/TD]
     			[TD="colspan: 8, align: left"][480]: BPUP status update: {"B":"ZZCC69147","t":"devices/27a50892/state","i":"0500006436c8e6df","f":100,"s":200,"m":0,"b":{"po wer":0,"speed":1,"light":1,"up_light":0,"down_light":1,"_": " 6e0e2edb"}}[/TD]
     		[/TR]
    [/TABLE]
    [TABLE]
    [TR]
    [TD="align: left"]Mar-03 11:14:12 AM[/TD]
     			[TD="align: left"] [/TD]
     			[TD="colspan: 3, align: left"]AK Bond[/TD]
     			[TD="colspan: 8, align: left"][480]: Execute cmd: /v2/devices/27a50892/actions/TurnDownLightOn/[/TD]
     		[/TR]
    [/TABLE]
    [TABLE]
    [TR]
    [TD="align: left"]Mar-03 11:14:12 AM[/TD]
     			[TD="align: left"] [/TD]
     			[TD="colspan: 3, align: left"]Device Control[/TD]
     			[TD="colspan: 8, align: left"]Device: Bond Sue's Room Sue's Fan Down Light to On (-18) by/from: CAPI Control Handler[/TD]
     		[/TR]
    [/TABLE]
    .
    Bond state before the ON command
    Code:
        [TABLE]
    [TR]
    [TD="align: left"]Mar-03 11:13:58 AM[/TD]
     			[TD="align: left"] [/TD]
     			[TD="colspan: 3, align: left"]AK Bond[/TD]
     			[TD="colspan: 8, align: left"][480]: BPUP status update: {"B":"ZZCC69147","t":"devices/27a50892/state","i":"050000fbf0fc9499","f":100,"s":200,"m":0,"b":{"po wer":0,"speed":1,"light":0,"up_light":1,"down_light":0,"_": " 1fba4a5a"}}[/TD]
     		[/TR]
    [/TABLE]

    #2
    Than you Chris.

    I "couldn't reproduce it" - because I had "Do not log commands from this device" checked. Now I see what you mean.
    It could be "who cares" scenario - unless it actually does change the HS device states - then it could trigger unnecessary events...
    I'll check.

    Click image for larger version

Name:	Annotation 2020-03-07 020931.jpg
Views:	64
Size:	56.9 KB
ID:	1368464

    Comment


      #3
      Yeah, you are right. This is the workaround logic for stupid Bond's "three lights" logic.
      That's why I hate workarounds. What looks simple at the beginning - becomes nightmare to implement/troubleshoot.
      And unfortunately it's not a "who cares" scenario - because it does change the HS device states.

      Click image for larger version

Name:	Annotation 2020-03-07 020931.jpg
Views:	73
Size:	121.0 KB
ID:	1368473

      Comment


        #4
        Ver 3.0.0.41 Moved Sleep to Execute();
        Fixed Light/UpLight/DownLight logic

        Comment


          #5
          Well picked Chris, you are a great tester!

          So, I fixed the stupid logic - it still checks the UpLight / DownLigt states twice, but at least it uses the new state both times - so it doesn't toggle the HS device state briefly.

          BTW, it could explain why the light sometimes comes on when it shouldn't - if first (brief) state change succeeds, but the second Execute command fails - then it stays in wrong state.

          And I moved the delay from ExecuteAction to Execute function - so it should apply to any send.

          Comment


            #6
            testing v41. Turning OFF the DownLight (which is ON) while the Uplight is OFF still triggers a event on the UpLight.

            Here is my event:
            IF Bond Sue's Room Sue's Fan Up Light just had its value set or changed.
            Then Set Device Upstairs Master Bath Shower Light to On

            This event got triggered even though the UpLight was OFF and not action was taken on that light and its physical state did not change.

            What would be the issue with treating Light, UpLight, and DownLight as three separate devices that had no knowledge of each other. In other words, don't assume that because Light went from ON to OFF that UpLight or DownLight changed state. I understand that one or the other or both will change state under that condition, but just ignore that.

            You could simply AND Light's state with Bond's UpLight's state to get the "HS" usable/testable state of UpLight and you AND Light's state with Bond's DownLight's state to get the usable/testable HS state for DownLight? Then and only then test for a change in the HS DownLight state and a change in the HS UpLight state and a change in the Light state. That way no extraneous events can be triggered.


            Comment


              #7
              Man, it's not that simple.

              I wrote my plugin in completely agnostic way - so the code doesn't know anything about the physical device type (i.e. is it light, fan?).
              I declare mapping between the Bond state and the HS device state. So each HS device registers itself for the particular Bond state change.

              Click image for larger version  Name:	Annotation 2020-03-07 121758.jpg Views:	0 Size:	57.3 KB ID:	1368499

              Then generic code checking which Bond state changed - and updates HS device state. When received the Bond state i.e. {"power":0,"speed":1,"light":1,"up_light":0,"down_light": 1} - each state keyword is processed completely independently from other states.

              Click image for larger version  Name:	Annotation 2020-03-07 121758b.jpg Views:	0 Size:	15.8 KB ID:	1368500

              Simple and clean. This way it's future proof - whatever new devices Bond Bridge will support - it will still work.

              Comment


                #8
                If you noticed in the code above thought - ChildDeviceDownLight also has a link to ChildDeviceLight for checking when this Light device is OFF.
                Which breaks the agnostic code - but not too much - it's still generic enough.

                I.e. I can use exactly the same code if we decide to set HS Fan Speed device to zero when Fan Power is off.

                Comment


                  #9
                  Originally posted by CJMH View Post
                  IF Bond Sue's Room Sue's Fan Up Light just had its value set or changed.
                  Then Set Device Upstairs Master Bath Shower Light to On

                  This event got triggered even though the UpLight was OFF and not action was taken on that light and its physical state did not change.

                  What would be the issue with treating Light, UpLight, and DownLight as three separate devices that had no knowledge of each other. In other words, don't assume that because Light went from ON to OFF that UpLight or DownLight changed state. I understand that one or the other or both will change state under that condition, but just ignore that.
                  I never use had its value set or changed trigger unless I have some additional condition. Because the "set" part will trigger the event even if the value didn't actually change.

                  I'm not really sure what you are trying to say in the last sentence?

                  Comment


                    #10
                    Originally posted by alexbk66 View Post

                    I never use had its value set or changed trigger unless I have some additional condition. Because the "set" part will trigger the event even if the value didn't actually change.

                    I'm not really sure what you are trying to say in the last sentence?
                    Not knowing more about your code structure I can't advise, but can't you create a middle man device/structure for fans that have the three lights, that does the AND and then passes the result off as if it came directly from Bond?

                    I know this is not agnostic, but the choice is do you want to the plugin to work correctly given the Bond oddity of (Light/UpLight/DownLight) or do you want to tell people that it does not work right for fans with Up/Down lights and they need to understand and work around that.

                    Comment


                      #11
                      Originally posted by CJMH View Post
                      can't you create a middle man device/structure for fans that have the three lights, that does the AND and then passes the result off as if it came directly from Bond?
                      Problem is I don't know what lights the device has - it can be one light, two lights, etc... How do I know? Based on template name?

                      Comment


                        #12
                        Originally posted by CJMH View Post
                        do you want to tell people that it does not work right for fans with Up/Down lights and they need to understand and work around that.
                        But what exactly doesn't work right?

                        Comment


                          #13
                          Originally posted by alexbk66 View Post

                          But what exactly doesn't work right?
                          Events

                          Comment


                            #14
                            Originally posted by alexbk66 View Post

                            Problem is I don't know what lights the device has - it can be one light, two lights, etc... How do I know? Based on template name?
                            I don't think you can use the template name since SBBs don't have one. However, you must know how many devices to create in HS some way. My fans with no lights have no light devices created in HS. May fans with one light have only "Light" created in HS. And my fans with three lights have an "UpLight", "DownLight", and "Light" created. For example on my fan with an up and down light the device details are:
                            [480]: {"name":"Sue's Fan","type":"CF","location":"Sue's Room","template":"A1a","actions":["StartDownLightDimmer","ToggleUpLight","SetSpeed","ToggleDow nLight","StartUpLightDimmer","TurnOff","Stop","TogglePower", "TurnOn","IncreaseSpeed","DecreaseSpeed","ToggleLight","Turn LightOn","TurnLightOff","TurnUpLightOn","TurnUpLightOff","Tu rnDownLightOn","TurnDownLightOff"],"_":"92bdbbba","commands":{"_":"1e65b710"},"state":{"_":"d3 6ae6b1"},"properties":{"_":"cacf75fa"}}
                            Mar-07 7:25:07 AM AK Bond [480]: Execute cmd: /v2/devices/27a50892/

                            If you see "TurnUpLightOn", "TurnDownLightOn", and "TurnLightOn" you know it has three lights. I know this is not agnostic, but because of the kludge Bond put in their firmware to deal with integrations that can't handle two lights, it should be dealt with.



                            Comment


                              #15
                              Originally posted by CJMH View Post

                              I know this is not agnostic, but because of the kludge Bond put in their firmware to deal with integrations that can't handle two lights, it should be dealt with.[/COLOR]
                              I understand what yo want Chris, just don't understand why? You said "Events" not working - in what way? Please elaborate. I can't read your mind.

                              Comment

                              Working...
                              X