Display scraped value in dollar

Hi

Is there a way to display the scraped value in dollar in HA?

The scrape:

  - resource: "https://markets.ft.com/data/commodities/tearsheet/summary?c=COMEX+Gold"
    scan_interval: 300
    sensor:
      - name: Gold
        select: ".mod-ui-data-list__value"
        unit_of_measurement: $

but I get this error:

ValueError: could not convert string to float: '1,978.90'

ValueError: Sensor sensor.gold has device class 'None', state class 'None' unit '$' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: '1,978.90' (<class 'str'>)

When I remove the unit of measurement it gives me the value in HA, but not displayed in dollar.

Thanks

It’s the comma that’s throwing off the float conversion. You could take the unit_of_measurement off of this sensor, and make a template sensor that has the unit_of_measurement with a template like this:

{{ sensor.your_gold_sensor | replace(',','') | float }}

1 Like