Hi,
i try to split a value which i get from a website.
scrape:
- resource: https://www.idealo.de/preisvergleich/OffersOfProduct/3978999_-pj7000j-makita.html
sensor:
- name: "Makita Test"
select: ".oopStage-conditionButton-wrapper-text-price > strong:nth-child(2)"
value_template: "{{value.split (' ')[0]}}"
unit_of_measurement: '€'
The value is at “219,90 €”. I want to split the € from the price. Space doesn’t work but with the “,” it works.
Can someone help me?
Heinz
February 1, 2023, 7:01pm
2
The value-template seems not to be the problem. If I put this in template editor:
{% set value='219,90 €' %}
"{{value.split (' ')[0]}}"
I get: “219,90”
Did you check the value of your sensor in Developer Tools → States?
WallyR
(Wally)
February 1, 2023, 7:22pm
3
Maybe its not a space as such.
Try to set up the sensor, then take a look at the sensor value with the browser’s developer tool.
It could be a
or some other value.
123
(Taras)
February 1, 2023, 7:25pm
4
Try slicing off the last two characters.
scrape:
- resource: https://www.idealo.de/preisvergleich/OffersOfProduct/3978999_-pj7000j-makita.html
sensor:
- name: "Makita Test"
select: ".oopStage-conditionButton-wrapper-text-price > strong:nth-child(2)"
value_template: "{{value[:-2]}}"
unit_of_measurement: '€'
i have already tryed " " but it is the same result. the developer tool show special character.
“{{value[:-2]}}” is a good idea.Thanks