# How to send mqtt to turn on a Shelly 1 device

**URL:** <https://discourse.nodered.org/t/how-to-send-mqtt-to-turn-on-a-shelly-1-device/71718>\
**Category:** General\
**Created:** [5 December 2022 17:30 UTC](https://discourse.nodered.org/t/how-to-send-mqtt-to-turn-on-a-shelly-1-device/71718 "2022-12-05T17:30:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lindeskovfrank](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lindeskovfrank/32/71289_2.png) [@lindeskovfrank](https://discourse.nodered.org/u/lindeskovfrank)\
**Post date:** [5 December 2022 17:30 UTC](https://discourse.nodered.org/t/how-to-send-mqtt-to-turn-on-a-shelly-1-device/71718/1 "2022-12-05T17:30:19Z")

</div>

I want to test a Shelly temperature, test if it is above or below and send a mqtt message to the Shelly to turn it on or off.

```auto
[
    {
        "id": "311ddb3abbfbce82",
        "type": "debug",
        "z": "f96ed7468badd9c4",
        "name": "<=18",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1030,
        "y": 200,
        "wires": []
    },
    {
        "id": "45ddefc9b9bbdec9",
        "type": "mqtt in",
        "z": "f96ed7468badd9c4",
        "name": "",
        "topic": "shellies/shelly1-3494547070DD/ext_temperature/0",
        "qos": "2",
        "datatype": "auto-detect",
        "broker": "3ecd7f11.4d3dd",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 370,
        "y": 280,
        "wires": [
            [
                "44581b7acff590d1"
            ]
        ]
    },
    {
        "id": "7d804b43fb3305b4",
        "type": "debug",
        "z": "f96ed7468badd9c4",
        "name": ">=19",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1030,
        "y": 340,
        "wires": []
    },
    {
        "id": "1464b3bde2ec1e1f",
        "type": "mqtt out",
        "z": "f96ed7468badd9c4",
        "name": "",
        "topic": "shellies/shelly1-3494547070DD/relay/0/command/on",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "3ecd7f11.4d3dd",
        "x": 1180,
        "y": 240,
        "wires": []
    },
    {
        "id": "44581b7acff590d1",
        "type": "switch",
        "z": "f96ed7468badd9c4",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "lte",
                "v": "18",
                "vt": "str"
            },
            {
                "t": "gte",
                "v": "19",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 710,
        "y": 280,
        "wires": [
            [
                "311ddb3abbfbce82",
                "1464b3bde2ec1e1f"
            ],
            [
                "7d804b43fb3305b4",
                "53bfabb355b0b9ec"
            ]
        ]
    },
    {
        "id": "53bfabb355b0b9ec",
        "type": "mqtt out",
        "z": "f96ed7468badd9c4",
        "name": "",
        "topic": "shellies/shelly1-3494547070DD/relay/0/command/off",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "3ecd7f11.4d3dd",
        "x": 1180,
        "y": 380,
        "wires": []
    },
    {
        "id": "3ecd7f11.4d3dd",
        "type": "mqtt-broker",
        "name": "Mosquitto MQTT Broker",
        "broker": "localhost",
        "port": "",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    }
]

```

I know the mqtt out node is not correct it is an example of the mqtt message I want to send.

But how ?

Best Frank

---

<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:** [5 December 2022 17:42 UTC](https://discourse.nodered.org/t/how-to-send-mqtt-to-turn-on-a-shelly-1-device/71718/2 "2022-12-05T17:42:54Z")

</div>

Have you read the api

[documentation](https://shelly-api-docs.shelly.cloud/gen1/#shelly1-1pm-mqtt)  
the second bullet point describes the topic and payload it will accept

---

<div class="post-metadata">

**Author:** ![lindeskovfrank](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lindeskovfrank/32/71289_2.png) [@lindeskovfrank](https://discourse.nodered.org/u/lindeskovfrank)\
**Post date:** [5 December 2022 19:43 UTC](https://discourse.nodered.org/t/how-to-send-mqtt-to-turn-on-a-shelly-1-device/71718/3 "2022-12-05T19:43:59Z")

</div>

thank your for the response.  
yes I have and if I use an inject node and send  
payload: on  
topic: shellies/shelly1-3494547070DD/relay/0/command

into a mqtt out node it works :0)

How do I make an "inject node" that I can trigger?

Best Frank

---

<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:** [5 December 2022 19:55 UTC](https://discourse.nodered.org/t/how-to-send-mqtt-to-turn-on-a-shelly-1-device/71718/4 "2022-12-05T19:55:21Z")

</div>

Use a change node after a switch node to determine if temp greater or less than.

---

<div class="post-metadata">

**Author:** ![lindeskovfrank](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lindeskovfrank/32/71289_2.png) [@lindeskovfrank](https://discourse.nodered.org/u/lindeskovfrank)\
**Post date:** [6 December 2022 09:21 UTC](https://discourse.nodered.org/t/how-to-send-mqtt-to-turn-on-a-shelly-1-device/71718/5 "2022-12-06T09:21:32Z")

</div>

Ahh :0) I read your suggestion and thought that does not work I have to change both the topic and the payload.  
And as it turns out you can :0) so thank you a loth I was really getting frustarted.

Thanks again  
Frank

---

<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:** [20 December 2022 09:21 UTC](https://discourse.nodered.org/t/how-to-send-mqtt-to-turn-on-a-shelly-1-device/71718/6 "2022-12-20T09:21:59Z")

</div>

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