Scrape sensor improved - scraping multiple values

Cracked it! For those wanting to scrape their pricing (standard rates) if the have a peak and off-peak plan with Powershop in NZ, here is the full working code.

[EDIT] 9th November 2022. Adjusted code so that the peak and off-peak dollar values can be used in the HA Energy dashboard.

- resource: 'https://secure.powershop.co.nz/rates'
  name: Powershop
  log_response: true
  scan_interval: 43200 #every 12hrs
  form_submit:
    submit_once: true
    resource: 'https://secure.powershop.co.nz'
    select: ".content > form"
    input:
      email: !secret powershop_user
      password: !secret powershop_pass
  sensor:
    - unique_id: powershop_offpeak
      name: Powershop Off Peak
      select: "#main_container > div > div.row > div.rates-table-container.base-rates-table > table > tbody > tr:nth-child(1) > td.base-rates.current > span.rate.gst_inclusive"
      unit_of_measurement: "NZD/kWh"
      value_template: '{{ (value | int) / 100 | float | round(3)}}'
      device_class: monetary     
    - unique_id: powershop_peak
      name: Powershop Peak
      select: "#main_container > div > div.row > div.rates-table-container.base-rates-table > table > tbody > tr:nth-child(2) > td.base-rates.current > span.rate.gst_inclusive"      
      unit_of_measurement: "NZD/kWh"
      value_template: '{{ (value | int) / 100 | float | round(3)}}'
      device_class: monetary   
    - unique_id: powershop_daily_charge
      name: Powershop Daily Charge
      select: "#main_container > div > div.row > div.rates-table-container.base-rates-table > table > tbody > tr:nth-child(4) > td.base-rates.current > span.rate.gst_inclusive"      
      unit_of_measurement: "NZD/kWh"
      value_template: '{{ (value | int) / 100 | float | round(3)}}'
      device_class: monetary      
      on_error:
        log: warning
        value: last

1 Like