Get state of Thing's Channel in BaseThingHandler

Hi there,

I’m writing a binding for some device. My device sends me a lot of events with some sensor values. Often, these values have not changed; are just the same as the event before.

I currently implement a BaseThingHandler calling this.updateState(channel, state). Now I want to change it by checking if the state has really changed.
How can i get the current State of a channel from inside a BaseThingHandler?
Something like this.getThing().getChannel(channelId) seems to give me only the static configuration of the thing, but not the state.
Any hint where to look?


You shouldn’t do that - the framework does the filtering of updates/changes for you.

If you filter out the data that hasn’t changed, then people can’t trigger rules with the correct event (ie they can’t detect if the value has been updated, or has changed since they will only get the changed events).

Hi all,

I have the same issue as SuperOok.

But my use case is slightly different. My thing has a channel lastSeen, which is automatically updated, when I receive data from the sensor.
Now I registered via scheduler to call every 5 minutes and check if lastSeen is older than 2 minutes. If so, the thing status changes to offline (which triggers a rule that react to it).

So I would like to get the state of my thing:channel in the BaseThingHandler…can somebody assists me here? Or am I approaching it from the wrong angle?