Integration of Shelly Door Window 2 with Ilevia via MQTT

How to configure the Shelly Door Window 2 sensor via MQTT in Ilevia Manager: state, brightness, battery, tilt, temperature, and vibration.

Introduction

This Shelly device is designed to be applied to doors and windows and provides the following values: whether they are open, closed, or tilted (with a specific angle in degrees), the room temperature where the device is installed, room brightness, battery level, and whether the device detects vibrations when the window is closed.

Web interface configuration

Step 1:

First, connect to the Shelly Door Window 2 device Wi-Fi network. Once connected, enter the default IP address for accessing the Shelly device web interface in the URL bar: 192.168.33.1.

How to connect to the Shelly device web interface

Step 2:

Go to the Internet security settings menu, open the wifi client mode section, and select the Connect the device to an existing wifi network checkbox to connect the Shelly device to your local network.

How to connect your Shelly device to its own Wi-Fi network

Step 3:

The next step is to enable actions via the MQTT protocol on the Shelly device: in the Internet security settings menu, open the Advanced developer settings section and enable the Enable action execution via MQTT protocol checkbox.

Enter your IP address of your Ilevia server in the Address text field of the MQTT protocol settings, then set QoS to 2 and finally click SAVE to apply the settings.

How to enable actions with the MQTT protocol in the Shelly device web interface

Topic configuration

This is the list of topics used in the guide:

Topic configuration index

– shellies/shellydw2-<deviceID>/sensor/state: this topic reports the current door/window state;

– shellies/shellydw2-<deviceID>/sensor/lux: this topic reports the brightness level of the room where the device is located;

– shellies/shellydw2-<deviceID>/sensor/battery: this topic reports the device battery level;

– shellies/shellydw2-<deviceID>/sensor/tilt: this topic reports the window tilt angle, from 0 to 180;

– shellies/shellydw2-<deviceID>/sensor/temperature: this topic reports the current temperature of the room where the device is installed;

– shellies/shellydw2-<deviceID>/sensor/vibration: this topic reports 0 if no vibration is detected and 1 if it is detected.

Step 4:

Open Ilevia Manager, create a new project, and create a new MQTT gateway: this guide explains step by step how to set up the new MQTT gateway.

Step 5:

Now set up the first topic, which reports the door/window state (closed or open). Drag a Text Info component into the project and set its gateway to the previously created MQTT one.

Adding a new Text Info component in the Ilevia Manager Components section

Step 6:

Topic: shellies/shellydw2-<deviceID>/sensor/state

Now configure the component. The topic that receives the device state is the Event topic.

Clicking this link you can view the topic configuration illustrated.

Setting the topic in the Text Info component in Ilevia Manager

Step 7:

To receive the Lux value from the Shelly device, add a new Info component in the Ilevia Manager Components section and set the gateway to the previously created MQTT one.

Adding a new Info component in the Ilevia Manager Components section

Step 8:

Topic: shellies/shellydw2-<deviceID>/sensor/lux

This is the topic to apply to the Info component to receive the value from the Shelly device.

Clicking this link you can view the topic illustrated in the image below.

Setting the Info component to display the lux value received from the Shelly device

Step 9:

Now configure the Info component that reports the battery level of the Shelly device.

Then add a new component to the project and set the MQTT gateway.

Adding a new component to the project to display the battery percentage of the Shelly device

Step 10:

Topic: shellies/shellydw2-<deviceID>/sensor/battery

Set the topic that reports the battery level of the Shelly device. To display the value as a percentage, select “Percentage” as the unit of measure from the Data type options list in the component properties.

Clicking this link you can view the topic illustrated in the image below.

Setting the Info component to display the battery level of the Shelly device in Ilevia Manager

Step 11:

Let's configure the component that reports the window tilt value coming from the Shelly device. Add a new Info component to the project and set it to the MQTT protocol from the gateway options list in the component properties.

Adding a new Info component to display the window tilt angle in Ilevia Manager

Step 12:

Topic: shellies/shellydw2-<deviceID>/sensor/tilt

Set the topic that reports the value published by the Shelly device. The value is an integer: to display it as “°”, select the unit of measure from the Data type options list in the component properties.

Clicking this link you can view the topics illustrated in the image below.

Setting the Info component to display the window tilt angle

Step 13:

Let’s configure the component that displays the temperature published by the Shelly device. Add a new Info component to the project and set it to the MQTT protocol from the gateway options list, in the upper part of the component properties.

Adding a new Info component to display the temperature

Step 14:

Topic: shellies/shellydw2-<deviceID>/sensor/temperature

Let’s set the topics. This topic returns the value published by the Shelly device as a decimal number.

By clicking this link you can view the topics shown in the image below.

Setting the Info component topic to display the temperature received from the Shelly device in Ilevia Manager

Step 15:

Finally, let’s configure vibration detection: add a new Button component in the Components section and set its protocol to the previously created MQTT, selecting it from the Gateway options list in the component properties.

Adding a new Button component to send the notification when the Shelly device detects vibrations

Step 16:

Topic: shellies/shellydw2-<deviceID>/sensor/vibration

Now let’s set the related topics: this time the topic does not only receive the state, but also changes the state of the Button component. To reset the Button component state every time the Shelly device triggers it, set a release time (“Auto release”) in the auto release section of the Button component properties; a release time of 1 second is recommended.

By clicking this link you can view the topics shown in the image below.

Setting the Button component topics, which is triggered when the Shelly device detects vibration

How to configure notification sending when vibration is detected

Introduction

If the option is enabled, the Shelly Door Window 2 device sends the value 0 if no vibration is detected and 1 if vibration is detected.

Notifications module setup

Step 1.1:

Add a Notifications component by dragging it from the Messaging section, on the left side of the Components section.

Creating a new Notification component in Ilevia Manager

Step 1.2:

Now select the Button component as the trigger component in the Notification component properties.

Selecting the trigger component for notification sending in Ilevia Manager

Step 1.3:

Now select the user who will receive the notification when the Shelly device detects a vibration: click the “Select user” options list and select the desired user.

Selecting users in the Notification component properties in Ilevia Manager

Step 1.4:

Once the user has been selected, set the notification content that users will receive. You can enter the most suitable information for your needs in the “Content” text field in the Notification component properties.

This completes the notification module setup.

Notification content entered in the component properties in Ilevia Manager

Result in the user interface

Now let’s test all configured components in the Ilevia Control app user interface.

Window closed

The project with the window closed in the Ilevia Control app

Window open

The project with the window open in the Ilevia Control app

Window tilted

The project with the window tilted in the Ilevia Control app

Notification display

This is how the notification is displayed in the Ilevia Control app when the Shelly device detects a vibration.

Notification received in the Ilevia Control app when the Shelly device detects a vibration

Troubleshooting

1- Make sure you have the latest available version of Ilevia Manager and the X1 server firmware.

2- Make sure the Shelly device is correctly connected to your network.

3- If you cannot connect the broker, check that the X1 has been configured correctly.

Give a tip

Last updated: