Page 1 of 1

How to set Espeasy when 2 switches are using the same broker

Posted: 12 Apr 2017, 06:29
by jackwan1
I have two sonoff switches. When I set one switch, I have no problem to control it with node-red through mosquitto broker.

But when I add another identical switch, I have mqtt connection lost and re connect alternatively between the two switches and lost control on GPIO 12 of one switch.
In the log, the connection failure count also increase alternatively two at a time.

I name the switches differently also the names in the device definition differently.

What am I missing?

Re: How to set Espeasy when 2 switches are using the same broker

Posted: 12 Apr 2017, 06:47
by grovkillen
Tried giving them different Unit number?

Re: How to set Espeasy when 2 switches are using the same broker

Posted: 12 Apr 2017, 09:56
by jackwan1
Thank you
Where can I give them a unique unit number? The name of each unit is different, i.e. Sonoff1/# and sonoff2/#

Re: How to set Espeasy when 2 switches are using the same broker

Posted: 12 Apr 2017, 10:20
by grovkillen
Under the config tab.

Re: How to set Espeasy when 2 switches are using the same broker

Posted: 12 Apr 2017, 10:27
by jackwan1
Nvm
I saw the unit number entry in the config menu. Never thought it is significant
Thank you

Re: How to set Espeasy when 2 switches are using the same broker

Posted: 12 Apr 2017, 10:32
by grovkillen
A piece of advice: include the unit number in the device name. I.e. nodename_001, nodename_002 etc. It may be hard to find what next number is available.


PS. this should be implemented in the FW (to be able to publish the %unitnr% as the same manner as %ip%, %sysname% and %systime%). Just my opinion..

Re: How to set Espeasy when 2 switches are using the same broker

Posted: 14 Apr 2017, 23:00
by jackwan1
actually I found out if you put a / in the espeasy name, you can subscribe and publish with a /# qualifier

For example, I name each sonoff switch as sonoff/1.....x instead of sonoff1....x

The benefit of that is in subscribe, I only need to subscribe: sonoff/# and one MQTT client will receive the information from all switches.

and when I publish, I can publish to "sonoff" and each sonoff unit will receive the same command. In my case, I only need one big timer in node red to control all my switches.

That is if you want to treat the series of switches in a "scene" like in IFTTT. You can also easily control each unit separately by using the full name convention.