We have a smart water meter which reports water consumption several times a day. I thought I'd just integrate #HomeAssistant with the service API. However, there is no API, and the webpage with the values is buried behind at least four interactions. Yesterday, I started writing a fairly complex Selenium-based scraper. In the process, I discovered that I was being redirected to a page with values using an authentication token in the URL. I could just use the link and skip all the previous steps.

However, the page with the values is still generated by JavaScript, so I still have to use a web engine for scraping. It's too heavy for Home Assistant Green, so I have to run the service elsewhere and integrate it with HA.

All that just to read ONE goddamn value! What a beautiful rabbit hole for the weekend!

in reply to Táta Geek

@tatageek to mi říkal už @bycx, že to jde odchytávat, ale to by vyžadovalo další hardware a s tímto nemám vůbec zkušenost, tak jsem si řekl, že scrapování bude jednodušší (ale to bylo před mnoha hodinami, co nad tím sedím 🙂). Ještě jsem přemýšlel nad tím tam dát zařízení na odečítání toho ciferníku jako u hloupého vodoměru, ale je v šachtě venku, kde je vlhko, žádný přívod elektřiny a je to dva metry v zemi, takže je otázka, jak by s tím šlo komunikovat vzduchem.
Je to fakt smutné, že máme chytrý vodoměr, ale BVK a Suez se opravdu snaží, aby se k tomu lidi nemohli strojově dostat.
in reply to Jiří Eischmann

@Razemix @steve At first glance, it looks like something that can be scraped without a web engine. The website is generated by ASP, simple "curl -L" fails the authentication, but if it doesn't work with curl after all, it's something Python requests + BeautifulSoup should handle. I have a new branch of the rabbit hole to dig, great! 😅
in reply to Jiří Eischmann

@Razemix @steve At second glance, no. First they really try hard to make sure they talk to a browser and second they do refresh the token every day (I was naive to think it could be a long term token). So I really have to login and scrape the bvk.cz website to get the refreshed token. 🙄
in reply to Radomír Žemlička

@Razemix @steve There is no integration. You have to log in at bvk.cz, go through 3 pages to find a link (with a token attached) to the Suez portal and then you're redirected there and can read the values there. I've already completed the scraping. It doesn't take too long (20s) and works reliably, but it loads Chromium, so it's too heavy for Home Assistant Green.
in reply to Václav Pašek

@electricCZ já ti nevím, jestli je co závidět, protože toto je digitalizace udělaná úplně tím nejblbějším způsobem. Vodárny se ani nesnažily to nějak integrovat do svého webu. Musím se tam přihlásit a proklikat čtyři obrazovky, aby ses dostal k odkazu s přiloženým tokenem do systému Suezu (dodavatele vodoměrů). A to je taky kapitola sama pro sebe. Stav ukazují na takové JS šílenosti, která simuluje ciferník vodoměru. Vodoměr očividně posílá stavy 4x denně, protože některé grafy se 4x denně aktualizují, ale samotný stav vodoměru se aktualizuje jen jednou denně. Navíc tam píšou, že k odečtu došlo ve tři ráno, ale ještě v devět ráno tam byl stav z předchozího dne.
No prostě v určité fázi už jsem si říkal, že snad raději budu denně lozit do šachty a odečítat to ručně než pracovat s tímto. 😅