robbinjanssen / python-ojmicroline-thermostat

Asynchronous Python client controlling an OJ Electronics/Microline OWD5 Thermostat
MIT License
3 stars 3 forks source link

UWG4/AWG4 support? #178

Closed adamjernst closed 9 months ago

adamjernst commented 10 months ago

Great project. I would like to know if you would accept patches to add support for UWG4/AWG4 thermostats.

There is prior art on how to do it, but that integration is much less mature than yours. It's a bit odd because OJ Microline basically operates two completely separate APIs for OWD5 vs UWG4/AWG4, so to implement the changes this library would have to attempt signing in to both APIs and see which one works… definitely odd. (Or ask the user to select up-front which model of thermostat they have, as part of the config process.)

Let me know what you think.

robbinjanssen commented 10 months ago

Hi!

Sure that sounds great, adding more supported models will only make this library better! I did not really look into the linked code much, but at a glance it looks like the main difference is the auth parameters? The OWD5 requires a customer ID and API key, seems like the UWG4/AWG4 doesn't. Furthermore the OWD5 requires the API key to be sent each request, where the UWG4/AWG4 doesn't.

I don't really like adding more parameters to the init method, or make certain things optional and "guess" which thermostat the user has.

My preference would be to create an OWD class and UWG (or AWG) class which implements all specific API code/methods currently defined in the Ojmicroline class. And then provide an OWD/UWG object to the OJMicroline class (if that makes any sense).

Then we could use it something like:

owd5 = Owd(
        host="ocd5.azurewebsites.net",
        customer_id=99,
        api_key="<app-api-key>",
        username="<your-username>",
        password="<your-password>",
)

## Or:

uwg4 = Uwg(
        host="uwg4.azurewebsites.net",
        username="<your-username>",
        password="<your-password>",
)

client = OJMicroline(model=owd5)
data = client.get_thermostats()

Next step would be to make it configurable/usable in the home assistant integration

adamjernst commented 10 months ago

190 begins the process.