jaraco / jaraco.abode

MIT License
11 stars 9 forks source link

Device specialization is confusing and unnecessarily complicated #28

Closed jaraco closed 1 month ago

jaraco commented 2 months ago

In the handling of Device.new, there are some convoluted behaviors in resolving the specialized subclasses of BinarySensor (namely Sensor, Occupancy, and Motion):

https://github.com/jaraco/jaraco.abode/blob/595f714456315159fa7d2f34f826b950d86e2f7d/jaraco/abode/devices/base.py#L127-L180

In particular, in get_generic_type, the device tags are explicitly managed rather than being associated with a sub_cls and then indicated as "unknown", even though they are known. Then another routine resolve_type_unknown replaces these falsely-unknown types with real types.

This roundabout approach to resolving types is confusing, error-prone, and counter-intuitive, contributing to home-assistant/core#121300 and delaying its resolution.

Let's find a better way.

jaraco commented 1 month ago

Attempting to understand the difference between "Motion" and "Occupancy" sensors as coded in:

https://github.com/jaraco/jaraco.abode/blob/abb2c6a0028ac04cee3ca2c40bfb8186b972f9a3/jaraco/abode/devices/base.py#L140-L142

I did some searching and found https://github.com/MisterWil/abodepy/issues/10#issuecomment-325838125, which seems to indicate that the origin of these two classes is javascript (presumably from the Abode web UI) that alters the labels based on the reported version.

Moreover, there seems to be no examples of a device that returns a version prefixed with "MINIPIR", so this code path may never be activated.