Announcement

Collapse
No announcement yet.

Show latest date-time of last update on device card

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

    Show latest date-time of last update on device card

    I have created a plugin that allows me to create devices with few pre-configured features. One of those features is Status which indicates Online/Offline. This feature updates frequently. Other than that I have other feature which updates less frequently. On the device card, the date-time of the last update is shown as the last update time of the feature which is last in the sequence. Can I change this to show the latest date-time of the last update in the device card? Have a look at the below images to get a better idea.

    Click image for larger version  Name:	image.png Views:	0 Size:	31.1 KB ID:	1576760
    Click image for larger version  Name:	image.png Views:	0 Size:	23.3 KB ID:	1576761

    The last update time on the device card should be 16:47:50 and not 12:03:18​.

    #2
    You can set explicitly AbstractHsDevice.LastChange (HomeSeer.PluginSdk.Devices.EProperty.LastChange) I guess

    Comment


      #3
      Is there a way to globally configure this to take the latest value instead of me modifying it every time I update any of the features?

      Comment


        #4
        "LastChange" should always update automatically if you set the feature value

        Comment


          #5
          In the images I posted in the question, we can see that the Status feature is last updated but the time shown on the device card is of the last change time of the Motion feature. The way I update features is as soon as I receive new values, for every feature I run this piece of code
          Code:
          HomeSeerSystem.UpdateFeatureValueByRef(feature.Ref, newValue);
          Now if the newValue is the same as the oldValue the last updated time for the feature is not changed even if I am calling the UpdateFeatureValueByRef method. Now consider this scenario to better understand my situation,

          I have these two features in sequence Status and Motion. Now when new values are received I call the UpdateFeatureValueByRef​ for both of these features. The new value for Motion status is the same as the old value and hence its last change is not updated. Whereas for the status feature this is not the case and its last change is updated. After the update, we have Status - t2 and Motion - t1 (in sequence). Now in this scenario, the last change of device should be t2 but I am getting t1 on the device card (refer to the images in question to have a better idea),

          Also, I would like to point out that I have marked all the features in my device as Display Type: Important.

          Another thing to mention is if I add one feature at the end of the sequence whose value is not yet updated (which means the feature doesn't have the last change) the device card shows no last change value. It clearly indicates that the device card shows the last change of the last feature in sequence. Is this a bug or is this something related to the way I implement it?

          Comment


            #6
            Are you saying that you want Last Changed time to be updated even if the value didn't change? There was an option in settings before, but I can't find it...

            In the worst case you still can set the time manually.

            BTW, did you try refreshing the page manually? I found often it doesn't update by itself.

            Comment


              #7
              Are you saying that you want Last Changed time to be updated even if the value didn't change? There was an option in settings before, but I can't find it...
              No I want the device card to show the latest Last Change out of all features. For that, I tried the below code but I am not able to achieve what I want.

              Code:
              var features = device.Features;
              var lastChangeDates = features.Select(_ => _.LastChange).ToList();
              device.LastChange = lastChangeDates.Max();
              
              HomeSeerSystem.UpdateDeviceByRef(device.Ref, device.Changes);
              BTW, did you try refreshing the page manually? I found often it doesn't update by itself.
              Yes tried that. No success.​

              Comment


                #8
                Originally posted by hembhagat View Post

                No I want the device card to show the latest Last Change out of all features.​
                I would suggest you put in a feature request to HomeSeer for this. I agree with you that it would make more sense to show the latest LastChange of all the features rather than rather randomly the last feature in the list. Ideally it would be useful to be able to choose either the most recent of all features or a specific feature.

                Steve

                Comment


                  #9
                  Okay, SteveMSJ I will create a feature request for it in my free time. But it means there is no way of achieving what I want currently as I tried setting the time manually and it is not reflecting. Any other way to achieve what I want?

                  Comment


                    #10
                    Originally posted by hembhagat View Post
                    Okay, SteveMSJ I will create a feature request for it in my free time. But it means there is no way of achieving what I want currently as I tried setting the time manually and it is not reflecting. Any other way to achieve what I want?
                    I haven't studied your code but you seem to be setting the LastChange of the Parent Device to the latest of all the Features. To work around the way HS seems to be currently working, you would want to set the LastChange of the last Feature on the Grid (card). However, whether this is the last, first, or random item in the list returned by device.Features, you would have to experiment with.

                    The User can reorder the Features on the Grid which may or may not change which is used for the LastChange shown. Programmatically I don't think you can set the order, my experience is that they are initially ordered by the order you create them.

                    Steve

                    Comment


                      #11
                      Originally posted by SteveMSJ View Post
                      To work around the way HS seems to be currently working, you would want to set the LastChange of the last Feature on the Grid (card).

                      Won't that show the wrong Last Change for that feature? I want the latest value on the device card but the individual Last Change for the feature should still be correct.


                      Comment


                        #12
                        Originally posted by hembhagat View Post

                        Won't that show the wrong Last Change for that feature? I want the latest value on the device card but the individual Last Change for the feature should still be correct.
                        Yes it would, but we are talking about a work around not a solution It would be a hack until HS updates the way it works.

                        Personally I wouldn't do it, I was just offering a suggestion. I consider the HS web view (Grid and List) to just be useful for system configuration. For user interaction, I use HSTouch where I can configure what is shown, how I want it. Although it is time consuming to set up
                        For that reason this particular bug/feature hasn't bothered me too much.

                        Steve

                        Comment


                          #13
                          Okay, SteveMSJ. Thanks for the help.

                          Comment


                            #14
                            SteveMSJ Can you tell me what is the use of the flag "Last Change Time Updates on Status Change Only" on the device settings page?

                            Comment


                              #15
                              Originally posted by hembhagat View Post
                              SteveMSJ Can you tell me what is the use of the flag "Last Change Time Updates on Status Change Only" on the device settings page?
                              When the flag is Set (default) the Last Change only updates when the value of the Feature changes. When the flag is UnSet the Last Change is updated every time the Feature value is set even if it is set to its previous value.

                              Steve

                              Comment

                              Working...
                              X