# Wattsense

## **Connection between Wattsense Tower and MClimate Enterprise** <a href="#connection-between-the-things-industries-and-mclimates-lorawan-broker-using-webhooks" id="connection-between-the-things-industries-and-mclimates-lorawan-broker-using-webhooks"></a>

In order to properly create a Wattsense integration with MClimate Enterprise you need configure both the particular Wattsense Tower Device you are using and your Organization within the Wattsense platform.

## Configuring the Wattsense Tower

Log into our Wattsense Console (<https://console.wattsense.com/>) and open up the Tower you are going to be using to connect through.

You need to edit the Properties of the devices that you want to integrate (this needs to be done for every device you want to see in Enterprise)

<figure><img src="https://3940008670-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-McDr-jr9h3qA888r1Yp%2Fuploads%2FEwhMGH8yr9z5D4mj4GGm%2F13.png?alt=media&#x26;token=18ebb14b-ed7c-417a-8476-7ca202ee8533" alt=""><figcaption><p>Wattsense Tower configuration</p></figcaption></figure>

There are 2 properties that need to be enabled at the very least as these are what Enterprise needs to extract the data that it is to display:

* Raw encoded payload
* Encoded downlink message

<figure><img src="https://3940008670-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-McDr-jr9h3qA888r1Yp%2Fuploads%2F1AGAvdaIVezbjpi8IGZ9%2Fw1.png?alt=media&#x26;token=cb5fe7d2-a325-4834-84c9-7e416625ce41" alt=""><figcaption><p>Required properties</p></figcaption></figure>

You can enable as many as you like, but these two are the minimum.

## Configuring your Organization

Go to the Organization section and open up the API Keys tab.&#x20;

You need to create a "Service Account".

<figure><img src="https://3940008670-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-McDr-jr9h3qA888r1Yp%2Fuploads%2FPTE9PYieSwDsJaipp6Ey%2F1.png?alt=media&#x26;token=c9d19d17-3319-411d-af69-0b878b2eb27d" alt=""><figcaption><p>API Key tab</p></figcaption></figure>

Give it a name and make sure to select "Site Manager" from the drop down menu for the permissions level.

<figure><img src="https://3940008670-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-McDr-jr9h3qA888r1Yp%2Fuploads%2FUVtkjwc2BNrRuHjugDcB%2F2.png?alt=media&#x26;token=fbf2759b-4130-411a-aa2f-204e09832d41" alt=""><figcaption><p>Service Account</p></figcaption></figure>

Now that you have a Service Account with sufficient permissions you can create the actual API Key. Refer to the image below.

<figure><img src="https://3940008670-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-McDr-jr9h3qA888r1Yp%2Fuploads%2F5UWJtTjcLQvd1859bwU2%2F3.png?alt=media&#x26;token=cf12277f-0294-4c97-9812-4f961c92e179" alt=""><figcaption><p>API Keys</p></figcaption></figure>

You can have multiple Keys, we will need a single one for this tutorial. Create one.

<figure><img src="https://3940008670-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-McDr-jr9h3qA888r1Yp%2Fuploads%2Fs4y8xW5zCUM172bqJZkX%2F4.png?alt=media&#x26;token=8e3bdb82-3ba3-41c9-a810-333de32dc5e7" alt=""><figcaption><p>Adding an API Key</p></figcaption></figure>

You need only enter a description and your set of Key and Secret will be generated (automatically downloaded in a file form).

<figure><img src="https://3940008670-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-McDr-jr9h3qA888r1Yp%2Fuploads%2FOr2XnKQUzDG1m2A7uxnK%2F5.png?alt=media&#x26;token=3ae77468-e7ad-4d85-a516-91d4bbc2754e" alt=""><figcaption><p>API Key and Secret</p></figcaption></figure>

Now that you have the Keys you need to import them into the Enterprise platform. Head over to the link <https://enterprise.mclimate.eu/> and log into your account. Go to the Integrations section and create a new M-token.

<figure><img src="https://3940008670-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-McDr-jr9h3qA888r1Yp%2Fuploads%2FN10hwZbiVBSg50EZkfYX%2F6.png?alt=media&#x26;token=d134e890-4337-4b41-8bce-3ca08f3d1cb8" alt=""><figcaption><p>M-token</p></figcaption></figure>

Make sure to copy it as you will need it together with the Keys to create the integration (image above). You can click on the box to open up a window where you need to enter the set of the 3 (M-token on top, Key in the middle and Secret at the bottom field):

<figure><img src="https://3940008670-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-McDr-jr9h3qA888r1Yp%2Fuploads%2Fv38L4K5lGLI4ZvTOYujN%2F7.png?alt=media&#x26;token=adcf5081-2aa4-401b-a836-a5dbb60304b0" alt=""><figcaption><p>Wattsense Integration</p></figcaption></figure>

Your integration is now created. This will allow for the proper authentication between the Wattsense and MClimate Enterprise platforms.

In order to finalize the process you need to create a data stream. Go back to the Organizations section, but this time open  up the Data Stream tab and create a Connector.

<figure><img src="https://3940008670-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-McDr-jr9h3qA888r1Yp%2Fuploads%2FRznAOjEcg09lYeBVFbLF%2F8.png?alt=media&#x26;token=5e3ea1b8-41dd-44e9-9e72-99ff073cf10a" alt=""><figcaption><p>Data Stream Connector</p></figcaption></figure>

You need to fill all fields with the following values (use the image as reference if need be), only 3 of which are case specific (marked with the blue arrows)

* *Name* - choose an appropriate one
* *Protocol* - **HTTP (webhooks)**
* *Base URL* - **lorawan-broker.mclimate.eu**
* *Event route* - **/wattsense**
* *Alarms route* - **/wattsense-alarms**
* *Values route* - **/wattsense**
* *Secret key -* **the value of YOUR M-TOKEN**
* *Authentication -* **API Key**
* *Key name* - **m-token**
* *Key value* - **the value of YOUR M-TOKEN**
* *Key type -* **Header**

<figure><img src="https://3940008670-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-McDr-jr9h3qA888r1Yp%2Fuploads%2FGqkryCKyTRoebwz2DG7p%2F9.png?alt=media&#x26;token=8982fb53-0b56-49db-9514-1eb9353cbff3" alt=""><figcaption><p>Connector parameters</p></figcaption></figure>

You also need a trigger, so go and create one.

<figure><img src="https://3940008670-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-McDr-jr9h3qA888r1Yp%2Fuploads%2FeHiX1Z7MHtbWGEqGfxWH%2F10.png?alt=media&#x26;token=daeb6695-8681-4a66-a51a-8b70e97d82c8" alt=""><figcaption><p>Creating a Trigger</p></figcaption></figure>

Give it a name and make sure to select the 3rd radio button (**Value** option), this will result in it being triggered when the two properties we made sure are enabled in the start of the tutorial send data. Finalize it by adding a Tower (you can list as many Wattsense Towers as you have here).

<figure><img src="https://3940008670-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-McDr-jr9h3qA888r1Yp%2Fuploads%2FtJK7qxkpym24C5rOZ1U1%2F11.png?alt=media&#x26;token=70bf7a47-dda2-4bdd-936d-f958f869d22a" alt=""><figcaption><p>Trigger parameters</p></figcaption></figure>

Finally make sure both the Connector and Trigger are enabled. The Trigger should by by default, but the Connector you need to turn on manually.

<figure><img src="https://3940008670-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-McDr-jr9h3qA888r1Yp%2Fuploads%2FBZviSroTxsxfNMLWXuBY%2F12.png?alt=media&#x26;token=fe7de09d-481e-45a0-a5a1-9e0b498db95b" alt=""><figcaption><p>Trigger and Connector states</p></figcaption></figure>

If you configured everything properly your Integration is now complete and you should be able to see data in MClimate Enterprise (provided you have registered the devices there already).
