thor0215 / hassio-xfinity-usage

Fetch Xfinity Internet Service Usage Data and publish it to Home Assistant sensor
Apache License 2.0
11 stars 3 forks source link

Development/0.0.12.8 #39

Closed thor0215 closed 1 month ago

thor0215 commented 1 month ago
csobrinho commented 1 month ago

It's looking pretty good, thanks. I would probably remove the hassio env from the python and just do a

if pooling_rate == 0:
  EXIT(SUCCESS)

The python script doesn't really need to know you are running inside hassio.

Also you can extract the MQTT code to another file and just use it as a listener that will be called once data arrives. If MQTT, create class and attach to a listener list. Then you can have log also be a listener, etc. Just some separation of concerns inside the main python.

Some small nits could also be splitting the browser logic into steps (one action, supports retries, what element(s) to expect, presence of element A should indicate moving forward, presence of element B should indicate retry or abandonment) I believe playwright had a way to say: looking into the DOM and try to find one of these n elements in parallel so you can say search for password and username at the same time to validate the happy path and error path. Then would could encapsulate each browser step into a class, register all the steps as if they were a state machine and just run the state machine. Just some ideas from someone looking from the outside. Cheers and keep up the great work!

thor0215 commented 1 month ago

Some small nits could also be splitting the browser logic into steps (one action, supports retries, what element(s) to expect, presence of element A should indicate moving forward, presence of element B should indicate retry or abandonment) I believe playwright had a way to say: looking into the DOM and try to find one of these n elements in parallel so you can say search for password and username at the same time to validate the happy path and error path. Then would could encapsulate each browser step into a class, register all the steps as if they were a state machine and just run the state machine. Just some ideas from someone looking from the outside. Cheers and keep up the great work!

I've thought some on this and am realizing I just do not have enough programming experience with creating classes and subclasses. I like the idea of creating more separation, I'm just not sure where to start I guess.