jaroschek / home-assistant-myuplink

Custom Home Assistant integration for devices and sensors in myUplink account.
43 stars 10 forks source link

Added new controllable platforms #11

Closed 7RST1 closed 1 year ago

7RST1 commented 1 year ago

I decided to have a go at enabling the integration to control its devices. This included a few deep changes to the API, which works, but I have no idea if I'm following HASS conventions. Maybe there are no relevant conventions?

Nonetheless, the integration now adds a water_heater for the Høiax CONNECTED lineup, and adds each parameter as a fitting user-editable entity if the API specifies the parameter as writable.

~This is all based on parameter.id checks on the const.py file though. It'd be more ideal to have a function check the parameter's details to determine what kind of entity it should be, so it'd work for more devices. Maybe this should be implemented before merge?~

7RST1 commented 1 year ago

I made a method on Parameter called find_fitting_entity, which delegates to entities based on parameter context. The PR should be ready to merge, and the integration should now be suited for reading or controlling basically any device :)

jaroschek commented 1 year ago

I installed your branch in my dev installation and made some tests. Here is the view of my now editable data points: editable-data-points This looks very promising.

Unfortunately there are some readonly data points described as writable: true in the json response from myUplink API. This seems to be an error in the API, as Degree Minutes or measurements in kWh are nothing I could or even would adjust.

Here is a current response from the API: response.json.zip

I think we will need a possibility to optionally define the entity a datapoint should use to compensate these API errors.

There is also a special data point Tarifblockierung, that I defined as binary_sensor with specific icon in my implementation to visualize this as a locking mechanism. With your current changes it not only looses it's icon but even is defined as simple sensor now: tarifblockierung I would appreciate if you would keep these special treatments.

7RST1 commented 1 year ago

Seems like Tarifblockierung is also an API deviation, cause there are no enumValues defining its two on/off states. I added two variables in const which defines overrides for platform and is_writable. Could you test again and see if it works as it should?

jaroschek commented 1 year ago

With your latest changes it is working now and keeps my current special entities as they are now.