Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed nightscout findings and improved loginscript #70

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions custom_components/carelink/nightscout_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,7 @@ def __get_treatments(self, input, key, value):

def __getDataStringFromIso(self, time, tz):
dt = datetime.fromisoformat(time.replace(".000-00:00", ""))
dt = dt.astimezone(tz)
timestamp = dt.timestamp()
date = int(timestamp * 1000)
date_string = dt.isoformat()
return date, date_string

def __getDataString(self, time, tz):
dt = datetime.strptime(time,"%Y-%m-%dT%H:%M:%S.%fZ")
dt = dt.replace(tzinfo=tz)
dt = dt.astimezone(tz)
timestamp = dt.timestamp()
date = int(timestamp * 1000)
Expand Down Expand Up @@ -376,7 +369,7 @@ def __getSGSEntries(self, sgs, tz):
trend, delta = self.__ns_trend(sgs[count], sgs[count-1])
except Exception:
pass
date, date_string=self.__getDataString(sg["datetime"], tz)
date, date_string=self.__getDataStringFromIso(sg["datetime"], tz)
result.append(dict(
device=NS_USER_AGENT,
direction=trend,
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
colorlog==6.7.0
homeassistant==2023.8.0
homeassistant==2023.12.3
pip>=21.0,<23.2
ruff==0.0.292
18 changes: 17 additions & 1 deletion utils/carelink_carepartner_api_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@
import secrets
from time import sleep
import requests
import platform
import sys

import OpenSSL
from seleniumwire import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.service import Service


def setup_logging():
Expand Down Expand Up @@ -98,7 +102,19 @@ def reformat_csr(csr):
return csr

def do_captcha(url, redirect_url):
driver = webdriver.Firefox()
options = Options()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
driver = None
if platform.system() == 'Linux':
geckodriver_path = "/snap/bin/geckodriver" # path to your geckodriver
driver_service = Service(executable_path=geckodriver_path)
driver = webdriver.Firefox(options=options, service=driver_service)
elif platform.system() == 'Windows':
driver = webdriver.Firefox(options=options)
else:
print("OS not supported yet.")
sys.exit(1)
driver.get(url)

while True:
Expand Down
Loading