Skip to content

Commit

Permalink
Update for new Veolia/Vedif site 1/1/2025
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd committed Jan 1, 2025
1 parent ff5d958 commit ca692ca
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 43 deletions.
2 changes: 1 addition & 1 deletion addon_meterstoha/config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---

Check failure on line 1 in addon_meterstoha/config.yaml

View workflow job for this annotation

GitHub Actions / workflows / Lint Add-on

Add-on version identifier must be 'dev'
name: MetersToHA
version: 2024.12.9
version: 2025.1.1
slug: meterstoha
description: MetersToHA add-on for Home Assistant
url: https://github.com/mdeweerd/MetersToHA
Expand Down
101 changes: 59 additions & 42 deletions apps/meters_to_ha/meters_to_ha.py
Original file line number Diff line number Diff line change
Expand Up @@ -1632,77 +1632,94 @@ def get_veolia_idf_file(self):
else:
self.mylog(st="OK")

# Wait until element is at least visible
ep = EC.visibility_of_any_elements_located((By.CSS_SELECTOR, r".logo"))
# Wait until the page after login is loaded by checking
# that at least one of these elements is visible
ep = EC.visibility_of_element_located(
(
By.XPATH,
r"//span[" r"contains(text(), 'Alertes de consommation')"
# r" or contains(text(), 'HISTORIQUE')"
+ r"]",
)
)
self.__wait.until(
ep,
message="Failed, page timeout (timeout="
+ str(self.configuration[PARAM_TIMEOUT])
+ ")",
)

# Wait until spinner is gone #####
# Wait until spinner is gone # (Note: may need to be updated) ####
self.wait_until_disappeared(By.CSS_SELECTOR, "lightning-spinner")
time.sleep(1)

self.__browser.switch_to.default_content()

# Different handling dependent on multiple or single contract

self.mylog("Wait for MENU contrats or historique", end="")
ep = EC.visibility_of_element_located(
(
By.XPATH,
r"//span[contains(text(), 'CONTRATS')"
r" or contains(text(), 'HISTORIQUE')]",
)
)
try:
el = self.__wait.until(
ep,
message="failed, page timeout (timeout="
+ str(self.configuration[PARAM_TIMEOUT])
+ ")",
if False: # New site, multiple contract handling unknown
self.mylog("Wait for MENU contrats or historique", end="")
ep = EC.visibility_of_element_located(
(
By.XPATH,
r"//span[contains(text(), 'CONTRATS')"
r" or contains(text(), 'HISTORIQUE')]",
)
)
except Exception:
pass
try:
el = self.__wait.until(
ep,
message="failed, page timeout (timeout="
+ str(self.configuration[PARAM_TIMEOUT])
+ ")",
)
except Exception:
pass

self.mylog(st="OK")
self.mylog(st="OK")

time.sleep(2)
time.sleep(2)

menu_type = str(el.get_attribute("innerHTML"))
menu_type = str(el.get_attribute("innerHTML"))

# Click on Menu #####
self.mylog(f"Click on menu : {menu_type}", end="")
# Click on Menu #####
self.mylog(f"Click on menu : {menu_type}", end="")

el.click()
el.click()

self.mylog(st="OK")
self.mylog(st="OK")

# GESTION DU PARCOURS MULTICONTRATS
if menu_type == "CONTRATS":
time.sleep(2)
contract_id = str(self.configuration[PARAM_VEOLIA_CONTRACT])
self.click_in_view(
By.LINK_TEXT,
contract_id,
wait_message=f"Select contract : {contract_id}",
click_message="Click on contract",
delay=0,
)
# GESTION DU PARCOURS MULTICONTRATS
if menu_type == "CONTRATS":
time.sleep(2)
contract_id = str(self.configuration[PARAM_VEOLIA_CONTRACT])
self.click_in_view(
By.LINK_TEXT,
contract_id,
wait_message=f"Select contract : {contract_id}",
click_message="Click on contract",
delay=0,
)

time.sleep(2)

# Click Historique #####
self.click_in_view(
By.LINK_TEXT,
"Historique",
wait_message="Wait for historique menu",
click_message="Click on historique menu",
"Consommation",
wait_message="Wait for consommation link",
click_message="Click on consommation link",
delay=4,
)

if False:
# Click Historique (not needed, already selected) #####
self.click_in_view(
By.LINK_TEXT,
"Historique",
wait_message="Wait for historique menu",
click_message="Click on historique menu",
delay=4,
)

time.sleep(10)

try:
Expand Down

0 comments on commit ca692ca

Please sign in to comment.