Skip to content

[feature] add previous_price to restock values #3987

@opicron

Description

@opicron

Version and OS
v0.54.4 Docker

Is your feature request related to a problem? Please describe.
In my restock price notification I add the previous price as additional information. To make this work I have to add this jinta code to get the previous price from the difference in text:

{% set lines = diff_patch.splitlines() %}
{% if diff and 'Example' not in diff %}{% for line in lines %}{% if line.startswith('-') and 'Price:' in line %}{% if line.split('Price: ')|length > 1 %}Previous amount: {{ line.split('Price: ')[1].split()[0] }}{% else %} {% endif %}{% endif %}{% endfor %}{% endif %}

Describe the solution you'd like
Currently in watch.json the restock prices and availability is stored like so:

  "restock": {
    "in_stock": false,
    "price": 44.99,
    "currency": "EUR",
    "original_price": 44.99,
    "availability": "\n \n \n \n \n \nhttps://schema.org/outofstock\n \n  \n \n \n \n"
  },

Could we add a previous_price value which is saved when a new price is detected? The previous_price value would be the price value just before it is set with the new price.

Describe the use-case and give concrete real-world examples
This would significantly improve the jinta code and provide more information to notifications.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions