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

**URL:** <https://community.homey.app/t/best-way-to-develop-an-app-where-one-driver-can-host-multiple-different-devices/111818>\
**Category:** Developers\
**Created:** [June 22, 2024, 10:11am UTC](https://community.homey.app/t/best-way-to-develop-an-app-where-one-driver-can-host-multiple-different-devices/111818 "2024-06-22T10:11:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Venxir](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/venxir/32/79282_2.png) [@Venxir](https://community.homey.app/u/Venxir)\
**Post date:** [June 22, 2024, 10:11am UTC](https://community.homey.app/t/best-way-to-develop-an-app-where-one-driver-can-host-multiple-different-devices/111818/1 "2024-06-22T10:11:37Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [June 22, 2024, 10:20am UTC](https://community.homey.app/t/best-way-to-develop-an-app-where-one-driver-can-host-multiple-different-devices/111818/2 "2024-06-22T10:20:07Z")

</div>

> [@Venxir](#):
>
> 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.

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.

---

<div class="post-metadata">

**Author:** ![ChrisG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/chrisg/32/8825_2.png) [@ChrisG](https://community.homey.app/u/ChrisG)\
**Post date:** [June 22, 2024, 11:56am UTC](https://community.homey.app/t/best-way-to-develop-an-app-where-one-driver-can-host-multiple-different-devices/111818/3 "2024-06-22T11:56:10Z")

</div>

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

> <https://github.com/cgHome/homey.dingz/blob/main/drivers/dingzSwitch/driver.js>

---

<div class="post-metadata">

**Author:** ![Venxir](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/venxir/32/79282_2.png) [@Venxir](https://community.homey.app/u/Venxir)\
**Post date:** [June 22, 2024, 7:19pm UTC](https://community.homey.app/t/best-way-to-develop-an-app-where-one-driver-can-host-multiple-different-devices/111818/4 "2024-06-22T19:19:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Adrian\_Rockall](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/adrian_rockall/32/13209_2.png) [@Adrian\_Rockall](https://community.homey.app/u/Adrian_Rockall)\
**Post date:** [June 23, 2024, 12:25am UTC](https://community.homey.app/t/best-way-to-develop-an-app-where-one-driver-can-host-multiple-different-devices/111818/5 "2024-06-23T00:25:30Z")

</div>

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.
