# Writing Smartapp/Device Handler for API/Smartthings sensor

**URL:** <https://community.smartthings.com/t/writing-smartapp-device-handler-for-api-smartthings-sensor/178237>\
**Category:** Support\
**Created:** [November 20, 2019, 11:16pm UTC](https://community.smartthings.com/t/writing-smartapp-device-handler-for-api-smartthings-sensor/178237 "2019-11-20T23:16:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kukuhome](https://avatars.discourse-cdn.com/v4/letter/k/f9ae1b/32.png) [@kukuhome](https://community.smartthings.com/u/kukuhome)\
**Post date:** [November 20, 2019, 11:16pm UTC](https://community.smartthings.com/t/writing-smartapp-device-handler-for-api-smartthings-sensor/178237/1 "2019-11-20T23:16:59Z")

</div>

Hello,

I’m new to smartthings app writing, but not new to technology and I’m hoping I can get some ideas/pointers on writing a decent smartapp/device handler for the following situation.

I’m using these Xiaomi plant sensors [here](https://www.amazon.com/Northfifteen-Connected-Home-Plant-Monitor/dp/B07L491F8K/) to measure moisture, fertilization level, temp and lux for my plants.

Instead of using the app, I’ve leveraged a slightly customized version of this [Project](https://github.com/ThomDietrich/miflora-mqtt-daemon) to gather the data from the BLE sensors.

Things are working great, I’m using influxdb and grafana to graph the data, and I have the MQTT messages being passed to [beebotte.com](http://beebotte.com), which can then expose it to API calls.

I would now like to present this plant data as a thing in SmartThings. What’s the best approach here? Do I start my development path on the classic method, or jump straight into the new? Do I create this as a cloud device, or try to connect it over the LAN? I had assumed that this would be fairly straight forward, but I gave this a cursory overview last night and realized it would not be as straight forward as I assumed. I could really use some help in understanding a path forward, or just some general ideas around making this possible.

---

<div class="post-metadata">

**Author:** ![Tech\_GFam](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/tech_gfam/32/98588_2.png) [@Tech\_GFam](https://community.smartthings.com/u/Tech_GFam)\
**Post date:** [November 21, 2019, 9:27pm UTC](https://community.smartthings.com/t/writing-smartapp-device-handler-for-api-smartthings-sensor/178237/2 "2019-11-21T21:27:05Z")

</div>

Kukuhome -

I created this repository to integrate any MQTT device with ST fairly robustly and easily  
check it out

> **[sgupta999/mqtt-bridge-smartthings](https://github.com/sgupta999/mqtt-bridge-smartthings)**
>
> MQTT Bridge To SmartThings \[MBS\]. Contribute to sgupta999/mqtt-bridge-smartthings development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![kukuhome](https://avatars.discourse-cdn.com/v4/letter/k/f9ae1b/32.png) [@kukuhome](https://community.smartthings.com/u/kukuhome)\
**Post date:** [December 8, 2019, 8:19pm UTC](https://community.smartthings.com/t/writing-smartapp-device-handler-for-api-smartthings-sensor/178237/3 "2019-12-08T20:19:39Z")

</div>

I’m not sure exactly where to start here, but I’ll give it a go.

---

<div class="post-metadata">

**Author:** ![Tech\_GFam](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/tech_gfam/32/98588_2.png) [@Tech\_GFam](https://community.smartthings.com/u/Tech_GFam)\
**Post date:** [December 9, 2019, 9:48am UTC](https://community.smartthings.com/t/writing-smartapp-device-handler-for-api-smartthings-sensor/178237/4 "2019-12-09T09:48:32Z")

</div>

I would start with the readme there. If you are familiar with node js and or docker the server side should be fairly straightforward.

If you have never used the SmartThings IDE there is some learning curve there but the appropriate SmartApp are already in the package.

In most cases you would not need a custom device handler but not sure if your use case can be mapped to an existing ST virtual device - if not you might need to modify a custom device handles - examples for that are also included in the package

---

<div class="post-metadata">

**Author:** ![erickv](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/erickv/32/230792_2.png) [@erickv](https://community.smartthings.com/u/erickv)\
**Post date:** [December 10, 2019, 10:52pm UTC](https://community.smartthings.com/t/writing-smartapp-device-handler-for-api-smartthings-sensor/178237/5 "2019-12-10T22:52:38Z")

</div>

Hello, @kukuhome

Speaking from the **[Connected platform](https://smartthings.developer.samsung.com)** side:

I’d recommend you to create your device controller app as an **AWS Lambda Function** so you don’t need to worry about running a server. Check if next libraries suits you:

- [node-mi-flora](https://github.com/demirhanaydin/node-mi-flora)
- [Xiaomi Mi Flora](https://github.com/honkmaster/homebridge-mi-flower-care)

Regarding the Lambda Function, [check this tutorial](https://blog.runscope.com/posts/how-to-write-your-first-aws-lambda-function).

And for your integration, the quickest integration is st-schema. Here is the proper documentation:

- [Cloud-Connected Devices](https://smartthings.developer.samsung.com/docs/devices/smartthings-schema/schema-basics.html).

And if you need examples, you can always check the SmartThings available [samples](https://smartthings.github.io/).

Regards,  
Erick.
