Skip to main content



      Home
Home » Archived » Eclipse SmartHome » Getting channel's current/latest state
Getting channel's current/latest state [message #1751321] Sun, 08 January 2017 10:28 Go to next message
Eclipse UserFriend
Hello,

Is there a way to get the current/latest value previously posted for a channel inside my ThingHandler?

Background:
I have a poller to a physical device's switch status and I want to use this value to update the UI. Right now, I can simply send a state "off" when the physical switch is polled "off", however that may create a long stream of unnecessary updateState() commands since a channel already in "off" doesn't really need to receive another "off" state.

I've read on another thread that I can have my ThingHandler caching values, however I'm wondering whether there's a better option considering channel values/states "should" be "somewhere" available for querying.
Re: Getting channel's current/latest state [message #1751342 is a reply to message #1751321] Mon, 09 January 2017 03:04 Go to previous messageGo to next message
Eclipse UserFriend
In general, it is a good practice to send new updates whenever you have a recent value at hand - it doesn't matter if it has changed or not.
Clients can subscribe to "changed" events, so if they are not interested in all updates, they can ignore them.

If you want to cache the status inside the handler nonetheless, this is indeed up to your implementation, there is no cache available in general.
Re: Getting channel's current/latest state [message #1751451 is a reply to message #1751342] Tue, 10 January 2017 08:47 Go to previous messageGo to next message
Eclipse UserFriend
Kai,

One of the issues I've encountered when blindly sending values (rather than just changed values) is on the UI front which tends to do things on a value update (regardless it the value is the same or not).

I'm going to pick on the paperui as an example.

Say you have a binding that has a lot of channels (channels 'A' through 'Z'). So many channels that the paperui/control has a vertical scroll bar. Let's say channel 'A' has a value of 1 and channel 'Z' has a value of 2. Furthermore, channel 'A' is at the top of the page, channel 'Z' is at the bottom of the page and you've scrolled to see channel 'Z' (so channel 'A' is off screen). If the binding were to send the value 1 to channel 'A' again - paperui will reset the scroll to the top because channel 'A' was updated (even though it really wasn't updated from a user perspective).

Now - compound that if the binding has some type of polling refresh set to say 10 seconds (where 'A' get's 'updated' to 1 every 10 seconds) - makes the paperui unusable because the scrolling always shifts away from what you are looking at...

note: I know this could be a bug in paperui (ie the scrolling on value updates [not necessarily changes] - probably setting the field focus or something) - but it generally applies to any ui that could take whatever action.

Tim

Re: Getting channel's current/latest state [message #1751871 is a reply to message #1751451] Mon, 16 January 2017 06:30 Go to previous message
Eclipse UserFriend
What you describe would be simply two bugs:
1. There should be no scrolling when a value is updated (independent whether it has changed or not). I know that the Classic UI has this limitation, but all other UIs should not show such an issue.
2. UIs should only react on "changed" events and not on "updated" events. So if nothing has changed, they anyhow should have ignored that event.

So if you indeed encounter such a situation, please file a bug against the respective UI.
Previous Topic:How To Query Items Things and Bindings
Next Topic:Get A lot of ERROR while setup my ESH environment (T_T)
Goto Forum:
  


Current Time: Tue Jul 01 06:33:56 EDT 2025

Powered by FUDForum. Page generated in 0.03747 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top