# Node-red-contrib-shelly for 2 PM in cover mode

**URL:** https://discourse.nodered.org/t/node-red-contrib-shelly-for-2-pm-in-cover-mode/67899
**Category:** General
**Created:** [18 September 2022 20:32 UTC](https://discourse.nodered.org/t/node-red-contrib-shelly-for-2-pm-in-cover-mode/67899 "2022-09-18T20:32:24Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Simone](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@Simone](https://discourse.nodered.org/u/Simone)
#### Post date: [18 September 2022 20:32 UTC](https://discourse.nodered.org/t/node-red-contrib-shelly-for-2-pm-in-cover-mode/67899/1 "2022-09-18T20:32:24Z")

</div>

Hi there,  
I can't find the syntax of the message to control the position of the roller/cover using node-red-contrib-shelly (Shelly Gen 2) and the Shelly Plus 2PM.

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [19 September 2022 10:06 UTC](https://discourse.nodered.org/t/node-red-contrib-shelly-for-2-pm-in-cover-mode/67899/2 "2022-09-19T10:06:09Z")

</div>

From reading the doc linked below, I think something like below

```auto
{"id":123, "src":"mytopic", "method":"Cover.GoToPosition", "pos": 20}

```

> **[Cover | Shelly Technical Documentation](https://shelly-api-docs.shelly.cloud/gen2/ComponentsAndServices/Cover/#covergotoposition-example)**
>
> The Cover component handles the operation of motorized garage doors, window blinds, roof skylights etc. It uses Cover as RPC namespace and provides the methods:

> **[MQTT | Shelly Technical Documentation](https://shelly-api-docs.shelly.cloud/gen2/ComponentsAndServices/Mqtt/)**
>
> The MQTT component handles configuration and status of the outbound MQTT connection. The supported Quality of service level is 1, which guarantees that a message is delivered at least one time to the receiver. Here, you can find how to configure your...

---

<div class="post-metadata">

### Author: ![Simone](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@Simone](https://discourse.nodered.org/u/Simone)
#### Post date: [27 September 2022 17:19 UTC](https://discourse.nodered.org/t/node-red-contrib-shelly-for-2-pm-in-cover-mode/67899/3 "2022-09-27T17:19:59Z")

</div>

> [@Simone](#):
>
> the syntax of the message to control the position of the roller/cover using node-red-contrib-shelly (Shelly Gen 2) and the Shelly Plus 2PM.

Many Thanks,  
It works!  
On the same Shelly Plus 2PM I can't have the MQTT notification of the relay's status change.  
At the moment I'm subscribing my clients to these topics:

- shellies / CucinaLuci / relay / 0

- shellies / CucinaLuci / relay / 1

Where CucinaLuci is both MQTT\_Prefix and Client\_ID in the configuration page of the module, see the following picture.

 ![Shelli 2pm mqtt](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/3/33ea0abede404d2354b3abc159396af5b5a7ca93.jpeg)

No user and password are requested from my MQTT broker.

With a Shelly 2.5 it works while with the 2PM it doesn't.

From the documentation, the topic format of the two modules looks the same.

If I'm not on the right way, please suggest me the MQTT\_Prefix or Client\_ID and the topics for the subscriber.

Many thanks again.

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [27 September 2022 19:23 UTC](https://discourse.nodered.org/t/node-red-contrib-shelly-for-2-pm-in-cover-mode/67899/4 "2022-09-27T19:23:55Z")

</div>

RTM  
from the links i supplied

> Step 6: Receive notifications over MQTT[​](https://shelly-api-docs.shelly.cloud/gen2/ComponentsAndServices/Mqtt#step-6-receive-notifications-over-mqtt)

> Now, let's see the communication over MQTT in action. For this to happen, subscribe to the MQTT topic `<shelly-id>/events/rpc`, where you must replace `shelly-id` with your device's ID. For example, _shellypro4pm-f008d1d8b8b8/events/rpc_:

---

<div class="post-metadata">

### Author: ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)
#### Post date: [27 September 2022 19:35 UTC](https://discourse.nodered.org/t/node-red-contrib-shelly-for-2-pm-in-cover-mode/67899/5 "2022-09-27T19:35:35Z")

</div>

> [@Simone](#):
>
> On the same Shelly Plus 2PM I can't have the MQTT notification of the relay's status change.  
> At the moment I'm subscribing my clients to these topics:
> 
> - shellies / CucinaLuci / relay / 0
> - shellies / CucinaLuci / relay / 1

Spaces are not allowed in MQTT topics!

- shellies/CucinaLuci/relay/0
- shellies/CucinaLuci/relay/1

---

<div class="post-metadata">

### Author: ![Simone](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@Simone](https://discourse.nodered.org/u/Simone)
#### Post date: [27 September 2022 19:49 UTC](https://discourse.nodered.org/t/node-red-contrib-shelly-for-2-pm-in-cover-mode/67899/6 "2022-09-27T19:49:12Z")

</div>

Sorry, it's copy and paste effect. No spaces in the original topic.  
Seems as E1cid sayed, the topic is CucinaLuci/events/rpc and the payload is json. So it's different from 2.5.

---

<div class="post-metadata">

### Author: ![Simone](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@Simone](https://discourse.nodered.org/u/Simone)
#### Post date: [27 September 2022 19:59 UTC](https://discourse.nodered.org/t/node-red-contrib-shelly-for-2-pm-in-cover-mode/67899/7 "2022-09-27T19:59:12Z")

</div>

👍  
Works! Now a little trouble with the payload. After the json conversion I have the following payload but I don't know how to manage the field: switch:0

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/f/6fe3a73a46a3cd2a0d05bdc74b309142944c8a7e.png)

I need the field output so I tried with:  
var Switch0 = msg.payload.params.switch[0].output;  
var Switch0 = msg.payload.params.switch.0.output;  
ad a lot of other random 😱 combination of ", ', ....  
but it's wrong... never managed : in the payload fields

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [27 September 2022 20:04 UTC](https://discourse.nodered.org/t/node-red-contrib-shelly-for-2-pm-in-cover-mode/67899/8 "2022-09-27T20:04:49Z")

</div>

> [@Simone](#):
>
> var Switch0 = msg.payload.params.switch[0].output;

`let Switch0 = msg.payload.params["switch:0"].output;`  
The property name has non spec characters in, so you have to use [] notation.

p.s. There is a copy path button in the sidebar debug panel. Hover mouse to right of object name.

---

<div class="post-metadata">

### Author: ![Simone](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@Simone](https://discourse.nodered.org/u/Simone)
#### Post date: [27 September 2022 20:46 UTC](https://discourse.nodered.org/t/node-red-contrib-shelly-for-2-pm-in-cover-mode/67899/9 "2022-09-27T20:46:56Z")

</div>

Perfect!  
Many thanks! Finally works.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [11 October 2022 20:47 UTC](https://discourse.nodered.org/t/node-red-contrib-shelly-for-2-pm-in-cover-mode/67899/10 "2022-10-11T20:47:44Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
