# How to store device(Sonoff,s) status in database using node-red?

**URL:** https://discourse.nodered.org/t/how-to-store-device-sonoff-s-status-in-database-using-node-red/4765
**Category:** General
**Created:** [11 November 2018 09:13 UTC](https://discourse.nodered.org/t/how-to-store-device-sonoff-s-status-in-database-using-node-red/4765 "2018-11-11T09:13:31Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ahmad](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@ahmad](https://discourse.nodered.org/u/ahmad)
#### Post date: [11 November 2018 09:13 UTC](https://discourse.nodered.org/t/how-to-store-device-sonoff-s-status-in-database-using-node-red/4765/1 "2018-11-11T09:13:31Z")

</div>

I want to store device's status e.g  
which device connected to mqtt or which device is sending signals(ON,OFF) to mqtt.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [11 November 2018 11:23 UTC](https://discourse.nodered.org/t/how-to-store-device-sonoff-s-status-in-database-using-node-red/4765/3 "2018-11-11T11:23:16Z")

</div>

What sort of database?  
Have a look in [flows.nodered.org](http://flows.nodered.org) to see what is available for the database type you want to use.

---

<div class="post-metadata">

### Author: ![ahmad](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@ahmad](https://discourse.nodered.org/u/ahmad)
#### Post date: [11 November 2018 12:12 UTC](https://discourse.nodered.org/t/how-to-store-device-sonoff-s-status-in-database-using-node-red/4765/4 "2018-11-11T12:12:06Z")

</div>

@Colin i have to store device's ID and Status in database in node-red.  
I know node-red support databases e.g MsSql .  
But how to integrate it with the sonoffs?

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [11 November 2018 12:21 UTC](https://discourse.nodered.org/t/how-to-store-device-sonoff-s-status-in-database-using-node-red/4765/5 "2018-11-11T12:21:55Z")

</div>

I install mosquitto on my pi and then use OpenHab in the Sonoff 'Controlers' Protocol.  
If you look at the thread [Coffee pot timer](https://discourse.nodered.org/t/coffee-pot-timer/4743) you will see how I set the controler on a SonOff S20 switch. That and the flow should get you pointed in the right direction.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [11 November 2018 13:36 UTC](https://discourse.nodered.org/t/how-to-store-device-sonoff-s-status-in-database-using-node-red/4765/6 "2018-11-11T13:36:48Z")

</div>

> [@ahmad](#):
>
> But how to integrate it with the sonoffs?

Do you already have the Sonoff's sending data to MQTT? If so then you can use the MQTT In node to get the values into node-red.
