Gas Pricing Plus Oil

Got it! Looking at the post above linking to the “scrape” documentation the code should be the following:

scrape:
  resource: https://www.gasbuddy.com/station/34888
  scan_interval: 3600
  sensor:
    - name: Costco Gas
      select: "#root > div > div.Page-module__content___196kn.Page-module__padded___3hQ0U > div > div > div:nth-child(2) > div.grid__column___nhz7X.grid__desktop10___2T18R > div:nth-child(1) > div.grid__column___nhz7X.grid__desktop8___38Y4U > div:nth-child(3) > div > div.GasPriceCollection-module__collectionContainer___29Ngz > div:nth-child(2) > div:nth-child(1) > span"
1 Like

And your Costco fuel is so much higher than ours. Gotta love Cali :wink:

Yeah… I wish I lived elsewhere, but I’m currently stuck here. Once I have kids and they are about to go into public school, we may seriously consider moving out of state if we can’t get them in private school/home school.

The golden handcuffs. I get paid too well for my job, but I’m bored, and earning a state pension.

Now back on topic, I took the same inputs and applied to to the price per barrel of oil above. That sensor won’t scrape data. Anyone have that working? Or preferably both working and an example?

I want to create a chart trend and have it alert me on trend shifts so I know when it’s a good time to get gas or not. Gas price is usually a week or 2 behind oil pricing. If oil is trending down but gas is still trending up I want the trend senor to say “don’t buy” if both are trending up it’ll say “trending up” if both are trending down it’ll say “trending down” and if oil is trending up but gas isn’t trending up yet, it’ll say “buy” and send me a notification.

If you need it, this is the integration for Gas prices in Portugal:

For oil I use:

https://oilprice.com/oil-price-charts/#WTI-Crude

#pagecontent > div.siteContainer.oilprices > div.oilprices__centercolumn > table:nth-child(1) > tbody.row_holder > tr:nth-child(1) > td.last_price

Hopefully that helps.

What’s the YAML you are using to create/update the sensor. That’s what I have mine set to.

scrape:
  - resource: https://www.gasbuddy.com/station/34888
    scan_interval: 3600
    sensor:
      - name: Costco Gas
        select: "#root > div > div.Page-module__content___196kn.Page-module__padded___3hQ0U > div > div > div:nth-child(2) > div.grid__column___nhz7X.grid__desktop10___2T18R > div:nth-child(1) > div.grid__column___nhz7X.grid__desktop8___38Y4U > div:nth-child(3) > div > div.GasPriceCollection-module__collectionContainer___29Ngz > div:nth-child(2) > div:nth-child(1) > span"
  - resource: https://oilprice.com/oil-price-charts/#WTI-Crude
    scan_interval: 3600
    sensor:
      - name: Oil Per Barrel
        select: "#pagecontent > div.siteContainer.oilprices > div.oilprices__centercolumn > table:nth-child(1) > tbody.row_holder > tr:nth-child(1) > td.last_price"

I did read the integration documentation, that’s how I got it working. Using Sensor|Platform|Sensor didn’t work for me. I had to use Scrape|Resource|Sensor. However, that’s only working for Gas Prices, not Oil.

I was showing the example of my sensor but I stopped using the sensor via yaml at some point and just leveraged the scrape integration GUI under integrations. You could go that route.

I had no idea there was a GUI. Commenting out the gas scraper, restarting HA made the oil sensor work. Then I uncommented out the gas sensor and they are both working now… weird.