# Zigbee2mqtt - own news

**URL:** <https://discourse.nodered.org/t/zigbee2mqtt-own-news/93625>\
**Category:** General\
**Created:** [2 December 2024 13:00 UTC](https://discourse.nodered.org/t/zigbee2mqtt-own-news/93625 "2024-12-02T13:00:08Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Le-Ze](https://avatars.discourse-cdn.com/v4/letter/l/a87d85/32.png) [@Le-Ze](https://discourse.nodered.org/u/Le-Ze)\
**Post date:** [2 December 2024 13:00 UTC](https://discourse.nodered.org/t/zigbee2mqtt-own-news/93625/1 "2024-12-02T13:00:08Z")

</div>

Good morning.  
I bought a switch ZS-EUB\_2gange

> **[Moes ZS-EUB\_2gang control via MQTT | Zigbee2MQTT](https://www.zigbee2mqtt.io/devices/ZS-EUB_2gang.html)**
>
> Integrate your Moes ZS-EUB\_2gang via Zigbee2MQTT with whatever smart home infrastructure you are using without the vendor's bridge or gateway.

Switch (left endpoint)  
payload {"state\_left": "ON"}, {"state\_left": "OFF"} or {"state\_left": "TOGGLE"}.

Switch (right endpoint)  
{"state\_right": "ON"}, {"state\_right": "OFF"} or {"state\_right": "TOGGLE"}

In Zigbee2MQTT out - command - is not state\_left,state\_right.  
He's just there sate.  
How to send state\_right": "TOGGLE"?  
Thank you.

---

<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:** [2 December 2024 13:23 UTC](https://discourse.nodered.org/t/zigbee2mqtt-own-news/93625/2 "2024-12-02T13:23:52Z")

</div>

If you install and run MQTTExplorer and connect to your MQTT server, what topics/values do you see for the switch?

---

<div class="post-metadata">

**Author:** ![Le-Ze](https://avatars.discourse-cdn.com/v4/letter/l/a87d85/32.png) [@Le-Ze](https://discourse.nodered.org/u/Le-Ze)\
**Post date:** [2 December 2024 16:20 UTC](https://discourse.nodered.org/t/zigbee2mqtt-own-news/93625/3 "2024-12-02T16:20:15Z")

</div>

This works through terminal

mosquitto\_pub -t 'zigbee2mqtt/0xa4c138dfe4ce8c20/set' -m '{ "state\_left": "ON" }'  
mosquitto\_pub -t 'zigbee2mqtt/0xa4c138dfe4ce8c20/set' -m '{ "state\_left": "OFF" }'  
mosquitto\_pub -t 'zigbee2mqtt/0xa4c138dfe4ce8c20/set' -m '{ "state\_left": "TOGGLE" }'

mosquitto\_pub -t 'zigbee2mqtt/0xa4c138dfe4ce8c20/set' -m '{ "state\_right": "ON" }'  
mosquitto\_pub -t 'zigbee2mqtt/0xa4c138dfe4ce8c20/set' -m '{ "state\_right": "OFF" }'  
mosquitto\_pub -t 'zigbee2mqtt/0xa4c138dfe4ce8c20/set' -m '{ "state\_right": "TOGGLE" }'

---

<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:** [2 December 2024 16:44 UTC](https://discourse.nodered.org/t/zigbee2mqtt-own-news/93625/4 "2024-12-02T16:44:53Z")

</div>

So what is it that you don't know how to do? Use an MQTT Out node and send those values to that topic.

Make life easier for yourself, though, and configure Friendly Names in zigbee2MQTT. Firstly that makes remembering topics much easier, and secondly, if you have to replace the switch, all you have to do is to configure the new one with the name.

---

<div class="post-metadata">

**Author:** ![Le-Ze](https://avatars.discourse-cdn.com/v4/letter/l/a87d85/32.png) [@Le-Ze](https://discourse.nodered.org/u/Le-Ze)\
**Post date:** [2 December 2024 16:51 UTC](https://discourse.nodered.org/t/zigbee2mqtt-own-news/93625/5 "2024-12-02T16:51:32Z")

</div>

I want to know how to do it through Zigbee2mqtt.

> **[node-red-contrib-zigbee2mqtt](https://flows.nodered.org/node/node-red-contrib-zigbee2mqtt)**
>
> Zigbee2mqtt connectivity nodes for node-red

---

<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:** [2 December 2024 16:56 UTC](https://discourse.nodered.org/t/zigbee2mqtt-own-news/93625/6 "2024-12-02T16:56:48Z")

</div>

> [@Le-Ze](#):
>
> I want to know how to do it through Zigbee2mqtt.

Don't bother, it is easier just to use MQTT nodes, as you have found out. The zigbee node contributes little, if anything, and has numerous unaddressed issues on its github page.

---

<div class="post-metadata">

**Author:** ![Le-Ze](https://avatars.discourse-cdn.com/v4/letter/l/a87d85/32.png) [@Le-Ze](https://discourse.nodered.org/u/Le-Ze)\
**Post date:** [2 December 2024 17:52 UTC](https://discourse.nodered.org/t/zigbee2mqtt-own-news/93625/7 "2024-12-02T17:52:21Z")

</div>

It doesn't work via MQTT out.  
Server OK. You write connected.

How to write to topic?  
zigbee2mqtt/0xa4c138dfe4ce8c20/set -m '{ "state\_right": "TOGGLE" }'

---

<div class="post-metadata">

**Author:** ![gemini86](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gemini86/32/70967_2.png) [@gemini86](https://discourse.nodered.org/u/gemini86)\
**Post date:** [2 December 2024 18:04 UTC](https://discourse.nodered.org/t/zigbee2mqtt-own-news/93625/8 "2024-12-02T18:04:56Z")

</div>

use a change node before the mqtt out node.  
Set msg.topic to 'zigbee2mqtt/0xa4c138dfe4ce8c20/set'.  
Then set msg.payload to '{ "state\_right": "TOGGLE" }'.

You could also configure the mqtt out node to that topic and only send messages for that topic to that node. I tend to use only a few mqtt out nodes and dynamically set the topic with a change node.

---

<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:** [2 December 2024 18:25 UTC](https://discourse.nodered.org/t/zigbee2mqtt-own-news/93625/9 "2024-12-02T18:25:55Z")

</div>

> [@gemini86](#):
>
> set msg.payload to '{ "state\_right": "TOGGLE" }'.

That is with the type set to `{}` not string.

---

<div class="post-metadata">

**Author:** ![gemini86](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gemini86/32/70967_2.png) [@gemini86](https://discourse.nodered.org/u/gemini86)\
**Post date:** [2 December 2024 18:32 UTC](https://discourse.nodered.org/t/zigbee2mqtt-own-news/93625/10 "2024-12-02T18:32:51Z")

</div>

in this case it would be converted into a JSON string either way in the MQTT out node, right?

---

<div class="post-metadata">

**Author:** ![Le-Ze](https://avatars.discourse-cdn.com/v4/letter/l/a87d85/32.png) [@Le-Ze](https://discourse.nodered.org/u/Le-Ze)\
**Post date:** [2 December 2024 18:34 UTC](https://discourse.nodered.org/t/zigbee2mqtt-own-news/93625/11 "2024-12-02T18:34:03Z")

</div>

I'm looking for the Internet and I don't know how to solve.

> **[mqtt hosted at ImgBB](https://ibb.co/zPPWJks)**
>
> Image mqtt hosted in ImgBB

---

<div class="post-metadata">

**Author:** ![gemini86](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gemini86/32/70967_2.png) [@gemini86](https://discourse.nodered.org/u/gemini86)\
**Post date:** [2 December 2024 18:45 UTC](https://discourse.nodered.org/t/zigbee2mqtt-own-news/93625/12 "2024-12-02T18:45:51Z")

</div>

It would be super helpful if you could copy all the nodes in your flow and export them to JSON so you can drop it in here. To really get a handle on how this should work though, watch some youtube videos or read through a couple starter tutorials.

---

<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:** [2 December 2024 20:36 UTC](https://discourse.nodered.org/t/zigbee2mqtt-own-news/93625/13 "2024-12-02T20:36:10Z")

</div>

> [@gemini86](#):
>
> in this case it would be converted into a JSON string either way in the MQTT out node, right?

Possibly, but who cares. When you are in node-red you can use the object features of javascript to make life easier. Doing it that way has the advantage that it will check for syntax errors in the data you give it.

---

<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:** [2 December 2024 20:41 UTC](https://discourse.nodered.org/t/zigbee2mqtt-own-news/93625/14 "2024-12-02T20:41:03Z")

</div>

> [@Le-Ze](#):
>
> I'm looking for the Internet and I don't know how to solve.

Don't know how to solve what? All you need for this simple test is a Change node configured like

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/0/70860dd950e590f0e1c0351f7568a757103254ce.png)

and feed that into the MQTT Out node.

---

<div class="post-metadata">

**Author:** ![Le-Ze](https://avatars.discourse-cdn.com/v4/letter/l/a87d85/32.png) [@Le-Ze](https://discourse.nodered.org/u/Le-Ze)\
**Post date:** [2 December 2024 22:05 UTC](https://discourse.nodered.org/t/zigbee2mqtt-own-news/93625/15 "2024-12-02T22:05:00Z")

</div>

But I'm trying to do something wrong.  
MQTT OUT writes connected.

> **[\[{ "id": "51386e6609a80ba1", "type": "mqtt out", -...](https://pastebin.com/GkM9VMQY)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

---

<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:** [2 December 2024 22:14 UTC](https://discourse.nodered.org/t/zigbee2mqtt-own-news/93625/16 "2024-12-02T22:14:33Z")

</div>

In future, please past flows here directly. In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote `````)

````auto
``` 
   code goes here 
```

````

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

Is your mqtt broker running on the same machine as node-red? If so then you should have `localhost` as the broker address.

> [@Le-Ze](#):
>
> MQTT OUT writes connected.

Do you mean the the mqtt node is showing 'connected' as its status. If so then that is correct.

---

<div class="post-metadata">

**Author:** ![Le-Ze](https://avatars.discourse-cdn.com/v4/letter/l/a87d85/32.png) [@Le-Ze](https://discourse.nodered.org/u/Le-Ze)\
**Post date:** [2 December 2024 22:25 UTC](https://discourse.nodered.org/t/zigbee2mqtt-own-news/93625/17 "2024-12-02T22:25:51Z")

</div>

You put a change knot here.  
It works.  
Thank you.
