Comcast/Xfinity Data Usage Sensor

Actually I didn’t have to parse any of the data myself. The docker container has an option for Home Assistant and auto discovery. It played nicely with the MQTT integration so when I setup the container, it created “Xfinity Usage” sensor automatically.

When I look at the MQTT Topic, there are 3 sub topics

One is “config”

{"name":"Xfinity Usage","state_topic":"homeassistant/sensor/xfinity/state","json_attributes_topic":"homeassistant/sensor/xfinity/attributes","unit_of_measurement":"GB","icon":"mdi:network"}

One is “attributes”

{"allowable_usage":1229,"home_usage":557,"wifi_usage":0,"courtesy_used":0,"courtesy_remaining":1,"courtesy_allowed":1,"in_paid_overage":false,"remaining_usage":672}

The last one is “state”

557

Here what I have in the config.yml file for the container

xfinity:
  username: USERNAME
  password: PASSWORD
  interval: 480

http:

post:
  

mqtt:
  host: IP ADDRESS
  port: 1883
  username: 
  password: 
  topic: xfinity
  homeassistant:
    prefix: "homeassistant"

I think I can technically remove the http: and post: lines but it works so I didn’t bother.

Ron, thanks for the work around!! Would you be willing to share the .js files for the 3 custom cards (stack-in-card, mini-graph-card, bar-card).

Thx!

Absolutely, I documented everything in a Gist. If I’m missing anything, let me know and I’ll update the Gist.

I finally got around to revisiting this. I was looking at the wrong logs. The docker app is not scraping the data at all. The issue I’m seeing in the logs is that I need to use a headless version of chrome or Firefox. I’ve done some digging and tried installing a headless version of chrome but I’m still getting the error in the logs. Here are my relevant logs:

Loading Configuration File config.ini

Configuration Successfully Loaded

/usr/local/lib/python3.6/site-packages/selenium/webdriver/phantomjs/webdriver.py:49: UserWarning: Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome or Firefox instead

warnings.warn('Selenium support for PhantomJS has been deprecated, please use headless ’

[2021-02-23 03:53:10,191 ERROR] Screenshot saved to: /src/webdriver_fail.png

[2021-02-23 03:53:10,193 ERROR] Page title: Sign in to Xfinity

[2021-02-23 03:53:10,201 ERROR] Page source saved to: /src/webdriver_fail.html

[2021-02-23 03:53:10,201 WARNING] Exception while logging in

Traceback (most recent call last):

File “/usr/local/lib/python3.6/site-packages/xfinity_usage/xfinity_usage.py”, line 233, in get_usage_page

self.do_login()

File “/usr/local/lib/python3.6/site-packages/xfinity_usage/xfinity_usage.py”, line 207, in do_login

raise RuntimeError(“Login button clicked but no redirect”)

RuntimeError: Login button clicked but no redirect

Any thoughts on how to resolve this?

did you install the other dependencies in requirements.txt?

Reviving and old topic, but could you share a link to this scraper?

1 Like

I believe this is the one you are looking for.