Zigbee2mqtt - own news

Good morning.
I bought a switch ZS-EUB_2gange

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.

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

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" }'

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.

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.

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

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

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.

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

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

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

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.

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.

1 Like

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

and feed that into the MQTT Out node.

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

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 ```)

``` 
   code goes here 
```

See this post for more details - How to share code or flow json

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

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

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