cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Need some help onadding an alert/event to be trigger a subscription when row count of an infotable is changed

ad24
1-Visitor

Need some help onadding an alert/event to be trigger a subscription when row count of an infotable is changed

Hi

As per my exploration the subscription will use property/events to trigger itself.

But i dont know how to approach for my usecase.

It would be better if any snippet is provided for alerting on infotable data added up.

Thanks in advance

Aakash D

ACCEPTED SOLUTION

Accepted Solutions
supandey
19-Tanzanite
(To:ad24)

Aakash, what is updating the infotable? Can you not create an Event/Alert on that? In a crude and straight forward way you can simply create a Timer thing which subscribes to the Timer which fires every few seconds (you can configure as you feel). And in that Timer you can create a subscription which listens to itself. Under this subscription you can add your code to count the rows of the infotable and this way you have current state of the rows in the Infotable. For e.g. i added this code snippet in the Subscription like this and writes to a property GetCurrentTotalValue in DemoThing

result = Things["demothing"].infotableProp.getRowCount();

Things["demothing"].GetCurrentTotalValue = result;

This is how my subscription looks like:

This timer fires every second and gets me the current row which I then store in a property in a Thing which contains a property persisting the infotable looks something like this. The GetCurrentTotalValue property below gets updated everytime the Timer thing is fired (which is every second) and updates the value

Hope this helps.

View solution in original post

7 REPLIES 7
supandey
19-Tanzanite
(To:ad24)

Aakash, what is updating the infotable? Can you not create an Event/Alert on that? In a crude and straight forward way you can simply create a Timer thing which subscribes to the Timer which fires every few seconds (you can configure as you feel). And in that Timer you can create a subscription which listens to itself. Under this subscription you can add your code to count the rows of the infotable and this way you have current state of the rows in the Infotable. For e.g. i added this code snippet in the Subscription like this and writes to a property GetCurrentTotalValue in DemoThing

result = Things["demothing"].infotableProp.getRowCount();

Things["demothing"].GetCurrentTotalValue = result;

This is how my subscription looks like:

This timer fires every second and gets me the current row which I then store in a property in a Thing which contains a property persisting the infotable looks something like this. The GetCurrentTotalValue property below gets updated everytime the Timer thing is fired (which is every second) and updates the value

Hope this helps.

ad24
1-Visitor
(To:supandey)

Thank You

Sushant Pandey

I need mainly to capture the data change event of GetCurrentTotalValue as new and old value based on timeline(datachange event) and determine whether the new item is added to it or removed from it.

If you have worked with datachange event in subscription it would be really helpful for me.

Thanks in advance

supandey
19-Tanzanite
(To:ad24)

Aakash, I think your requirement to track the change of a single property isn't very different from the title of your question. Whether its a property or an infotable you are trying to track periodically. You just need an Alert/Event fired to which you can subscribe. That's how the Event - Subscription model works. So if your requirement is to simply track the change in property value then you can create a Subscription on that property which uses an OOTB Event called DataChange on GetCurrentTotalValue property and that's it. Here's how it would look when you'll configure it

Once enabled this subscription will execute the code you'll put in whenever there's a DataChange Event fired on Property GetCurrentTotalValue

ad24
1-Visitor
(To:ad24)

Yes Sushant Pandey

As per my Title i need the timer event to get count periodically as well as the datachange of GetcurrentTotalValue ​ must also be used to compare the timeline of datachange and generate the result whether item is added or removed from it.

supandey
19-Tanzanite
(To:ad24)

Not aware of the full use case but then won't it help to have these values added to a ValueStream together and then you can easily compare them based on the timestamp?

ad24
1-Visitor
(To:ad24)

Thanks for your reply

Sushant Pandey

The complete Usecase of mine is to count the entries of infotable at frequent interval and notify the user if any entry is either added to it or deleted from it.

I hope you could get it now.

Is it possible to combine value stream and timer?

supandey
19-Tanzanite
(To:ad24)

I'm not sure what you mean with combining value stream and timer these are two different things, sorry I don't want to confuse you with too many options. I just want to say that you can meet your requirement described above by using the Events and Subscription model. I hope it's clear how you can use them with the screenshot and description above. Else you can also refer to the Thing Events and Thing Subscription for more detail.

Announcements


Top Tags