I made a small web scraping script with python to check how much of our monthly internetvolume we used.
Code: Select all
import requests
from bs4 import BeautifulSoup
import re
DOMOTICZ_IP = 'http://YOUR_DOMOTICZ_IP'
DEVICE_IDX = 'YOUR_DEVICE_IDX'
POST_LOGIN_URL = "https://www.scarlet.be/customercare/logon.do?language=nl"
REQUEST_URL ="https://www.scarlet.be/customercare/usage/dispatch.do"
payload = {
"username": "YOUR_USERNAME",
"password": "YOUR_PASSWORD"
}
with requests.Session() as session:
post = session.post(POST_LOGIN_URL, data=payload)
# print(post.status_code)
page = session.get(REQUEST_URL)
# print(page.status_code)
soup = BeautifulSoup(page.text,'html.parser')
td = soup.find_all('td')
number = (td[4].text)
numb = re.findall("\d+\.\d+", number)
value = numb[0]
fltvalue = float(value)
D_value = str(round(fltvalue,2))
requests.get(DOMOTICZ_IP + "/json.htm?type=command¶m=udevice&idx=" + DEVICE_IDX + "&svalue=" + D_value)
Also make a dummy counter device in domoticz and remember the IDX
Then adjust the parameters in the script.
I use crontab to run this script once a day.
I also made a custom sensor icon with the scarlet logo which I will send to the domoticz icons e-mailadres.