changedetection.io icon indicating copy to clipboard operation
changedetection.io copied to clipboard

[feature] Price Threshold Filter

Open jrruethe opened this issue 2 years ago • 10 comments

Version and OS Docker image dgtlmoon/changedetection.io:0.39.18

Is your feature request related to a problem? Please describe. ChangeDetection.io does a great job extracting text and creating notifications when that text changes. However, from what I can tell, it cannot interpret the extracted text of something like a price as a number and trigger a notification when that number exceeds a threshold.

Describe the solution you'd like Underneath the "Extract Text" options in "Filters & Triggers", I'd like to see a checkbox such as "Extracted Text is a Number", followed by a way to set a trigger if that number is <, =, > a value. For example, the trigger fires if the extracted price is < 20.

Describe the use-case and give concrete real-world examples As an example, I'd like to use ChangeDetection.io to monitor when the Bitcoin price exceeds a value.

So using this site: https://coinmarketcap.com/currencies/bitcoin/

With this XPath filter: /html/body/div[1]/div/div[1]/div[2]/div/div[1]/div[2]/div/div[2]/div[1]/div/span

And this regex under "Extract Text": \$([0-9,.]+)

I can extract the current Bitcoin price (which at the time of this writing is 21,582.35). This works well, I have pulled out the price as a number without the dollar sign.

However, the Bitcoin price changes quite often, by small amounts, which normally causes this notification to fire on each check. In reality, I only really care if the price has risen above some value (or dropped below some value). In this example, maybe I want to set the threshold to 22,000.00 and only trigger a notification if the extracted value exceeds that threshold.

This would essentially suppress all the notifications from the price fluctuations, but still notify me if there is a large change.

I suppose if the price does go above the threshold, it would then trigger a notification with each little fluctuation, which is fine.

As another use-case example, Amazon prices tend to fluctuate. Maybe I want to set a watch for an item that is normally around $20, and be notified if that price drops below $15. I don't need to be notified if the price goes to $19 or up to $25.

Additional context If this is already possible, I was unable to find the documentation for it. Thanks!

jrruethe avatar Aug 26 '22 14:08 jrruethe

I just discovered this project, and this feature request is my primary use case - notify me when things go on sale or when items are mis-priced below a threshold. +1 on this request.

bmn001 avatar Sep 15 '22 15:09 bmn001

Sorry, I don't get it. Can we use conditions at now and how we do it?

masterwishx avatar Oct 29 '22 16:10 masterwishx

no, i'm open to a pull-request if you want to add it

dgtlmoon avatar Oct 30 '22 07:10 dgtlmoon

no, i'm open to a pull-request if you want to add it

Thanks a lot, very like your app

masterwishx avatar Oct 31 '22 09:10 masterwishx

An idea, could be some language to describe a trigger filter like

math: extract_any_number_value > 10.50

which goes in the trigger text setting

dgtlmoon avatar Nov 02 '22 23:11 dgtlmoon

Duplicate #190

dgtlmoon avatar Nov 04 '22 13:11 dgtlmoon

+1 for this feature. This is such a fantastic project and I appreciate all the work being put into it. The lack of a threshold filter is the only part that is really limiting its use for me.

timmeh-git avatar Jan 28 '23 14:01 timmeh-git

I'd really like this as well. Currently I'm using regex filter under the "Trigger/wait for text" section. But regex and number ranges is a mess. And it doesn't work in all scenarios.

I too use a xpath selector that gives me just the value. Even the functionality to execute an external script on a trigger would be great. Then we could make our own condition scripts.

codedesperate avatar Sep 15 '23 10:09 codedesperate

I found a way to do this! Or rather, I found a comment here from someone who found the way! https://github.com/dgtlmoon/changedetection.io/discussions/1474#discussioncomment-6652576

Using XPATH, I can now have price alerts that should only alert when under a specific threshold. One caveat though, is while as long as the price is not under the specified value, changedetection will report: Warning, no filters were found, no change detection ran - Did the page change layout? update your Visual Filter if necessary. Because the filter will only match when the price is under. I now have price monitors with prices written as "9999" and "9.999" as sudlon in this comment also showed how to deal with dots and commas. For a 9.999 price I just strip the "." away so it will compare with 9999.

codedesperate avatar Sep 15 '23 11:09 codedesperate

Building on this, to get rid of the dollar sign, comma and periods, use this XPATH filter:

/html/body/div[3]/div[4]/section/section/div[6]/div[2]/div[2]/div[1]/div/div/div[number(translate(text(), '$,.', '')) < 129999]

This does the logic on the XPATH of: /html/body/div[3]/div[4]/section/section/div[6]/div[2]/div[2]/div[1]/div/div/div

pauljones0 avatar May 26 '24 21:05 pauljones0