Best way to develop an app where one driver can host multiple different devices

I’m currently working on an app where one single API can generate results for multiple devices. I created a driver which succesfully talks to this API but the devices returned all have somewhat different capabilities.

I resent the idea that the tutorials imply that each device has it’s own driver file, this feels very redundant because all drivers would make about the same API calls but filter on different JSON data.

How do the seasoned developers handle these cases? So ideally one driver which can provide data to multiple devices or perhaps one driver and one device with changing capabilities?

So you use subclassing, where you create a “base driver” (and “base device”) class that implements everything that all device types have in common, and create separate drivers/devices that extend the base class and implement/define the particular filter for that particular device type.

I had the same problem (one driver many devices) and solved it this way:

Thanks both for the input, this might just be the nudge that I need.

You could create one device/driver and add/remove capabilities, plus change the class on the fly.
My SmartThings app works that way. The disadvantage is the app only shows support for one device in the app store.
The advantage is a smaller app as it only requires one set of device images.