Announcement

Collapse
No announcement yet.

How do you set a value for a feature? I always get an error.

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

    How do you set a value for a feature? I always get an error.

    Whether I use this code:
    Code:
                Dim df As Devices.HsFeature = myHomeSeerSystem.GetFeatureByRef(FeatureRef)
                Dim status As Dictionary(Of HomeSeer.PluginSdk.Devices.EProperty, Object) = New Dictionary(Of HomeSeer.PluginSdk.Devices.EProperty, Object)()
                status.Add(HomeSeer.PluginSdk.Devices.EProperty.Value, NewValue)
                myHomeSeerSystem.UpdateFeatureByRef(FeatureRef, status)
    I get this error : Invalid type for property Service Version: NO_VERSION

    If I do this:

    Code:
                Dim df As Devices.HsFeature = myHomeSeerSystem.GetFeatureByRef(FeatureRef)
                df.Value = NewValue
                myHomeSeerSystem.UpdateFeatureByRef(FeatureRef, df.Changes)
    It also gives me an error : Do not set StatusControls directly Service Version: NO_VERSION

    Setting status does work:
    Code:
                Dim df As Devices.HsFeature = myHomeSeerSystem.GetFeatureByRef(FeatureRef)
                Dim status As Dictionary(Of HomeSeer.PluginSdk.Devices.EProperty, Object) = New Dictionary(Of HomeSeer.PluginSdk.Devices.EProperty, Object)()
                status.Add(HomeSeer.PluginSdk.Devices.EProperty.Status, NewValue)
                myHomeSeerSystem.UpdateFeatureByRef(FeatureRef, status)
    Anyone has this working or has some idea what I do wrong?

    #2
    To update only one property (value) I do it like this:

    Code:
    _hs.UpdatePropertyByRef(feat.Ref, EProperty.Value, value);
    but in the latest SDK, JLDubz has added some methods which are direct replacement for SetDeviceValueByRef and SetDeviceString

    Code:
    bool UpdateFeatureValueByRef(int featRef, double value);
    bool UpdateFeatureValueStringByRef(int featRef, string value);

    Comment


      #3
      Originally posted by spud View Post
      To update only one property (value) I do it like this:

      Code:
      _hs.UpdatePropertyByRef(feat.Ref, EProperty.Value, value);
      but in the latest SDK, JLDubz has added some methods which are direct replacement for SetDeviceValueByRef and SetDeviceString

      Code:
      bool UpdateFeatureValueByRef(int featRef, double value);
      bool UpdateFeatureValueStringByRef(int featRef, string value);
      Just a note, since you are developing a "contemporary" API - should it be a bit more OO, i.e. Feature.UpdateValue and Feature.UpdateValueString? spud JLDubz

      Comment


        #4
        Originally posted by spud View Post
        To update only one property (value) I do it like this:

        Code:
        _hs.UpdatePropertyByRef(feat.Ref, EProperty.Value, value);
        but in the latest SDK, JLDubz has added some methods which are direct replacement for SetDeviceValueByRef and SetDeviceString

        Code:
        bool UpdateFeatureValueByRef(int featRef, double value);
        bool UpdateFeatureValueStringByRef(int featRef, string value);
        I have been told that the correct way to update a feature value or status is to use:
        Code:
        bool UpdateFeatureValueByRef(int featRef, double value);
        bool UpdateFeatureValueStringByRef(int featRef, string value);
        which are available in SDK 1.0.5

        If you use UpdatePropertyByRef instead, it will not trigger any event or refresh the UI

        Comment


          #5
          Originally posted by spud View Post

          I have been told that the correct way to update a feature value or status is to use:
          Code:
          bool UpdateFeatureValueByRef(int featRef, double value);
          bool UpdateFeatureValueStringByRef(int featRef, string value);
          which are available in SDK 1.0.5

          If you use UpdatePropertyByRef instead, it will not trigger any event or refresh the UI
          I'm still on SDK 1.0.4 and UpdatePropertyByRef is (after adding the cast conversion to Double) working for me now.
          No UI dynamic updates though ...

          Comment


            #6
            Originally posted by spud View Post
            Code:
            bool UpdateFeatureValueByRef(int featRef, double value);
            bool UpdateFeatureValueStringByRef(int featRef, string value);
            spud JLDubz
            I have to re-iterate again - guys, you still have a chance to make your new SDK trully Object Oriented. It's not too late yet...

            Comment


              #7
              JLDubz still struggling with changing features. I use the following code:

              [/CODE]
              Dim fv As Devices.HsFeature = myHomeSeerSystem.GetFeatureByRef(HSRefArt)
              fv.StatusGraphics.RemoveKey(1000)
              Dim sg As Devices.StatusGraphic = New Devices.StatusGraphic(value, 1000)
              fv.StatusGraphics.Add(sg)
              myHomeSeerSystem.UpdateFeatureByRef(HSRefArt, fv.Changes)
              [/CODE]

              and get following error:

              Do not set StatusControls directly Service Version: NO_VERSION

              Any idea what I'm doing wrong or why this doesn't work?

              Comment


                #8
                Originally posted by dcorsus View Post
                JLDubz still struggling with changing features. I use the following code:

                Code:
                Dim fv As Devices.HsFeature = myHomeSeerSystem.GetFeatureByRef(HSRefArt)
                fv.StatusGraphics.RemoveKey(1000)
                Dim sg As Devices.StatusGraphic = New Devices.StatusGraphic(value, 1000)
                fv.StatusGraphics.Add(sg)
                myHomeSeerSystem.UpdateFeatureByRef(HSRefArt, fv.Changes)
                and get following error:

                Do not set StatusControls directly Service Version: NO_VERSION

                Any idea what I'm doing wrong or why this doesn't work?
                Are you trying to configure the StatusGraphics pair for the feature or set the feature's value? Maybe the following will help? I'm using C# so I've tried to translate what I have VB, it should be close.

                I use the following to update the StatusGraphic pair for a feature. For mine, I only have one StatusGraphic pair assigned to the feature so I do this:
                Code:
                myHomeSeerSystem.DeleteStatusGraphicByValue(fv.refid, value)
                myHomeSeerSystem.AddStatusGraphicToFeature(fv,refid, new_pair)
                To set the feature's value, I use:

                Code:
                myHomeSeerSystem.UpdateFeatureValueByRef(fv.refid, new_value)
                
                or
                myHomeSeerSystem.UpdateFeatureStringValueByRef(fv.refid, new_string_value)
                --
                Bob Paauwe
                ISYInsteon Plug-in
                http://www.bobsplace.com/ISYInsteon/

                Comment


                  #9
                  Originally posted by bpwwer View Post

                  Are you trying to configure the StatusGraphics pair for the feature or set the feature's value? Maybe the following will help? I'm using C# so I've tried to translate what I have VB, it should be close.

                  I use the following to update the StatusGraphic pair for a feature. For mine, I only have one StatusGraphic pair assigned to the feature so I do this:
                  Code:
                  myHomeSeerSystem.DeleteStatusGraphicByValue(fv.refid, value)
                  myHomeSeerSystem.AddStatusGraphicToFeature(fv,refid, new_pair)
                  To set the feature's value, I use:

                  Code:
                  myHomeSeerSystem.UpdateFeatureValueByRef(fv.refid, new_value)
                  
                  or
                  myHomeSeerSystem.UpdateFeatureStringValueByRef(fv.refid, new_string_value)
                  Thanks for the reply. After I posted my code yesterday, I found another post, perhaps by you or Spud referring to using AddStatusGraphicToFeature so I ended up trying this and it worked!

                  Code:
                                      Dim sg As Devices.StatusGraphic = New Devices.StatusGraphic(value, 1000)
                                      myHomeSeerSystem.AddStatusGraphicToFeature(HSRefNextArt, sg)
                  Not sure why I missed it yesterday but I couldn't find a DeleteStatusGraphicByValue like method, must have been sleeping. Thanks for the info.

                  Question to Rich or Jon rjh JLDubz , if I don't use DeleteStatusGraphicByValue but repeatedly use AddStatusGraphicToFeature for the same value, it seems to work but does this cause issues? Obviously, the less code I need to write the better but I couldn't find a method that just updates the graphic for the same value as opposed to delete it and add a new. Thoughts?

                  Dirk

                  Comment

                  Working...
                  X