ntalekt / Cox_Data_Usage

Script that collects Cox Communications data usage for internet subscribers
18 stars 8 forks source link

Help in modifying this for Comcast? #4

Closed poldim closed 5 years ago

poldim commented 5 years ago

Thanks for making this. Unfortunately, I'm in the same boat as you with my ISP limiting my usage as well as being a Home Assistant user, however, I'm on ~Crap~Comcast. I'd like to leverage your work but modify it to work with their site. Their account page states your current usage via a chart created by some javascript but above it states the amount of remaining data usage in the current cycle:

xfinity my account data usage

In the HTML, it shows as <span ng-bind-html="usage.details.userMessage.monthlyUsageState"><b>757GB</b> remaining of <b>1024GB</b> monthly plan</span>.

I believe your component is grabbing a script that contains your data usage in it and then parses out the data between the curley brackets.

How can I modify this to return the usage.details.userMessage.monthlyUsageState tag, keeping only the first number before GB?

I know that data usage remainning this month is not the same as data usage this month, but this seems easier. There is a table that you can expand below the chart that shows the total monthly usage of the last 6 months plus the current month, but I think that's too complex for me to tackle. The better source would probably be the javascript linked above, but I don't know the first thing about js.

I've modified the py file with the comcast urls:


# URL that we authenticate against
login_url = "https://login.xfinity.com/login"
# URL that we grab all the data from
stats_url = "https://customer.xfinity.com/#/services/internet"
# Your cox user account (e.g. username@xfinity.com) and password
xfinity_user = "username"
xfinity_pass = "password"
home = os.getenv('HOME', '/home/homeassistant')
json_file = f"{home}/.homeassistant/xfinity_usage.json"
ntalekt commented 5 years ago

https://github.com/SilvrrGIT/HomeAssistant/issues/105