|Re: Best update strategy for a polled device ? [message #1759321 is a reply to message #1759271]
||Mon, 10 April 2017 14:17
| Simon Kaufmann
Registered: January 2011
Does this make sense ?
Should the recurring task issue refresh commands to the channels instead of directly refreshing the channels
No, it is good to directly do it. The REFRESH commands are just used to communicate from an "external" party (UI, framework) to the binding that it should be done now. It's good like you did it.
Is it OK to call the updateState method without checking if the channel state really needs to be changed first ? Is it computationally expensive ?
Yes, it is okay. The framework checks whether the value changed and issues a ItemStateEvent (always) and ItemStateChangedEvent (only if it really changed), so that receivers can subscribe to whatever fits best their needs. Usually it's the ItemStateChangedEvent, unless it is important (for whatever reason) how old the information is.
Does updating with updateState automatically triggers an update if the UI (in openhab) , what does ?
Yes, it does. Most UIs subscribe to the mentioned ItemStateChangedEvent and therefore will get notified automatically.
This is a somewhat related question : when are refresh commands naturally triggered by the framework ?
The major use-case is on start-up, especially when an item gets linked to a channel. But there is no restriction to that.
[Updated on: Mon, 10 April 2017 14:19]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.01911 seconds